diff --git a/.gitignore b/.gitignore index 4005bca..658edd2 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ up.py job_review.py check_missing.py **/auth/* +**/radio_api/* test/db_stats.py test/report/* .gitignore diff --git a/endpoints/radio.py b/endpoints/radio.py index 2fe91d1..de6d9e2 100644 --- a/endpoints/radio.py +++ b/endpoints/radio.py @@ -434,7 +434,7 @@ class Radio(FastAPI): next["end"] = time_ends # Use BackgroundTasks for LRC fetch/cache - background_tasks.add_task(self._do_lrc_fetch, data.station, next.copy()) + asyncio.create_task(self._do_lrc_fetch(data.station, next.copy())) try: background_tasks.add_task(self.radio_util.webhook_song_change, next, data.station) diff --git a/utils/jwt_utils.py b/utils/jwt_utils.py new file mode 100644 index 0000000..f1dce97 --- /dev/null +++ b/utils/jwt_utils.py @@ -0,0 +1,19 @@ +from jose import jwt, JWTError +from ..auth.key_store import get_key_by_kid + +JWT_ALGORITHM = "HS256" + + +def decode_jwt(token: str) -> dict | None: + """Decode a JWT token using the existing key management system.""" + try: + headers = jwt.get_unverified_header(token) + kid = headers.get("kid") + if not kid: + return None + key = get_key_by_kid(kid) + if not key: + return None + return jwt.decode(token, key, algorithms=[JWT_ALGORITHM]) + except JWTError: + return None \ No newline at end of file diff --git a/utils/radio_util.py b/utils/radio_util.py index 336d7fd..5913898 100644 --- a/utils/radio_util.py +++ b/utils/radio_util.py @@ -504,7 +504,7 @@ class RadioUtil: track_id, ) tagger = music_tag.load_file(file_path) - album_art = tagger["artwork"].first.data + album_art = tagger["artwork"].first.data if tagger else None with sqlite3.connect(self.album_art_db_path, timeout=2) as db_conn: db_cursor = db_conn.execute( "INSERT OR IGNORE INTO album_art (track_id, album_art) VALUES(?, ?)",