Skip to content

Commit

Permalink
improved lyrics matching
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat committed Feb 25, 2024
1 parent 149b7a6 commit e4de031
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spotdl/providers/lyrics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Dict, List, Optional

from spotdl.utils.formatter import ratio, slugify
from spotdl.utils.matching import based_sort

__all__ = ["LyricsProvider"]
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -93,7 +94,13 @@ def get_lyrics(self, name: str, artists: List[str], **kwargs) -> Optional[str]:

results_with_score = {}
for title, url in results.items():
score = ratio(slugify(title), slugify(f"{name} - {', '.join(artists)}"))
result_title = slugify(title)
match_title = slugify(f"{name} - {', '.join(artists)}")

res_list, song_list = based_sort(result_title.split("-"), match_title.split("-"))
result_title, match_title = "-".join(res_list), "-".join(song_list)

score = ratio(result_title, match_title)
results_with_score[score] = url

if not results_with_score:
Expand Down

0 comments on commit e4de031

Please sign in to comment.