From 0fe081597e7bd1662cc133d39c9567aef0ac86d8 Mon Sep 17 00:00:00 2001 From: codey Date: Sun, 22 Jun 2025 07:54:32 -0400 Subject: [PATCH] base: add allowed CORS origins for localhost:4321 (dev purposes); lyric_search: change typeahead to return a maximum of 10 results, prev. 100 --- base.py | 2 +- endpoints/lyric_search.py | 4 ++-- utils/radio_util.py | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/base.py b/base.py index 865a130..c8c6dbc 100644 --- a/base.py +++ b/base.py @@ -26,7 +26,7 @@ app = FastAPI( constants = importlib.import_module("constants").Constants() util = importlib.import_module("util").Utilities(app, constants) -origins = ["https://codey.lol", "https://api.codey.lol"] +origins = ["https://codey.lol", "https://old.codey.lol", "https://api.codey.lol", "https://_new.codey.lol", "http://localhost:4321"] app.add_middleware( CORSMiddleware, # type: ignore diff --git a/endpoints/lyric_search.py b/endpoints/lyric_search.py index 003a51f..8f6bb39 100644 --- a/endpoints/lyric_search.py +++ b/endpoints/lyric_search.py @@ -31,7 +31,7 @@ class CacheUtils: _db.row_factory = sqlite3.Row db_query: str = """SELECT DISTINCT(LOWER(TRIM(artist) || " - " || TRIM(song))),\ (TRIM(artist) || " - " || TRIM(song)) as ret FROM lyrics WHERE\ - ret LIKE ? LIMIT 100""" + ret LIKE ? LIMIT 10""" db_params: tuple[str] = (f"%%%{query}%%%",) async with _db.execute(db_query, db_params) as _cursor: result: Iterable[sqlite3.Row] = await _cursor.fetchall() @@ -175,7 +175,7 @@ class LyricSearch(FastAPI): return JSONResponse( content={ "err": True, - "errorText": "Sources exhausted, lyrics not located.", + "errorText": "Failed to locate lyrics on any available sources.", } ) diff --git a/utils/radio_util.py b/utils/radio_util.py index 3d557b5..dfb64ab 100644 --- a/utils/radio_util.py +++ b/utils/radio_util.py @@ -50,18 +50,19 @@ class RadioUtil: "/usr/local/share", "sqlite_dbs", "track_album_art.db" ) self.playback_genres: list[str] = [ - # "post-hardcore", - # "post hardcore", + "post-hardcore", + "post hardcore", "metalcore", "deathcore", - # "edm", - # "electronic", - # "hard rock", - # "ska", - # "post punk", - # "post-punk", - # "pop punk", - # "pop-punk", + "edm", + "electronic", + "hard rock", + "rock", + "ska", + "post punk", + "post-punk", + "pop punk", + "pop-punk", ] self.active_playlist: list[dict] = [] self.playlist_loaded: bool = False