formatting/add meme endpoints

This commit is contained in:
2025-05-17 08:07:38 -04:00
parent d944a32c62
commit 2caa482a0d
10 changed files with 135 additions and 31 deletions

View File

@ -56,6 +56,7 @@ class RadioUtil:
"deathcore",
"edm",
"electronic",
"hard rock",
]
self.active_playlist: list[dict] = []
self.playlist_loaded: bool = False
@ -160,11 +161,9 @@ class RadioUtil:
if not artistsong and (not artist or not song):
raise RadioException("No query provided")
try:
search_query: str = (
'SELECT id, artist, song, (artist || " - " || song) AS artistsong, album, file_path, duration FROM tracks\
search_query: str = 'SELECT id, artist, song, (artist || " - " || song) AS artistsong, album, file_path, duration FROM tracks\
WHERE editdist3((lower(artist) || " " || lower(song)), (? || " " || ?))\
<= 410 ORDER BY editdist3((lower(artist) || " " || lower(song)), ?) ASC LIMIT 1'
)
if artistsong:
artistsong_split: list = artistsong.split(" - ", maxsplit=1)
(search_artist, search_song) = tuple(artistsong_split)
@ -256,9 +255,7 @@ class RadioUtil:
for pair in pairs:
try:
artist, genre = pair
query: str = (
"INSERT OR IGNORE INTO artist_genre (artist, genre) VALUES(?, ?)"
)
query: str = "INSERT OR IGNORE INTO artist_genre (artist, genre) VALUES(?, ?)"
params: tuple[str, str] = (artist, genre)
res = _db.execute(query, params)
if isinstance(res.lastrowid, int):
@ -376,7 +373,7 @@ class RadioUtil:
dedupe_processed.append(artistsongabc)
logging.info(
"Duplicates removed." "New playlist size: %s",
"Duplicates removed.New playlist size: %s",
len(self.active_playlist),
)