浏览代码

[music] Fix error when mb fails

Colin Powell 9 月之前
父节点
当前提交
1df8157d8d
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      vrobbler/apps/music/musicbrainz.py

+ 6 - 3
vrobbler/apps/music/musicbrainz.py

@@ -108,9 +108,12 @@ def lookup_track_from_mb(
 ) -> str:
     musicbrainzngs.set_useragent("vrobbler", "0.3.0")
 
-    top_result = musicbrainzngs.search_recordings(
-        query=track_name, artist=artist_mbid, release=album_mbid
-    )["recording-list"][0]
+    try:
+        top_result = musicbrainzngs.search_recordings(
+            query=track_name, artist=artist_mbid, release=album_mbid
+        )["recording-list"][0]
+    except IndexError:
+        return ""
     score = int(top_result.get("ext:score"))
     if score < 85:
         logger.debug(