aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-02-23 18:08:58 -0800
committerPinapelz <yukais@pinapelz.com>2026-02-23 18:08:58 -0800
commit1258bc106d0875fb545b5ea7b6cc513d44f04c2f (patch)
tree1997b7e070a1cd7625b49223e3ddddc02e238be0
parent7fd4a4412a2defcc393447a1dc0dddbc5ff63e68 (diff)
allow for a local .radio file to be used (newline seperated list of
urls)
-rw-r--r--yt_radio.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/yt_radio.py b/yt_radio.py
index 80b6178..145ad68 100644
--- a/yt_radio.py
+++ b/yt_radio.py
@@ -56,7 +56,34 @@ def _save_cache():
logger.exception("Failed to save cache to %s", CACHE_FILE)
+def load_urls_from_file(path: str):
+ urls = []
+ if not path:
+ logger.debug("No path provided to load_urls_from_file")
+ return urls
+ try:
+ with open(path, "r", encoding="utf-8") as f:
+ for raw in f:
+ line = raw.strip()
+ if not line:
+ continue
+ if line.startswith("#"):
+ continue
+ if " #" in line:
+ line = line.split(" #", 1)[0].strip()
+ urls.append(line)
+ logger.info("Loaded %d URLs from %s", len(urls), path)
+ except FileNotFoundError:
+ logger.warning("URL file not found: %s", path)
+ except Exception:
+ logger.exception("Failed to read URL file: %s", path)
+ return urls
+
+
def convert_playlist_to_links(link: str):
+ if link.endswith(".radio"):
+ logger.info(".radio file specified, loading from local file")
+ return load_urls_from_file(link)
ydl_opts = {
"quiet": True,
"extract_flat": True,
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage