aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-06-26 17:23:22 -0700
committerPinapelz <yukais@pinapelz.com>2026-06-26 17:52:22 -0700
commitcb6315b1cc7bc7ed936cdb7c70514013c2fdc159 (patch)
tree7868dd3cf88207eced6f5d9539f666dad0830930
parentf0d71ed632566ff8c9d12bf13029f67783f127e1 (diff)
fix: pass empty existing song list if output points to empty file
-rw-r--r--playlist_generator/playlist_generator.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/playlist_generator/playlist_generator.py b/playlist_generator/playlist_generator.py
index a02881a..0620c71 100644
--- a/playlist_generator/playlist_generator.py
+++ b/playlist_generator/playlist_generator.py
@@ -81,10 +81,16 @@ def main():
parser.add_argument("urls_file")
parser.add_argument("output_file", default="../server/data/songs.ts")
args = parser.parse_args()
- with open(args.output_file, "r", encoding="utf-8") as f:
- text = f.read()
- array_text = re.search(r"\[.*\]", text, re.S).group(0)
- songs = json5.loads(array_text)
+ songs = []
+ try:
+ with open(args.output_file, "r", encoding="utf-8") as f:
+ text = f.read()
+
+ if text.strip():
+ array_text = re.search(r"\[.*\]", text, re.S).group(0)
+ songs = json5.loads(array_text)
+ except (AttributeError, json5.JSON5DecodeError):
+ songs = []
generator = PlaylistGenerator(songs)
urls = generator.get_urls_from_file(args.urls_file)
video_info = generator.extract(urls)
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage