aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
author吳俊翰2023-05-05 17:31:09 +0800
committerGitHub2023-05-05 17:31:09 +0800
commitb9c28af9e209a23cee63c8d006ce296283cfd93c (patch)
tree755af1c0440712f055a1096e3e4724f1abb9aa8c /main.py
parent5f698e6afefc87bd1a3ccdd1ed6b6401a289c5f9 (diff)
Update main.py
Diffstat (limited to 'main.py')
-rw-r--r--main.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/main.py b/main.py
index 30a58b3..806cd47 100644
--- a/main.py
+++ b/main.py
@@ -150,6 +150,9 @@ def download_song(session, directory, name, url, song_counter, lock):
if downloaded < total:
print(f'Download of {name} was incomplete. Retrying...', file=sys.stderr)
os.remove(filename)
+ # Increase song counter
+ with lock:
+ song_counter.value += 1
# If file is .wav then export to .flac
if source.headers['content-type'] != 'audio/mpeg':
@@ -157,11 +160,7 @@ def download_song(session, directory, name, url, song_counter, lock):
os.remove(filename)
filename = directory + '/' + make_valid(name) + '.flac'
filetype = '.flac'
-
- # Increase song counter
- with lock:
- song_counter.value += 1
-
+
return filename, filetype
@@ -303,7 +302,7 @@ def main():
song_total = song_counter.value
album_total = album_counter.value
# Write counter to file
- with open("counter.txt", "a") as f:
+ with open("Statistics.txt", "a") as f:
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
f.write(f'Finish Time: {timestamp}\n')
f.write(f'Total albums skipped: {pass_total}\n')