-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (40 loc) · 1.24 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os, sys
from pathlib import Path
from collector import collector
from uploader import uploader
from threading import Thread
import logging
logging.basicConfig(
filename="app.log",
encoding="utf-8",
filemode="a",
format="{asctime} - {levelname} - {message}",
style="{",
datefmt="%Y-%m-%d %H:%M",
)
song_dir_path = input("enter songs dir path : ")
if song_dir_path == "":
logging.critical("dir not provided")
sys.exit(1)
files = os.listdir(song_dir_path)
def do_main_stuff():
while len(files) != 0:
file = files.pop()
if Path(file).suffix != ".mp3":
logging.info("other file extension")
continue
try:
song_path = f"{song_dir_path}/{file}"
collected = collector(song_path)
response = uploader(
data=collected[0], thumb_path=collected[1], audio_path=song_path
)
if response.status_code == 201:
print("success")
else:
print(response.status_code)
logging.warning(f"failed to upload {file} - {response.status_code}")
except Exception as e:
logging.warning(e)
for _ in range(40):
Thread(target=do_main_stuff).start()