radio: move db query to constants (gitignored), bugfix: naas
This commit is contained in:
parent
457d72c934
commit
3476dc9e64
@ -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."
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user