mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
lyrics plugin: retry lyrics search with unidecoded artist name
This commit is contained in:
+13
-2
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user