diff --git a/endpoints/radio.py b/endpoints/radio.py index 10f775c..29aed84 100644 --- a/endpoints/radio.py +++ b/endpoints/radio.py @@ -43,6 +43,7 @@ class Radio(FastAPI): self.now_playing = { 'artist': 'N/A', 'song': 'N/A', + 'genre': 'N/A', 'artistsong': 'N/A - N/A', 'duration': 0, 'start': 0, @@ -227,8 +228,18 @@ class Radio(FastAPI): try: logging.critical(f"Loading playlist...") self.active_playlist.clear() - db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, file_path, duration FROM tracks\ - GROUP BY artistdashsong ORDER BY RANDOM()' + # db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, genre, file_path, duration FROM tracks\ + # GROUP BY artistdashsong ORDER BY RANDOM()' + + """ + LIMITED GENRES + """ + + db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, genre, file_path, duration FROM tracks\ + WHERE genre IN ("hip hop", "metalcore", "pop punk", "punk rock", "metal", "punk", "electronic", "nu metal", "EDM",\ + "post-hardcore", "pop rock", "experimental", "post-punk", "death metal", "electronicore", "hard rock", "psychedelic rock",\ + "grunge", "house", "dubstep", "hardcore", "hair metal", "horror punk", "folk punk", "breakcore",\ + "post-rock", "deathcore", "hardcore punk", "synthwave", "trap") GROUP BY artistdashsong ORDER BY RANDOM()' async with sqlite3.connect(self.active_playlist_path, timeout=2) as db_conn: @@ -240,6 +251,7 @@ class Radio(FastAPI): 'id': r['id'], 'artist': double_space.sub(' ', r['artist']).strip(), 'song': double_space.sub(' ', r['song']).strip(), + 'genre': r['genre'] if r['genre'] else 'Unknown', 'artistsong': double_space.sub(' ', r['artistdashsong']).strip(), 'file_path': r['file_path'], 'duration': r['duration'], diff --git a/endpoints/radio_util.py b/endpoints/radio_util.py index 0998e6e..9417217 100644 --- a/endpoints/radio_util.py +++ b/endpoints/radio_util.py @@ -76,6 +76,11 @@ class RadioUtil: "value": self.duration_conv(track['duration']), "inline": True, }, + { + "name": "Genre", + "value": track['genre'] if track['genre'] else 'Unknown', + "inline": True, + }, { "name": "Filetype", "value": track['file_path'].rsplit(".", maxsplit=1)[1],