Add unified channel feed
This commit is contained in:
88
generate_feed_config_simple.py
Executable file
88
generate_feed_config_simple.py
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Generate feed-master configuration from channels.yml.
|
||||
Simplified version that doesn't require RSS-Bridge to be running.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from .channel_config import build_rss_bridge_url, load_channel_entries
|
||||
|
||||
|
||||
def generate_fm_config(channels_file, output_file, rss_bridge_host="rss-bridge"):
|
||||
"""Generate feed-master YAML configuration from channels.yml"""
|
||||
|
||||
print(f"Reading channels from {channels_file}")
|
||||
channels = load_channel_entries(Path(channels_file))
|
||||
print(f"Found {len(channels)} channels")
|
||||
|
||||
# Generate feed configuration
|
||||
config = []
|
||||
config.append("# Feed Master Configuration")
|
||||
config.append("# Auto-generated from channels.yml")
|
||||
config.append("# Do not edit manually - regenerate using generate_feed_config_simple.py")
|
||||
config.append("")
|
||||
config.append("feeds:")
|
||||
config.append(" youtube-unified:")
|
||||
config.append(" title: YouTube Unified Feed")
|
||||
config.append(" description: Aggregated feed from all YouTube channels")
|
||||
config.append(" link: https://youtube.com")
|
||||
config.append(' language: "en-us"')
|
||||
config.append(" sources:")
|
||||
|
||||
processed = 0
|
||||
skipped = 0
|
||||
|
||||
for channel in channels:
|
||||
if not channel.get("rss_enabled", True):
|
||||
skipped += 1
|
||||
continue
|
||||
bridge_url = build_rss_bridge_url(channel, rss_bridge_host=rss_bridge_host)
|
||||
if not bridge_url:
|
||||
skipped += 1
|
||||
continue
|
||||
name = channel.get("name", "Unknown")
|
||||
config.append(f" - name: {name}")
|
||||
config.append(f" url: {bridge_url}")
|
||||
processed += 1
|
||||
|
||||
# Add system configuration
|
||||
config.append("")
|
||||
config.append("system:")
|
||||
config.append(" update: 5m")
|
||||
config.append(" max_per_feed: 5")
|
||||
config.append(" max_total: 200")
|
||||
config.append(" max_keep: 1000")
|
||||
config.append(" base_url: http://localhost:8097")
|
||||
|
||||
# Write output
|
||||
print(f"\nProcessed {processed} channels, skipped {skipped}")
|
||||
|
||||
with open(output_file, 'w') as f:
|
||||
f.write('\n'.join(config))
|
||||
|
||||
print(f"Configuration written to {output_file}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Default paths
|
||||
script_dir = Path(__file__).parent
|
||||
channels_file = script_dir / "channels.yml"
|
||||
output_file = script_dir / "feed-master-config" / "fm.yml"
|
||||
|
||||
# Allow overriding via command line
|
||||
if len(sys.argv) > 1:
|
||||
channels_file = Path(sys.argv[1])
|
||||
if len(sys.argv) > 2:
|
||||
output_file = Path(sys.argv[2])
|
||||
|
||||
if not channels_file.exists():
|
||||
print(f"Error: {channels_file} not found", file=sys.stderr)
|
||||
print(f"\nUsage: {sys.argv[0]} [channels.yml] [output.yml]", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# Ensure output directory exists
|
||||
output_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
generate_fm_config(channels_file, output_file)
|
||||
Reference in New Issue
Block a user