bugfix: datatables search for radio queue was returning incorrect queue positions for items once a filter/query was provided (numbering/index was based on the filtered resultset)
This commit is contained in:
parent
2a49a92bb2
commit
8848d3a493
@ -128,9 +128,9 @@ class Radio(FastAPI):
|
|||||||
start: int = int(data.start)
|
start: int = int(data.start)
|
||||||
end: int = start + 20
|
end: int = start + 20
|
||||||
search: Optional[str] = data.search
|
search: Optional[str] = data.search
|
||||||
|
orig_queue: list[dict] = self.radio_util.active_playlist
|
||||||
if not search:
|
if not search:
|
||||||
queue_full: list = self.radio_util.active_playlist
|
queue_full: list = orig_queue
|
||||||
else:
|
else:
|
||||||
queue_full: list = self.radio_util.datatables_search(data.search)
|
queue_full: list = self.radio_util.datatables_search(data.search)
|
||||||
queue: list = queue_full[start:end]
|
queue: list = queue_full[start:end]
|
||||||
@ -138,7 +138,7 @@ class Radio(FastAPI):
|
|||||||
for x, item in enumerate(queue):
|
for x, item in enumerate(queue):
|
||||||
queue_out.append(
|
queue_out.append(
|
||||||
{
|
{
|
||||||
"pos": queue_full.index(item),
|
"pos": orig_queue.index(item),
|
||||||
"id": item.get("id"),
|
"id": item.get("id"),
|
||||||
"uuid": item.get("uuid"),
|
"uuid": item.get("uuid"),
|
||||||
"artist": item.get("artist"),
|
"artist": item.get("artist"),
|
||||||
@ -150,7 +150,7 @@ class Radio(FastAPI):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
fallback_playlist_len: int = len(
|
fallback_playlist_len: int = len(
|
||||||
self.radio_util.active_playlist
|
orig_queue
|
||||||
) # Used if search term is provided
|
) # Used if search term is provided
|
||||||
out_json = {
|
out_json = {
|
||||||
"draw": data.draw,
|
"draw": data.draw,
|
||||||
|
@ -50,12 +50,12 @@ class RadioUtil:
|
|||||||
"/usr/local/share", "sqlite_dbs", "track_album_art.db"
|
"/usr/local/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",
|
||||||
]
|
]
|
||||||
self.active_playlist: list[dict] = []
|
self.active_playlist: list[dict] = []
|
||||||
self.playlist_loaded: bool = False
|
self.playlist_loaded: bool = False
|
||||||
@ -118,7 +118,7 @@ class RadioUtil:
|
|||||||
filter (str): The filter query to fuzzy match with
|
filter (str): The filter query to fuzzy match with
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[str]: List of matching playlist items (if any are found)
|
list[dict]: List of matching playlist items (if any are found)
|
||||||
"""
|
"""
|
||||||
filter = filter.strip().lower()
|
filter = filter.strip().lower()
|
||||||
matched: list[dict] = []
|
matched: list[dict] = []
|
||||||
@ -335,10 +335,10 @@ class RadioUtil:
|
|||||||
LIMITED GENRES
|
LIMITED GENRES
|
||||||
"""
|
"""
|
||||||
|
|
||||||
db_query: str = (
|
# db_query: str = (
|
||||||
'SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))), (TRIM(artist) || " - " || TRIM(song))'
|
# 'SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))), (TRIM(artist) || " - " || TRIM(song))'
|
||||||
"AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks"
|
# "AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks"
|
||||||
)
|
# )
|
||||||
|
|
||||||
"""
|
"""
|
||||||
LIMITED TO ONE/SMALL SUBSET OF GENRES
|
LIMITED TO ONE/SMALL SUBSET OF GENRES
|
||||||
@ -351,8 +351,8 @@ class RadioUtil:
|
|||||||
LIMITED TO ONE/SOME ARTISTS...
|
LIMITED TO ONE/SOME ARTISTS...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks\
|
db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks\
|
||||||
# WHERE (artist LIKE "%outline in color%") 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'
|
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, genre, file_path, duration FROM tracks\
|
# 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'
|
# 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'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user