Reimpliment delay to only trigger on 503 response
The code has been refactored to only trigger a one second delay when one of the APIs have returned a 503. This will allow the script to finish faster.
This commit is contained in:
+10
-5
@@ -24,19 +24,24 @@ dir_list.sort()
|
||||
for artist in dir_list:
|
||||
artist_path = os.path.join(music_path, artist)
|
||||
if (not(dir_activities.has_artist_art(artist_path))):
|
||||
print(dir_activities.has_artist_art(artist_path))
|
||||
# print(dir_activities.has_artist_art(artist_path))
|
||||
print(str(count) + ": " + artist.strip('_'))
|
||||
try:
|
||||
found_status, mb_id = api_calls.get_mb_id(artist, mb_confidence)
|
||||
ftv_response = False
|
||||
mb_exit = False
|
||||
while not mb_exit:
|
||||
found_status, mb_id, mb_exit = api_calls.get_mb_id(artist, mb_confidence)
|
||||
# print("Getting ", artist_image)
|
||||
if found_status:
|
||||
artist_image = api_calls.get_image(mb_id, ftv_api_key, artist_path)
|
||||
while not ftv_response:
|
||||
ftv_response = api_calls.get_image(mb_id, ftv_api_key, artist_path)
|
||||
print(ftv_response)
|
||||
else:
|
||||
print(f"{artist} returned no results.")
|
||||
# api_requests.get_art(artist_image, artist, music_path)
|
||||
except Exception as e:
|
||||
print("Artist or art not found.")
|
||||
print(e)
|
||||
|
||||
print("---------")
|
||||
count += 1
|
||||
sleep(1)
|
||||
#sleep(1)
|
||||
|
||||
Reference in New Issue
Block a user