lyrics plugin: retry lyrics search with unidecoded artist name

This commit is contained in:
cwilvx
2024-05-24 15:36:23 +03:00
parent 7646f57405
commit 300c8eb30b
+13 -2
View File
@@ -141,12 +141,12 @@ class LyricsProvider(LRCProvider):
return body["subtitle"]["subtitle_body"]
def get_lrc(self, title: str, artist: str) -> Optional[str]:
def get_lrc(self, title: str, artist: str):
res = self._get(
"track.search",
[
("q_track", title),
("q_artist", unidecode(artist)),
("q_artist", artist),
("page_size", "5"),
("page", "1"),
("f_has_lyrics", "1"),
@@ -165,6 +165,17 @@ class LyricsProvider(LRCProvider):
except TypeError:
return []
if not tracks:
# if the artist name contains non-ascii characters, try to decode it
decoded = unidecode(artist)
# if the decoded artist name is the same as the original, return an empty list
if decoded == artist:
return []
# if the decoded artist name is different, retry!
return self.get_lrc(title, decoded)
return [
{
"track_id": t["track"]["track_id"],