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:
2024-09-20 13:03:57 -04:00
parent d6060c2e61
commit 370151373c
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -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.")