diff --git a/endpoints/misc.py b/endpoints/misc.py index 6546bcc..5083e09 100644 --- a/endpoints/misc.py +++ b/endpoints/misc.py @@ -49,7 +49,7 @@ class Misc(FastAPI): logging.debug("Loading NaaS reasons") - with open(self.nos_json_path, "r") as f: + with open(self.nos_json_path, "r", encoding="utf-8") as f: self.nos = json.loads(f.read()) logging.debug("Loaded %s reasons", len(self.nos)) @@ -62,7 +62,7 @@ class Misc(FastAPI): self.last_5_nos.append(no) if len(self.last_5_nos) >= 5: self.last_5_nos.pop(0) - return no + return json.dumps(no) except Exception as e: logging.debug("Exception: %s", str(e)) return "No." diff --git a/utils/radio_util.py b/utils/radio_util.py index 6b71268..68c0b89 100644 --- a/utils/radio_util.py +++ b/utils/radio_util.py @@ -328,37 +328,8 @@ class RadioUtil: try: logging.info("Loading playlist...") self.active_playlist.clear() - # db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\ - # GROUP BY artistdashsong ORDER BY RANDOM()' - """ - 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" - ) - - """ - LIMITED TO ONE/SMALL SUBSET OF GENRES - """ - - # db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\ - # WHERE (artist LIKE "%winds of plague%" OR artist LIKE "%acacia st%" OR artist LIKE "%suicide si%" OR artist LIKE "%in dying%") AND (NOT song LIKE "%(live%") ORDER BY RANDOM()' #ORDER BY artist DESC, album ASC, song ASC' - - """ - 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 "%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' - - # db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\ - # WHERE (artist LIKE "%akira the don%") 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: str = self.constants.RADIO_DB_QUERY with sqlite3.connect( f"file:{self.active_playlist_path}?mode=ro", uri=True, timeout=15