aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-02-19 13:13:42 -0800
committerPinapelz <yukais@pinapelz.com>2026-02-19 13:13:42 -0800
commit4ffdc887b6ff4393aeab0bb7a6fade8c44c4673a (patch)
tree374919ae8bd57333d80582f51afae1622a8a4e0c
parent22bd86dff4371b6be3aa69901531e711f848fcf7 (diff)
fix: edge case where id is None due to cached id not being set
-rw-r--r--yt_radio.py9
1 files 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],
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage