From 01682c62c2c9ea2f7f498544ee3aaa299c0c2423 Mon Sep 17 00:00:00 2001 From: Caine Date: Sat, 7 Mar 2026 12:52:55 +0000 Subject: Initial commit: Radio Susan scripts, configs, and SFX --- generate_tonight.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 generate_tonight.py (limited to 'generate_tonight.py') diff --git a/generate_tonight.py b/generate_tonight.py new file mode 100755 index 0000000..b457f90 --- /dev/null +++ b/generate_tonight.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +"""One-off: generate playlist for remaining hours tonight. +Unlike the full generator, this resets start_time to 0 so Liquidsoap +plays from the top immediately instead of seeking to a time offset.""" +import sys, time, json, os +sys.path.insert(0, os.path.dirname(__file__)) +from generate_daily_playlist import build_playlist, write_outputs + +playlist = build_playlist() +if not playlist: + sys.exit(1) + +now_secs = time.localtime().tm_hour * 3600 + time.localtime().tm_min * 60 +entries = [e for e in playlist["entries"] if e["start_time"] >= now_secs] + +# Rebase start times to 0 so the playlist plays sequentially from the top +offset = entries[0]["start_time"] if entries else 0 +for e in entries: + e["start_time"] = round(e["start_time"] - offset, 1) + h = int(e["start_time"] // 3600) + m = int((e["start_time"] % 3600) // 60) + s = int(e["start_time"] % 60) + e["start_formatted"] = f"{h:02d}:{m:02d}:{s:02d}" + +playlist["entries"] = entries +playlist["total_tracks"] = sum(1 for e in entries if e["type"] == "track") +playlist["total_entries"] = len(entries) + +write_outputs(playlist) + +ann_count = sum(1 for e in entries if e["type"] == "announcement") +jingle_count = sum(1 for e in entries if e["type"] == "jingle") +print(f"Tonight: {playlist['total_tracks']} tracks, {ann_count} announcements, {jingle_count} jingles from {now_secs/3600:.1f}h onwards") -- cgit v1.2.3