Add mb_confidence as a configurable variable.
Update the project main and api_calls.py to get and use a confidence value set in config.ini.
This commit is contained in:
parent
d6060c2e61
commit
370151373c
@ -1,13 +1,13 @@
|
||||
import requests
|
||||
import os
|
||||
|
||||
def get_mb_id(artist_name):
|
||||
def get_mb_id(artist_name, mb_confidence):
|
||||
mb_url = f'https://musicbrainz.org/ws/2/artist?query=artist:%22{artist_name}%22&fmt=json'
|
||||
response = requests.get(mb_url)
|
||||
if response.status_code == 200:
|
||||
mb_data = response.json()
|
||||
if mb_data['count'] > 0:
|
||||
if mb_data['artists'][0]['score'] > 80:
|
||||
if mb_data['artists'][0]['score'] > mb_confidence:
|
||||
return mb_data['artists'][0]['id']
|
||||
else:
|
||||
print("No artist found of hight enough confidance.")
|
||||
|
@ -10,6 +10,7 @@ config.read('config.ini')
|
||||
|
||||
music_path = config['music']['dir']
|
||||
ftv_api_key = config['fanart_tv']['api_key']
|
||||
mb_confidence = config['musicbrainz']['confidence']
|
||||
|
||||
count = 1
|
||||
dir_list = dir_activities.get_all(music_path)
|
||||
@ -19,7 +20,7 @@ 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_id = api_calls.get_mb_id(artist, mb_confidence)
|
||||
# print("Getting ", artist_image)
|
||||
artist_image = api_calls.get_image(mb_id, ftv_api_key, os.path.join(music_path, artist))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user