From ba1ec53753d1387c3be0dd0922ee97c8d9571f9d Mon Sep 17 00:00:00 2001 From: tavo-wasd Date: Sun, 31 Mar 2024 12:18:09 -0600 Subject: [PATCH] test for full path and only song name --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index f8f289d..baaa41e 100644 --- a/main.py +++ b/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] + 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