small optimization for filtering
This commit is contained in:
parent
f18a9da4a0
commit
5d2de1471f
@ -275,7 +275,9 @@ class RadioUtil:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
artist = artist.strip()
|
artist = artist.strip()
|
||||||
query: str = "SELECT genre FROM artist_genre WHERE artist LIKE ? COLLATE NOCASE"
|
query: str = (
|
||||||
|
"SELECT genre FROM artist_genre WHERE artist LIKE ? COLLATE NOCASE"
|
||||||
|
)
|
||||||
params: tuple[str] = (f"%%{artist}%%",)
|
params: tuple[str] = (f"%%{artist}%%",)
|
||||||
async with sqlite3.connect(self.artist_genre_db_path, timeout=2) as _db:
|
async with sqlite3.connect(self.artist_genre_db_path, timeout=2) as _db:
|
||||||
_db.row_factory = sqlite3.Row
|
_db.row_factory = sqlite3.Row
|
||||||
@ -360,12 +362,16 @@ class RadioUtil:
|
|||||||
if self.playback_genres:
|
if self.playback_genres:
|
||||||
new_playlist: list[dict] = []
|
new_playlist: list[dict] = []
|
||||||
logging.info("Limiting playback genres")
|
logging.info("Limiting playback genres")
|
||||||
for x, item in enumerate(self.active_playlist):
|
for item in self.active_playlist:
|
||||||
|
matched_genre: bool = False
|
||||||
item_genres: str = item.get("genre", "").strip().lower()
|
item_genres: str = item.get("genre", "").strip().lower()
|
||||||
for genre in self.playback_genres:
|
for genre in self.playback_genres:
|
||||||
genre = genre.strip().lower()
|
genre = genre.strip().lower()
|
||||||
if genre in item_genres:
|
if genre in item_genres:
|
||||||
new_playlist.append(item)
|
new_playlist.append(item)
|
||||||
|
matched_genre = True
|
||||||
|
continue
|
||||||
|
if matched_genre:
|
||||||
continue
|
continue
|
||||||
self.active_playlist = new_playlist
|
self.active_playlist = new_playlist
|
||||||
logging.info(
|
logging.info(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user