mb_confidence now working as a variable.
The value from config.ini is returned as a string. It needs to be cast to an int before use.
This commit is contained in:
parent
370151373c
commit
3eb993e3c4
@ -8,13 +8,15 @@ def get_mb_id(artist_name, mb_confidence):
|
||||
mb_data = response.json()
|
||||
if mb_data['count'] > 0:
|
||||
if mb_data['artists'][0]['score'] > mb_confidence:
|
||||
return mb_data['artists'][0]['id']
|
||||
return True, mb_data['artists'][0]['id']
|
||||
else:
|
||||
print("No artist found of hight enough confidance.")
|
||||
else:
|
||||
print("No artist found.")
|
||||
return False, ""
|
||||
else:
|
||||
print(f"Error: {response.status_code}")
|
||||
return False, ""
|
||||
|
||||
def get_image(mb_id, ftv_api_key, artist_path):
|
||||
ftv_api_url = f'https://webservice.fanart.tv/v3/music/{mb_id}?api_key={ftv_api_key}'
|
||||
|
@ -10,7 +10,7 @@ config.read('config.ini')
|
||||
|
||||
music_path = config['music']['dir']
|
||||
ftv_api_key = config['fanart_tv']['api_key']
|
||||
mb_confidence = config['musicbrainz']['confidence']
|
||||
mb_confidence = int(config['musicbrainz']['confidence'])
|
||||
|
||||
count = 1
|
||||
dir_list = dir_activities.get_all(music_path)
|
||||
@ -20,10 +20,12 @@ for artist in dir_list:
|
||||
print(dir_activities.has_artist_art(artist))
|
||||
print(str(count) + ": " + artist)
|
||||
try:
|
||||
mb_id = api_calls.get_mb_id(artist, mb_confidence)
|
||||
found_status, mb_id = 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, os.path.join(music_path, artist))
|
||||
|
||||
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.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user