This commit is contained in:
codey 2025-05-27 16:48:28 -04:00
parent e07a9dd7d2
commit 68408c4796
8 changed files with 34 additions and 27 deletions

View File

@ -20,7 +20,7 @@ class CacheUtils:
def __init__(self) -> None: def __init__(self) -> None:
self.lyrics_db_path: LiteralString = os.path.join( self.lyrics_db_path: LiteralString = os.path.join(
"/usr/local/share", "sqlite_dbs", "cached_lyrics.db" "/mnt/data/share", "sqlite_dbs", "cached_lyrics.db"
) )
async def check_typeahead(self, query: str) -> Optional[list[str]]: async def check_typeahead(self, query: str) -> Optional[list[str]]:

View File

@ -25,7 +25,7 @@ class Misc(FastAPI):
self.radio = radio self.radio = radio
self.activity_image: Optional[bytes] = None self.activity_image: Optional[bytes] = None
self.nos_json_path: str = os.path.join( self.nos_json_path: str = os.path.join(
"/", "usr", "local", "share", "naas", "reasons.json" "/", "mnt", "data", "share", "naas", "reasons.json"
) )
self.nos: list[str] = [] self.nos: list[str] = []
self.last_5_nos: list[str] = [] self.last_5_nos: list[str] = []

View File

@ -122,14 +122,21 @@ class Radio(FastAPI):
async def radio_get_queue( async def radio_get_queue(
self, self,
request: Request, request: Request,
data: ValidRadioQueueRequest, data: Optional[ValidRadioQueueRequest] = None,
) -> JSONResponse: ) -> JSONResponse:
""" """
Get current play queue (paged, 20 results per page) Get current play queue (paged, 20 results per page)
""" """
search: Optional[str] = None
draw: int = 0
if isinstance(data, ValidRadioQueueRequest):
search = data.search
draw = data.draw
start: int = int(data.start) start: int = int(data.start)
end: int = start + 20 end: int = start + 20
search: Optional[str] = data.search else:
start: int = 0
end: int = 20
orig_queue: list[dict] = self.radio_util.active_playlist orig_queue: list[dict] = self.radio_util.active_playlist
if not search: if not search:
queue_full: list = orig_queue queue_full: list = orig_queue
@ -154,7 +161,7 @@ class Radio(FastAPI):
full_playlist_len: int = len(orig_queue) full_playlist_len: int = len(orig_queue)
filtered_len: int = len(queue_full) filtered_len: int = len(queue_full)
out_json = { out_json = {
"draw": data.draw, "draw": draw,
"recordsTotal": full_playlist_len, "recordsTotal": full_playlist_len,
"recordsFiltered": filtered_len, "recordsFiltered": filtered_len,
"items": queue_out, "items": queue_out,

View File

@ -41,7 +41,7 @@ class RandMsg(FastAPI):
match db_rand_selected: match db_rand_selected:
case 0: case 0:
randmsg_db_path: Union[str, LiteralString] = os.path.join( randmsg_db_path: Union[str, LiteralString] = os.path.join(
"/usr/local/share", "sqlite_dbs", "qajoke.db" "/mnt/data/share", "sqlite_dbs", "qajoke.db"
) # For qajoke db ) # For qajoke db
db_query: str = ( db_query: str = (
"SELECT id, ('<b>Q:</b> ' || question || '<br/><b>A:</b> ' \ "SELECT id, ('<b>Q:</b> ' || question || '<br/><b>A:</b> ' \
@ -50,7 +50,7 @@ class RandMsg(FastAPI):
title_attr = "QA Joke DB" title_attr = "QA Joke DB"
case 1 | 9: case 1 | 9:
randmsg_db_path = os.path.join( randmsg_db_path = os.path.join(
"/usr/local/share", "sqlite_dbs", "randmsg.db" "/mnt/data/share", "sqlite_dbs", "randmsg.db"
) # For randmsg db ) # For randmsg db
db_query = "SELECT id, msg FROM msgs WHERE \ db_query = "SELECT id, msg FROM msgs WHERE \
LENGTH(msg) <= 180 ORDER BY RANDOM() LIMIT 1" # For randmsg db LENGTH(msg) <= 180 ORDER BY RANDOM() LIMIT 1" # For randmsg db
@ -59,28 +59,28 @@ class RandMsg(FastAPI):
title_attr = "Random Msg DB" title_attr = "Random Msg DB"
case 2: case 2:
randmsg_db_path = os.path.join( randmsg_db_path = os.path.join(
"/usr/local/share", "sqlite_dbs", "trump.db" "/mnt/data/share", "sqlite_dbs", "trump.db"
) # For Trump Tweet DB ) # For Trump Tweet DB
db_query = "SELECT id, content FROM tweets \ db_query = "SELECT id, content FROM tweets \
ORDER BY RANDOM() LIMIT 1" # For Trump Tweet DB ORDER BY RANDOM() LIMIT 1" # For Trump Tweet DB
title_attr = "Trump Tweet DB" title_attr = "Trump Tweet DB"
case 3: case 3:
randmsg_db_path = os.path.join( randmsg_db_path = os.path.join(
"/usr/local/share", "sqlite_dbs", "philo.db" "/mnt/data/share", "sqlite_dbs", "philo.db"
) # For Philo DB ) # For Philo DB
db_query = "SELECT id, (content || '<br> - ' || speaker) FROM quotes \ db_query = "SELECT id, (content || '<br> - ' || speaker) FROM quotes \
ORDER BY RANDOM() LIMIT 1" # For Philo DB ORDER BY RANDOM() LIMIT 1" # For Philo DB
title_attr = "Philosophical Quotes DB" title_attr = "Philosophical Quotes DB"
case 4: case 4:
randmsg_db_path = os.path.join( randmsg_db_path = os.path.join(
"/usr/local/share", "sqlite_dbs", "hate.db" "/mnt/data/share", "sqlite_dbs", "hate.db"
) # For Hate DB ) # For Hate DB
db_query = """SELECT id, ("<font color='#FF0000'>" || comment) FROM hate_speech \ db_query = """SELECT id, ("<font color='#FF0000'>" || comment) FROM hate_speech \
WHERE length(comment) <= 180 ORDER BY RANDOM() LIMIT 1""" WHERE length(comment) <= 180 ORDER BY RANDOM() LIMIT 1"""
title_attr = "Hate Speech DB" title_attr = "Hate Speech DB"
case 5: case 5:
randmsg_db_path = os.path.join( randmsg_db_path = os.path.join(
"/usr/local/share", "sqlite_dbs", "rjokes.db" "/mnt/data/share", "sqlite_dbs", "rjokes.db"
) # r/jokes DB ) # r/jokes DB
db_query = """SELECT id, (title || "<br>" || body) FROM jokes \ db_query = """SELECT id, (title || "<br>" || body) FROM jokes \
WHERE score >= 10000 ORDER BY RANDOM() LIMIT 1""" WHERE score >= 10000 ORDER BY RANDOM() LIMIT 1"""

View File

@ -61,15 +61,15 @@ class Transcriptions(FastAPI):
match show_id: match show_id:
case 0: case 0:
db_path = os.path.join("/usr/local/share", "sqlite_dbs", "sp.db") db_path = os.path.join("/mnt/data/share", "sqlite_dbs", "sp.db")
db_query = """SELECT DISTINCT(("S" || Season || "E" || Episode || " " || Title)), ID FROM SP_DAT ORDER BY Season, Episode""" db_query = """SELECT DISTINCT(("S" || Season || "E" || Episode || " " || Title)), ID FROM SP_DAT ORDER BY Season, Episode"""
show_title = "South Park" show_title = "South Park"
case 1: case 1:
db_path = os.path.join("/usr/local/share", "sqlite_dbs", "futur.db") db_path = os.path.join("/mnt/data/share", "sqlite_dbs", "futur.db")
db_query = """SELECT DISTINCT(("S" || EP_S || "E" || EP_EP || " " || EP_TITLE)), EP_ID FROM clean_dialog ORDER BY EP_S, EP_EP""" db_query = """SELECT DISTINCT(("S" || EP_S || "E" || EP_EP || " " || EP_TITLE)), EP_ID FROM clean_dialog ORDER BY EP_S, EP_EP"""
show_title = "Futurama" show_title = "Futurama"
case 2: case 2:
db_path = os.path.join("/usr/local/share", "sqlite_dbs", "parks.db") db_path = os.path.join("/mnt/data/share", "sqlite_dbs", "parks.db")
db_query = """SELECT DISTINCT(("S" || EP_S || "E" || EP_EP || " " || EP_TITLE)), EP_ID FROM clean_dialog ORDER BY EP_S, EP_EP""" db_query = """SELECT DISTINCT(("S" || EP_S || "E" || EP_EP || " " || EP_TITLE)), EP_ID FROM clean_dialog ORDER BY EP_S, EP_EP"""
show_title = "Parks And Rec" show_title = "Parks And Rec"
case _: case _:
@ -111,14 +111,14 @@ class Transcriptions(FastAPI):
match show_id: match show_id:
case 0: case 0:
db_path: Union[str, LiteralString] = os.path.join( db_path: Union[str, LiteralString] = os.path.join(
"/usr/local/share", "sqlite_dbs", "sp.db" "/mnt/data/share", "sqlite_dbs", "sp.db"
) )
db_query: str = """SELECT ("S" || Season || "E" || Episode || " " || Title), Character, Line FROM SP_DAT WHERE ID = ?""" db_query: str = """SELECT ("S" || Season || "E" || Episode || " " || Title), Character, Line FROM SP_DAT WHERE ID = ?"""
case 1: case 1:
db_path = os.path.join("/usr/local/share", "sqlite_dbs", "futur.db") db_path = os.path.join("/mnt/data/share", "sqlite_dbs", "futur.db")
db_query = """SELECT ("S" || EP_S || "E" || EP_EP || " " || EP_TITLE || "<br><em>Opener: " || EP_OPENER || "</em>"), EP_LINE_SPEAKER, EP_LINE FROM clean_dialog WHERE EP_ID = ? ORDER BY LINE_ID ASC""" db_query = """SELECT ("S" || EP_S || "E" || EP_EP || " " || EP_TITLE || "<br><em>Opener: " || EP_OPENER || "</em>"), EP_LINE_SPEAKER, EP_LINE FROM clean_dialog WHERE EP_ID = ? ORDER BY LINE_ID ASC"""
case 2: case 2:
db_path = os.path.join("/usr/local/share", "sqlite_dbs", "parks.db") db_path = os.path.join("/mnt/data/share", "sqlite_dbs", "parks.db")
db_query = """SELECT ("S" || EP_S || "E" || EP_EP || " " || EP_TITLE), EP_LINE_SPEAKER, EP_LINE FROM clean_dialog WHERE EP_ID = ? ORDER BY id ASC""" db_query = """SELECT ("S" || EP_S || "E" || EP_EP || " " || EP_TITLE), EP_LINE_SPEAKER, EP_LINE FROM clean_dialog WHERE EP_ID = ? ORDER BY id ASC"""
case _: case _:

View File

@ -22,7 +22,7 @@ class Cache:
def __init__(self) -> None: def __init__(self) -> None:
self.cache_db: Union[str, LiteralString] = os.path.join( self.cache_db: Union[str, LiteralString] = os.path.join(
"/", "usr", "local", "share", "sqlite_dbs", "cached_lyrics.db" "/mnt/data/share", "sqlite_dbs", "cached_lyrics.db"
) )
self.redis_cache = redis_cache.RedisCache() self.redis_cache = redis_cache.RedisCache()
self.notifier = notifier.DiscordNotifier() self.notifier = notifier.DiscordNotifier()
@ -32,7 +32,7 @@ class Cache:
pragma temp_store = memory; pragma mmap_size = 30000000000;" pragma temp_store = memory; pragma mmap_size = 30000000000;"
) )
self.sqlite_exts: list[str] = [ self.sqlite_exts: list[str] = [
"/home/api/api/solibs/spellfix1.cpython-311-x86_64-linux-gnu.so" "/home/kyle/api/solibs/spellfix1.cpython-311-x86_64-linux-gnu.so"
] ]
self.label: str = "Cache" self.label: str = "Cache"

View File

@ -14,7 +14,7 @@ class MemeUtil:
def __init__(self, constants) -> None: def __init__(self, constants) -> None:
self.constants = constants self.constants = constants
self.meme_db_path = os.path.join("/usr/local/share", "sqlite_dbs", "meme.db") self.meme_db_path = os.path.join("/mnt/data/share", "sqlite_dbs", "meme.db")
def is_png(self, buffer: bytes | io.BytesIO) -> bool: def is_png(self, buffer: bytes | io.BytesIO) -> bool:
""" """

View File

@ -38,22 +38,22 @@ class RadioUtil:
self.gpt = gpt.GPT(self.constants) self.gpt = gpt.GPT(self.constants)
self.ls_uri: str = self.constants.LS_URI self.ls_uri: str = self.constants.LS_URI
self.sqlite_exts: list[str] = [ self.sqlite_exts: list[str] = [
"/home/api/api/solibs/spellfix1.cpython-311-x86_64-linux-gnu.so" "/home/kyle/api/solibs/spellfix1.cpython-311-x86_64-linux-gnu.so"
] ]
self.active_playlist_path: str = os.path.join( self.active_playlist_path: str = os.path.join(
"/usr/local/share", "sqlite_dbs", "track_file_map.db" "/mnt/data/share", "sqlite_dbs", "track_file_map.db"
) )
self.artist_genre_db_path: str = os.path.join( self.artist_genre_db_path: str = os.path.join(
"/usr/local/share", "sqlite_dbs", "artist_genre_map.db" "/mnt/data/share", "sqlite_dbs", "artist_genre_map.db"
) )
self.album_art_db_path: str = os.path.join( self.album_art_db_path: str = os.path.join(
"/usr/local/share", "sqlite_dbs", "track_album_art.db" "/mnt/data/share", "sqlite_dbs", "track_album_art.db"
) )
self.playback_genres: list[str] = [ self.playback_genres: list[str] = [
# "post-hardcore", # "post-hardcore",
# "post hardcore", # "post hardcore",
# "metalcore", # "metalcore",
"deathcore", # "deathcore",
# "edm", # "edm",
# "electronic", # "electronic",
# "hard rock", # "hard rock",