From b9c28af9e209a23cee63c8d006ce296283cfd93c Mon Sep 17 00:00:00 2001 From: 吳俊翰 Date: Fri, 5 May 2023 17:31:09 +0800 Subject: Update main.py --- main.py | 11 +++++------ 1 file 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') -- cgit v1.2.3-70-g09d2