diff --git a/endpoints/radio_util.py b/endpoints/radio_util.py index 1350bf9..170a876 100644 --- a/endpoints/radio_util.py +++ b/endpoints/radio_util.py @@ -21,7 +21,7 @@ class RadioUtil: def __init__(self, constants) -> None: self.constants = constants self.gpt = gpt.GPT(self.constants) - self.ls_uri: str = "http://10.10.10.101:29000" + self.ls_uri: str = self.constants.LS_URI self.sqlite_exts: list[str] = ['/home/singer/api/solibs/spellfix1.cpython-311-x86_64-linux-gnu.so'] self.active_playlist_path: Union[str, LiteralString] = os.path\ .join("/usr/local/share", @@ -146,7 +146,7 @@ class RadioUtil: """ db_query: str = """SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))), (TRIM(artist) || " - " || TRIM(song)) AS artistdashsong, id, artist, song, genre, file_path, duration FROM tracks\ - WHERE genre LIKE "%metalcore%"\ + WHERE (genre LIKE "%metalcore%"\ OR genre LIKE "%rock%"\ OR genre LIKE "%pop punk%"\ OR genre LIKE "%math rock%"\ @@ -178,15 +178,16 @@ class RadioUtil: OR genre LIKE "%synthwave%"\ OR genre LIKE "%trap%"\ OR genre LIKE "%indie pop%"\ - OR genre LIKE "untagged"\ - GROUP BY artistdashsong ORDER BY RANDOM()""" + OR genre LIKE "%dnb%"\ + OR genre LIKE "untagged")\ + GROUP BY artistdashsong ORDER BY RANDOM()""" """ LIMITED TO ONE ARTIST... """ # db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, genre, file_path, duration FROM tracks\ - # WHERE artist LIKE "%bad omens%" GROUP BY artistdashsong ORDER BY RANDOM()' + # WHERE artist LIKE "%wage war%" GROUP BY artistdashsong ORDER BY id DESC' async with sqlite3.connect(self.active_playlist_path, timeout=2) as db_conn: diff --git a/endpoints/transcriptions.py b/endpoints/transcriptions.py index ca86fb6..c272d12 100644 --- a/endpoints/transcriptions.py +++ b/endpoints/transcriptions.py @@ -34,7 +34,7 @@ class Transcriptions(FastAPI): db_query: Optional[str] = None show_title: Optional[str] = None - if not show_id: + if not isinstance(show_id, int): return JSONResponse(status_code=500, content={ 'err': True, 'errorText': 'Invalid request', diff --git a/lyric_search/sources/cache.py b/lyric_search/sources/cache.py index e716d88..c210e0f 100644 --- a/lyric_search/sources/cache.py +++ b/lyric_search/sources/cache.py @@ -257,7 +257,7 @@ class Cache: matched = self.get_matched(redis_results=redis_result, matched_candidate=candidate, confidence=confidence) - if matched: + if matched and confidence >= 90: time_end: float = time.time() time_diff: float = time_end - time_start matched.confidence = confidence @@ -295,7 +295,7 @@ class Cache: candidate_tracks=result_tracks) else: best_match = (result_tracks[0], 100) - if not best_match: + if not best_match or confidence < 90: return None (candidate, confidence) = best_match logging.info("Result found on %s", self.label) diff --git a/lyric_search/utils.py b/lyric_search/utils.py index 291358f..b63f06a 100644 --- a/lyric_search/utils.py +++ b/lyric_search/utils.py @@ -41,6 +41,8 @@ class TrackMatcher: for candidate in candidate_tracks: normalized_candidate = self._normalize_string(candidate[1]) + if normalized_candidate.strip().lower() == input_track.strip().lower(): + return (candidate, 100.0) # Calculate various similarity scores exact_score = 1.0 if input_track == normalized_candidate else 0.0