Add fetching of hdmusiclogo if artistthumb fails.
This will catch a few more artists and at least place something in their directory.
This commit is contained in:
parent
858d68b491
commit
fe8a4c2410
23
api_calls.py
23
api_calls.py
@ -23,14 +23,23 @@ def get_image(mb_id, ftv_api_key, artist_path):
|
|||||||
response = requests.get(ftv_api_url)
|
response = requests.get(ftv_api_url)
|
||||||
ftv_data =response.json()
|
ftv_data =response.json()
|
||||||
if not ('status' in ftv_data):
|
if not ('status' in ftv_data):
|
||||||
art_url = ftv_data['artistthumb'][0]['url']
|
if ('artistthumb' in ftv_data):
|
||||||
print(art_url)
|
art_url = ftv_data['artistthumb'][0]['url']
|
||||||
response = requests.get(art_url)
|
print(art_url)
|
||||||
if response.status_code == 200:
|
response = requests.get(art_url)
|
||||||
with open(os.path.join(artist_path, 'artist.jpg'), 'wb') as f:
|
if response.status_code == 200:
|
||||||
f.write(response.content)
|
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']
|
||||||
|
response = requests.get(art_url)
|
||||||
|
if response.status_code == 200:
|
||||||
|
with open(os.path.join(artist_path, 'artist.png'), 'wb') as f:
|
||||||
|
f.write(response.content)
|
||||||
|
else:
|
||||||
|
print("Error downloading: ", response.status_code)
|
||||||
else:
|
else:
|
||||||
print("Error downloading: ", response.status_code)
|
print("Thumb not found.")
|
||||||
else:
|
else:
|
||||||
error_msg = ftv_data['error message']
|
error_msg = ftv_data['error message']
|
||||||
print(f"Error: {error_msg}")
|
print(f"Error: {error_msg}")
|
Loading…
x
Reference in New Issue
Block a user