Flask + React web UI with audio player, podcast queue, feed management, episode browser, music library, schedule viewer, and log tail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Manually enqueue a local audio file for immediate playback.
|
|
|
|
Usage:
|
|
enqueue_episode.py /path/to/episode.mp3
|
|
enqueue_episode.py /path/to/episode.mp3 "Episode Title"
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(os.environ.get("LOCALRADIO_BASE", "/opt/localradio"))
|
|
QUEUE_DIR = BASE_DIR / "state" / "queue"
|
|
|
|
|
|
def enqueue(file_path: str, label: str | None = None) -> None:
|
|
src = Path(file_path).resolve()
|
|
if not src.exists():
|
|
print(f"Error: file not found: {src}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
if not src.suffix.lower() in (".mp3", ".ogg", ".opus", ".flac", ".m4a", ".wav"):
|
|
print(f"Warning: '{src.suffix}' may not be a supported audio format")
|
|
|
|
QUEUE_DIR.mkdir(parents=True, exist_ok=True)
|
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
safe_name = src.name.replace(" ", "_")
|
|
link_name = f"{timestamp}_manual_{safe_name}"
|
|
link_path = QUEUE_DIR / link_name
|
|
|
|
link_path.symlink_to(src)
|
|
print(f"Enqueued: {link_name}")
|
|
if label:
|
|
print(f" Label: {label}")
|
|
print(f" Target: {src}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print(f"Usage: {sys.argv[0]} <audio-file> [title]", file=sys.stderr)
|
|
sys.exit(1)
|
|
title = sys.argv[2] if len(sys.argv) > 2 else None
|
|
enqueue(sys.argv[1], title)
|