whoopsies

This commit is contained in:
codey 2025-02-15 21:18:20 -05:00
parent 39d1ddaffa
commit e82ca841a8
3 changed files with 6 additions and 6 deletions

View File

@ -106,7 +106,7 @@ class LyricSearch(FastAPI):
pre_query: str = data.pre_query
query: str = data.query
typeahead_result: list[dict] = await self.cache_utils.check_typeahead(query, pre_query)
typeahead_list: list[str] = [str(r.get('song')) for r in typeahead_result]
typeahead_list: list[str] = [str(r['song']) for r in typeahead_result]
return JSONResponse(content=typeahead_list)
async def lyric_search_handler(self, data: ValidLyricRequest) -> JSONResponse:

View File

@ -6,7 +6,7 @@ import time
sys.path.insert(1,'..')
import traceback
import logging
from typing import Optional
from typing import Optional, Union
from aiohttp import ClientTimeout, ClientSession
from lyric_search import utils
from lyric_search.constructors import LyricsResult
@ -69,8 +69,8 @@ class LRCLib:
if len(text) < 100:
raise InvalidResponseException("Search response text was invalid (len < 100 chars.)")
search_data: Optional[dict] = await request.json()
if not isinstance(search_data, dict):
search_data: Optional[Union[list, dict]] = await request.json()
if not isinstance(search_data, list|dict):
raise InvalidResponseException("No JSON search data.")
# logging.info("Search Data:\n%s", search_data)

View File

@ -57,7 +57,7 @@ class TrackMatcher:
best_match = candidate
# Return the match only if it meets the threshold
if best_score >= self.threshold:
if best_score < self.threshold:
return None
match: tuple = (best_match, round(best_score * 100))
return match
@ -106,7 +106,7 @@ class DataUtils:
self.lrc_regex = regex.compile(r'\[([0-9]{2}:[0-9]{2})\.[0-9]{1,3}\](\s(.*)){0,}')
self.scrub_regex_1: Pattern = regex.compile(r'(\[.*?\])(\s){0,}(\:){0,1}')
self.scrub_regex_2: Pattern = regex.compile(r'(\d?)(Embed\b)',
flags=regex.IGNORECASe)
flags=regex.IGNORECASE)
self.scrub_regex_3: Pattern = regex.compile(r'\n{2}')
self.scrub_regex_4: Pattern = regex.compile(r'[0-9]\b$')