test for full path and only song name
This commit is contained in:
parent
1dfe60c01f
commit
ba1ec53753
1 changed files with 7 additions and 2 deletions
9
main.py
9
main.py
|
@ -21,10 +21,15 @@ def find_song(query, songs_dir):
|
|||
for file in files:
|
||||
if file.endswith(".mp3"):
|
||||
song_path = os.path.join(root, file)
|
||||
#song_name = os.path.relpath(song_path, start=songs_dir) # full path doesnt return good results
|
||||
song_name = os.path.splitext(file)[0]
|
||||
confidence = process.extractOne(query, [song_name.replace("_", " ")])[1]
|
||||
full_song_name = os.path.relpath(song_path, start=songs_dir)
|
||||
|
||||
confidence = process.extractOne(query, [song_name.replace("_", " ")])[1]
|
||||
if confidence > best_confidence:
|
||||
best_match = song_path
|
||||
best_confidence = confidence
|
||||
|
||||
confidence = process.extractOne(query, [full_song_name.replace("_", " ")])[1]
|
||||
if confidence > best_confidence:
|
||||
best_match = song_path
|
||||
best_confidence = confidence
|
||||
|
|
Loading…
Reference in a new issue