Fix it so lastfm imports dont barf

This commit is contained in:
2023-04-06 15:39:13 -04:00
parent 2896225826
commit 9baf1069b6
3 changed files with 26 additions and 7 deletions

View File

@ -53,10 +53,18 @@ def lookup_album_from_mb(musicbrainz_id: str) -> dict:
def lookup_album_dict_from_mb(release_name: str, artist_name: str) -> dict:
musicbrainzngs.set_useragent("vrobbler", "0.3.0")
top_result = musicbrainzngs.search_releases(
release_name, artist=artist_name
)["release-list"][0]
score = int(top_result.get("ext:score"))
top_result = {}
try:
top_result = musicbrainzngs.search_releases(
release_name, artist=artist_name
)["release-list"][0]
except IndexError:
logger.info(
f"No release found on MB for {artist_name} and {release_name}"
)
score = int(top_result.get("ext:score", 0))
if score < 85:
logger.debug(
"Album lookup score below 85 threshold",