From 4ffdc887b6ff4393aeab0bb7a6fade8c44c4673a Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Thu, 19 Feb 2026 13:13:42 -0800 Subject: fix: edge case where id is None due to cached id not being set --- yt_radio.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/yt_radio.py b/yt_radio.py index da479a6..8978e08 100644 --- a/yt_radio.py +++ b/yt_radio.py @@ -91,6 +91,7 @@ def fetch_metadata(index, url): "title": cached.get("title", f"Track {index+1}"), "artist": cached.get("uploader", "Unknown"), "duration": cached.get("duration", -1), + "id": cached.get("id", ""), } return except Exception: @@ -151,10 +152,10 @@ def _stream_track(index): meta = METADATA.get(index, {"title": f"Track {index+1}", "artist": "Unknown", "duration": -1, "id": ""}) NOW_PLAYING["index"] = index - NOW_PLAYING["title"] = meta["title"] - NOW_PLAYING["artist"] = meta["artist"] - NOW_PLAYING["id"] = meta["id"] - logger.info("Now playing [%d/%d]: %s - %s", index + 1, len(PLAYLIST), meta["artist"], meta["title"]) + NOW_PLAYING["title"] = meta.get("title", "") + NOW_PLAYING["artist"] = meta.get("artist", "") + NOW_PLAYING["id"] = meta.get("id", "") + logger.info("Now playing [%d/%d]: %s - %s", index + 1, len(PLAYLIST), meta.get("artist", ""), meta.get("title", "")) ytdlp = subprocess.Popen( ["yt-dlp", "-f", "bestaudio", "-o", "-", url], -- cgit v1.2.3