From 851ef0ef6ee721d440c1d83f44c28ee9bdab3b5d Mon Sep 17 00:00:00 2001 From: Mohammad Momeni Date: Sun, 28 Jul 2024 11:39:06 +0200 Subject: [PATCH] Return None in case of not expected result Fixes #52 --- syncedlyrics/providers/musixmatch.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syncedlyrics/providers/musixmatch.py b/syncedlyrics/providers/musixmatch.py index 83b9b60..8c1dd49 100644 --- a/syncedlyrics/providers/musixmatch.py +++ b/syncedlyrics/providers/musixmatch.py @@ -125,6 +125,8 @@ def get_lrc(self, search_term: str) -> Optional[Lyrics]: self.logger.warning(f"Got status code {status_code} for {search_term}") return None body = r.json()["message"]["body"] + if not isinstance(body, dict): + return None tracks = body["track_list"] cmp_key = lambda t: f"{t['track']['track_name']} {t['track']['artist_name']}" track = get_best_match(tracks, search_term, cmp_key)