#!/usr/bin/env python3 """ Generate RSS feed for Public Affairs RAP (Revolutionary African Perspectives) shows """ from src.mixcloud_rss import MixcloudRSSGenerator import xml.etree.ElementTree as ET from datetime import datetime def generate_rap_feed(username="WRFG"): """Generate RSS feed filtered for RAP shows.""" # Create generator generator = MixcloudRSSGenerator() # Set up filters for "Public Affairs" in the title # This should catch variations like "afrikan" vs "african" filters = { 'keywords': 'public affairs' } # Generate feed with a higher limit to catch all shows print(f"Generating RSS feed for {username} filtered by 'Public Affairs' shows...") rss_feed = generator.generate_rss_from_username(username, limit=100, filters=filters) if rss_feed: # Save to file filename = f"{username}_public_affairs_rap.xml" with open(filename, 'w', encoding='utf-8') as f: f.write(rss_feed) print(f"āœ… RSS feed saved to: {filename}") # Also print the RSS URL for the web server print(f"\nšŸ“” RSS URL for web server:") print(f"http://localhost:5000/rss/{username}?limit=100&keywords=public%20affairs") # Parse and show episodes root = ET.fromstring(rss_feed) items = root.findall('.//item') print(f"\nšŸ“Š Found {len(items)} 'Public Affairs' episodes") # Show episode details if items: print("\nšŸ“… Public Affairs RAP episodes:") for item in items: title = item.find('title').text pub_date_str = item.find('pubDate').text link = item.find('link').text # Parse date for better display try: pub_date = datetime.strptime(pub_date_str, "%a, %d %b %Y %H:%M:%S %z") date_display = pub_date.strftime("%B %d, %Y") except: date_display = pub_date_str print(f"\n šŸ“» {title}") print(f" Date: {date_display}") print(f" URL: {link}") # Check if it's the July 21 show if "21 july" in title.lower() or "july 21" in title.lower(): print(f" ⭐ This is the July 21 show!") # Generate specific URL for your podcast system print(f"\nšŸŽÆ For your podcast processing system, use this RSS URL:") print(f"http://localhost:5000/rss/WRFG?limit=100&keywords=public%20affairs") else: print("āŒ Error: Could not generate RSS feed") if __name__ == "__main__": generate_rap_feed()