소스 검색

[music] Fix error when mb fails

Colin Powell 10 달 전
부모
커밋
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(