From c5ffadd1f04a2503fd96a43a2fa1bf8e5653401c Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Mon, 14 Oct 2024 10:34:43 -0400 Subject: [PATCH 1/2] Get the artist background. Adds the artist background as a possible source of artist image. --- api_calls.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api_calls.py b/api_calls.py index aa1bcbd..4cef228 100644 --- a/api_calls.py +++ b/api_calls.py @@ -32,6 +32,12 @@ def get_image(mb_id, ftv_api_key, artist_path): if response.status_code == 200: with open(os.path.join(artist_path, 'artist.jpg'), 'wb') as f: f.write(response.content) + elif ('artistbackground' in ftv_data): + art_url = ftv_data['artistbackground'][0]['url'] + response = requests.get(art_url) + if (response.status_code == 200): + with open('artist.jpg','wb') as f: + f.write(response.content) elif ('hdmusiclogo' in ftv_data): art_url = ftv_data['hdmusiclogo'][0]['url'] response = requests.get(art_url) From 883f594f4f7ae2484de4be9ab4303baa83c5287a Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Mon, 14 Oct 2024 11:08:17 -0400 Subject: [PATCH 2/2] Fix the output path of Artist Background. The artist background had been saving to the folder the script was run from. This has now been resolved. --- api_calls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_calls.py b/api_calls.py index 4cef228..649edc4 100644 --- a/api_calls.py +++ b/api_calls.py @@ -36,7 +36,7 @@ def get_image(mb_id, ftv_api_key, artist_path): art_url = ftv_data['artistbackground'][0]['url'] response = requests.get(art_url) if (response.status_code == 200): - with open('artist.jpg','wb') as f: + with open(os.path.join(artist_path, 'artist.jpg'),'wb') as f: f.write(response.content) elif ('hdmusiclogo' in ftv_data): art_url = ftv_data['hdmusiclogo'][0]['url']