From dc4e83b1336dfce003c4ec01d0f257a7799b5bf0 Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Mon, 24 Feb 2025 13:15:53 -0500 Subject: [PATCH] Clean api code Clean up the formatting. --- api_calls.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api_calls.py b/api_calls.py index 268c9eb..ffa18d8 100644 --- a/api_calls.py +++ b/api_calls.py @@ -18,7 +18,7 @@ def get_mb_id(artist_name, mb_confidence): else: print("No artist found.") return False, "", True - elif (response.status_code == 503): + elif response.status_code == 503: sleep(1) return False, "", False else: @@ -30,7 +30,7 @@ def get_image(mb_id, ftv_api_key, artist_path): response = requests.get(ftv_api_url) ftv_data =response.json() if not ('status' in ftv_data): - if ('artistthumb' in ftv_data): + if 'artistthumb' in ftv_data: art_url = ftv_data['artistthumb'][0]['url'] print(art_url) response = requests.get(art_url) @@ -38,14 +38,14 @@ def get_image(mb_id, ftv_api_key, artist_path): with open(os.path.join(artist_path, 'artist.jpg'), 'wb') as f: f.write(response.content) return True - elif ('artistbackground' in ftv_data): + elif 'artistbackground' in ftv_data: art_url = ftv_data['artistbackground'][0]['url'] response = requests.get(art_url) - if (response.status_code == 200): + if response.status_code == 200: with open(os.path.join(artist_path, 'artist.jpg'),'wb') as f: f.write(response.content) return True - elif ('hdmusiclogo' in ftv_data): + elif 'hdmusiclogo' in ftv_data: art_url = ftv_data['hdmusiclogo'][0]['url'] response = requests.get(art_url) if response.status_code == 200: @@ -58,12 +58,12 @@ def get_image(mb_id, ftv_api_key, artist_path): else: print("Thumb not found.") return True - elif (response.status_code == 503): + elif response.status_code == 503: sleep(1) return False else: error_msg = ftv_data['error message'] - if (error_msg == "503"): + if error_msg == "503": sleep(1) return False else: