97 lines
3.1 KiB
Python
Executable File
97 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Beispiel-Script zum Testen des Mixcloud RSS Generators
|
|
"""
|
|
|
|
from mixcloud_rss import MixcloudRSSGenerator
|
|
import sys
|
|
|
|
def test_generator():
|
|
"""Testet den RSS-Generator mit deinem Mixcloud-Profil."""
|
|
username = "serman_dj"
|
|
|
|
print(f"🎵 Teste RSS-Generator für: {username}")
|
|
print("-" * 50)
|
|
|
|
# Generator erstellen
|
|
generator = MixcloudRSSGenerator(username, "test_feed.xml")
|
|
|
|
# Benutzerinfo testen
|
|
print("📋 Hole Benutzerinformationen...")
|
|
user_info = generator.get_user_info()
|
|
|
|
if user_info:
|
|
print(f"✅ Benutzer gefunden: {user_info.get('name', 'Unbekannt')}")
|
|
print(f" Follower: {user_info.get('follower_count', 0)}")
|
|
print(f" Following: {user_info.get('following_count', 0)}")
|
|
print(f" Cloudcasts: {user_info.get('cloudcast_count', 0)}")
|
|
else:
|
|
print("❌ Benutzer nicht gefunden!")
|
|
return False
|
|
|
|
# Cloudcasts testen
|
|
print("\n🎧 Hole die ersten 10 Cloudcasts...")
|
|
cloudcasts = generator.get_cloudcasts(limit=10)
|
|
|
|
if cloudcasts:
|
|
print(f"✅ {len(cloudcasts)} Cloudcasts gefunden:")
|
|
for i, cloudcast in enumerate(cloudcasts[:5], 1):
|
|
name = cloudcast.get('name', 'Unbekannter Titel')
|
|
duration = cloudcast.get('audio_length', 0)
|
|
duration_str = generator.format_duration(duration) if duration else "Unbekannt"
|
|
print(f" {i}. {name} ({duration_str})")
|
|
|
|
if len(cloudcasts) > 5:
|
|
print(f" ... und {len(cloudcasts) - 5} weitere")
|
|
else:
|
|
print("❌ Keine Cloudcasts gefunden!")
|
|
return False
|
|
|
|
# RSS-Feed erstellen
|
|
print("\n📡 Erstelle RSS-Feed...")
|
|
success = generator.create_rss_feed()
|
|
|
|
if success:
|
|
print("✅ RSS-Feed erfolgreich erstellt!")
|
|
print(f" Datei: {generator.output_file}")
|
|
|
|
# Feed-Info anzeigen
|
|
import os
|
|
if os.path.exists(generator.output_file):
|
|
size = os.path.getsize(generator.output_file)
|
|
print(f" Größe: {size} Bytes")
|
|
|
|
# Erste Zeilen der XML-Datei anzeigen
|
|
print("\n📄 Feed-Preview:")
|
|
with open(generator.output_file, 'r', encoding='utf-8') as f:
|
|
lines = f.readlines()[:10]
|
|
for line in lines:
|
|
print(f" {line.rstrip()}")
|
|
if len(lines) >= 10:
|
|
print(" ...")
|
|
|
|
return True
|
|
else:
|
|
print("❌ Fehler beim Erstellen des RSS-Feeds!")
|
|
return False
|
|
|
|
def main():
|
|
"""Hauptfunktion."""
|
|
print("🎵 Mixcloud RSS Generator - Test")
|
|
print("=" * 50)
|
|
|
|
success = test_generator()
|
|
|
|
if success:
|
|
print("\n🎉 Test erfolgreich abgeschlossen!")
|
|
print("\nNächste Schritte:")
|
|
print("1. Starte den Server: python mixcloud_rss.py serman_dj --serve")
|
|
print("2. Öffne http://localhost:8000/mixcloud_feed.xml im Browser")
|
|
print("3. Füge die URL in deiner Podcast-App hinzu")
|
|
else:
|
|
print("\n❌ Test fehlgeschlagen!")
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|