Skip to content

Commit 20accf7

Browse files
authored
revert bea748b: revert to rapidfuzz (spotDL#1403)
thefuzz was giving a headache. Revert spotDL#1391 back to rapidfuzz.
1 parent 209dfde commit 20accf7

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ install_requires =
3131
spotipy >= 2.19.0
3232
pytube >= 11.0.0
3333
rich
34-
thefuzz
35-
thefuzz[speedup]
34+
rapidfuzz
3635
mutagen
3736
ytmusicapi
3837
yt-dlp

spotdl/providers/provider_utils.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from pathlib import Path
22
from typing import List
33

4-
from thefuzz import fuzz
4+
from rapidfuzz import fuzz
55

66

77
def _match_percentage(str1: str, str2: str, score_cutoff: float = 0) -> float:
88
"""
9-
A wrapper around `thefuzz.fuzz.partial_ratio` to handle UTF-8 encoded
9+
A wrapper around `rapidfuzz.fuzz.partial_ratio` to handle UTF-8 encoded
1010
emojis that usually cause errors
1111
1212
`str` `str1` : a random sentence
@@ -19,12 +19,7 @@ def _match_percentage(str1: str, str2: str, score_cutoff: float = 0) -> float:
1919

2020
# ! this will throw an error if either string contains a UTF-8 encoded emoji
2121
try:
22-
partial_ratio = fuzz.partial_ratio(str1, str2)
23-
24-
if partial_ratio < score_cutoff:
25-
return 0
26-
27-
return partial_ratio
22+
return fuzz.partial_ratio(str1, str2, score_cutoff=score_cutoff)
2823

2924
# ! we build new strings that contain only alphanumerical characters and spaces
3025
# ! and return the partial_ratio of that
@@ -41,12 +36,7 @@ def _match_percentage(str1: str, str2: str, score_cutoff: float = 0) -> float:
4136
if each_letter.isalnum() or each_letter.isspace()
4237
)
4338

44-
partial_ratio = fuzz.partial_ratio(new_str1, new_str2)
45-
46-
if partial_ratio < score_cutoff:
47-
return 0
48-
49-
return partial_ratio
39+
return fuzz.partial_ratio(new_str1, new_str2, score_cutoff=score_cutoff)
5040

5141

5242
def _parse_duration(duration: str) -> float:

0 commit comments

Comments
 (0)