remove karma endpoints from schema + add webhook notification for debugging (failed lyrics searches, non-LRC)

This commit is contained in:
codey 2025-05-01 06:32:28 -04:00
parent 8848d3a493
commit ad43db289a
6 changed files with 21 additions and 17 deletions

View File

@ -152,7 +152,7 @@ class Karma(FastAPI):
for endpoint, handler in self.endpoints.items():
app.add_api_route(
f"/{endpoint}", handler, methods=["POST"], include_in_schema=True
f"/{endpoint}", handler, methods=["POST"], include_in_schema=False
)
async def top_karma_handler(

View File

@ -168,6 +168,10 @@ class LyricSearch(FastAPI):
)
if not result:
if not data.lrc:
await self.notifier.send(
"DEBUG", f"Could not locate lyrics, request was:\n`{data}`"
)
return JSONResponse(
content={
"err": True,

View File

@ -149,15 +149,12 @@ class Radio(FastAPI):
"duration": item.get("duration"),
}
)
fallback_playlist_len: int = len(
orig_queue
) # Used if search term is provided
full_playlist_len: int = len(orig_queue)
filtered_len: int = len(queue_full)
out_json = {
"draw": data.draw,
"recordsTotal": (
len(queue_full) if not data.search else fallback_playlist_len
),
"recordsFiltered": (len(queue_full)),
"recordsTotal": full_playlist_len,
"recordsFiltered": filtered_len,
"items": queue_out,
}
return JSONResponse(content=out_json)

View File

@ -1,3 +1,4 @@
import logging
from typing import Optional
from openai import AsyncOpenAI
@ -13,6 +14,8 @@ class GPT:
self.default_system_prompt: str = """You are a helpful assistant who will provide only totally accurate tidbits of \
info on the specific songs the user may listen to."""
logging.getLogger("httpx").setLevel("CRITICAL")
async def get_completion(
self, prompt: str, system_prompt: Optional[str] = None
) -> Optional[str]:

View File

@ -103,7 +103,7 @@ class LRCLib:
best_match = self.matcher.find_best_match(
input_track, possible_matches
)[0]
except: # noqa
except: # noqa
pass
if not best_match:

View File

@ -332,13 +332,13 @@ class RadioUtil:
# GROUP BY artistdashsong ORDER BY RANDOM()'
"""
LIMITED GENRES
FULL
"""
# db_query: str = (
# 'SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))), (TRIM(artist) || " - " || TRIM(song))'
# "AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks"
# )
db_query: str = (
'SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))), (TRIM(artist) || " - " || TRIM(song))'
"AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks"
)
"""
LIMITED TO ONE/SMALL SUBSET OF GENRES
@ -351,8 +351,8 @@ class RadioUtil:
LIMITED TO ONE/SOME ARTISTS...
"""
db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks\
WHERE (artist LIKE "%chunk!%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(2022)%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()' # ORDER BY album ASC, id ASC'
# db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks\
# WHERE (artist LIKE "%sullivan king%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(2022)%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()' # ORDER BY album ASC, id ASC'
# db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\
# WHERE (artist LIKE "%sullivan king%" OR artist LIKE "%kayzo%" OR artist LIKE "%adventure club%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(2022)%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()'# ORDER BY album ASC, id ASC'