mixcloud-rss-generator/generate_rap_precise_feed.py

90 lines
3.8 KiB
Python

#!/usr/bin/env python3
"""
Generate RSS feed for ONLY the Revolutionary African/Afrikan Perspectives shows
Using multiple keywords to be more precise
"""
from src.mixcloud_rss import MixcloudRSSGenerator
import xml.etree.ElementTree as ET
from datetime import datetime
def generate_rap_precise_feed(username="WRFG"):
"""Generate RSS feed filtered for ONLY Revolutionary African/Afrikan Perspectives shows."""
# Create generator
generator = MixcloudRSSGenerator()
# Set up filters - use "revolutionary" as it's unique to these shows
filters = {
'keywords': 'revolutionary' # This should only match the RAP shows
}
# Generate feed
print(f"Generating RSS feed for {username} filtered by Revolutionary African/Afrikan Perspectives shows...")
rss_feed = generator.generate_rss_from_username(username, limit=200, filters=filters)
if rss_feed:
# Save to file
filename = f"{username}_revolutionary_african_perspectives.xml"
with open(filename, 'w', encoding='utf-8') as f:
f.write(rss_feed)
print(f"✅ RSS feed saved to: {filename}")
# RSS URLs for different filtering options
print(f"\n📡 RSS URLs for web server:")
print(f"Option 1 (by 'revolutionary'): http://localhost:5000/rss/{username}?limit=200&keywords=revolutionary")
print(f"Option 2 (by 'public affairs' + 'revolutionary'): http://localhost:5000/rss/{username}?limit=200&keywords=public%20affairs,revolutionary")
# Parse and show episodes
root = ET.fromstring(rss_feed)
items = root.findall('.//item')
print(f"\n📊 Found {len(items)} Revolutionary African/Afrikan Perspectives episodes")
# Show episode details
if items:
print("\n📅 All Revolutionary African/Afrikan Perspectives episodes:")
july_21_found = False
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")
show_date = pub_date.strftime("%Y-%m-%d")
except:
date_display = pub_date_str
show_date = ""
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() or "2025-07-21" in show_date:
print(f" ⭐ This is the July 21, 2025 show!")
july_21_found = True
july_21_url = link
if july_21_found:
print(f"\n✨ JULY 21 SHOW FOUND!")
print(f"Direct URL: {july_21_url}")
print(f"\nTo analyze this specific show in your podcast system:")
print(f"1. Use the RSS feed URL above")
print(f"2. Or process this specific episode URL directly")
# Summary
print(f"\n📈 Summary:")
print(f"- Total RAP episodes found: {len(items)}")
print(f"- These are weekly shows featuring Revolutionary African/Afrikan Perspectives")
print(f"- The feed includes both 'African' and 'Afrikan' spelling variations")
else:
print("❌ Error: Could not generate RSS feed")
if __name__ == "__main__":
generate_rap_precise_feed()