This commit is contained in:
2025-07-15 11:39:12 -04:00
parent c75abdfab2
commit a1f82036ff
6 changed files with 38 additions and 29 deletions

View File

@ -50,19 +50,19 @@ class RadioUtil:
"/usr/local/share", "sqlite_dbs", "track_album_art.db"
)
self.playback_genres: list[str] = [
"post-hardcore",
"post hardcore",
"metalcore",
"deathcore",
"edm",
"electronic",
# "metal",
# # "hip hop",
# "metalcore",
# "deathcore",
# # "edm",
# "electronic",
# "hard rock",
# "rock",
# "ska",
# "post punk",
# "post-punk",
# "pop punk",
# "pop-punk",
# # "ska",
# # "post punk",
# # "post-punk",
# # "pop punk",
# # "pop-punk",
]
self.active_playlist: list[dict] = []
self.playlist_loaded: bool = False
@ -321,7 +321,7 @@ class RadioUtil:
if not res:
artist_genre[artist] = "N/A"
continue
artist_genre[artist] = res["genre"]
artist_genre[artist] = res["genre"].title()
time_end: float = time.time()
logging.info(f"Time taken: {time_end - time_start}")
return artist_genre
@ -377,7 +377,7 @@ class RadioUtil:
"artist": double_space.sub(" ", r["artist"]).strip(),
"song": double_space.sub(" ", r["song"]).strip(),
"album": double_space.sub(" ", r["album"]).strip(),
"genre": r["genre"],
"genre": r["genre"].title() if r["genre"] else "Not Found",
"artistsong": double_space.sub(
" ", r["artistdashsong"]
).strip(),
@ -419,19 +419,25 @@ class RadioUtil:
if self.playback_genres:
new_playlist: list[dict] = []
logging.info("Limiting playback genres")
# for item in self.active_playlist:
# matched_genre: bool = False
# item_genres: str = item.get("genre", "").strip().lower()
# for genre in self.playback_genres:
# genre = genre.strip().lower()
# if genre in item_genres:
# if item in new_playlist:
# continue
# new_playlist.append(item)
# matched_genre = True
# continue
# if matched_genre:
# continue
for item in self.active_playlist:
matched_genre: bool = False
item_genres: str = item.get("genre", "").strip().lower()
for genre in self.playback_genres:
genre = genre.strip().lower()
if genre in item_genres:
if item in new_playlist:
continue
item_genres = item.get("genre", "").strip().lower()
# Check if any genre matches and item isn't already in new_playlist
if any(genre.strip().lower() in item_genres for genre in self.playback_genres):
if item not in new_playlist:
new_playlist.append(item)
matched_genre = True
continue
if matched_genre:
continue
self.active_playlist = new_playlist
logging.info(
"%s items remain for playback after filtering",