Füge Mixcloud RSS Feed Generator hinzu, einschließlich Hauptskript, Serverstarter und Testskript. Aktualisiere .gitignore, .python-version, pyproject.toml und requirements.txt.
This commit is contained in:
95
start_server.py
Executable file
95
start_server.py
Executable file
@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Einfacher Server-Starter für den Mixcloud RSS-Feed
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import time
|
||||
import threading
|
||||
import http.server
|
||||
import socketserver
|
||||
from pathlib import Path
|
||||
|
||||
def update_feed():
|
||||
"""Aktualisiert den RSS-Feed."""
|
||||
print("🔄 Aktualisiere RSS-Feed...")
|
||||
result = subprocess.run([
|
||||
sys.executable, "mixcloud_rss.py", "serman_dj",
|
||||
"--output", "mixcloud_feed.xml"
|
||||
], capture_output=True, text=True)
|
||||
|
||||
if result.returncode == 0:
|
||||
print("✅ RSS-Feed erfolgreich aktualisiert!")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Fehler beim Aktualisieren: {result.stderr}")
|
||||
return False
|
||||
|
||||
def start_server(port=8000):
|
||||
"""Startet den HTTP-Server für den RSS-Feed."""
|
||||
handler = http.server.SimpleHTTPRequestHandler
|
||||
|
||||
try:
|
||||
with socketserver.TCPServer(("", port), handler) as httpd:
|
||||
print(f"🌐 Server läuft auf http://localhost:{port}")
|
||||
print(f"📡 RSS-Feed: http://localhost:{port}/mixcloud_feed.xml")
|
||||
print("=" * 60)
|
||||
print("📱 Podcast-App Anleitung:")
|
||||
print(" 1. Kopiere diese URL: http://localhost:{port}/mixcloud_feed.xml")
|
||||
print(" 2. Öffne deine Podcast-App")
|
||||
print(" 3. Wähle 'Podcast hinzufügen' oder 'Feed hinzufügen'")
|
||||
print(" 4. Füge die URL ein")
|
||||
print("=" * 60)
|
||||
print("⏹️ Drücke Ctrl+C zum Beenden")
|
||||
print()
|
||||
|
||||
httpd.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print("\n👋 Server beendet.")
|
||||
except Exception as e:
|
||||
print(f"❌ Fehler beim Starten des Servers: {e}")
|
||||
|
||||
def auto_update_feed(interval_minutes=60):
|
||||
"""Aktualisiert den Feed automatisch in regelmäßigen Abständen."""
|
||||
while True:
|
||||
time.sleep(interval_minutes * 60) # Warte x Minuten
|
||||
print(f"\n⏰ Automatische Aktualisierung nach {interval_minutes} Minuten...")
|
||||
update_feed()
|
||||
|
||||
def main():
|
||||
"""Hauptfunktion."""
|
||||
print("🎵 SERMAN DJ - Mixcloud RSS Server")
|
||||
print("=" * 40)
|
||||
|
||||
# Überprüfe ob wir im richtigen Verzeichnis sind
|
||||
if not Path("mixcloud_rss.py").exists():
|
||||
print("❌ mixcloud_rss.py nicht gefunden!")
|
||||
print(" Stelle sicher, dass du im richtigen Verzeichnis bist.")
|
||||
sys.exit(1)
|
||||
|
||||
# Erstelle initialen Feed
|
||||
print("🏁 Erstelle initialen RSS-Feed...")
|
||||
if not update_feed():
|
||||
sys.exit(1)
|
||||
|
||||
# Überprüfe ob Feed existiert
|
||||
if not Path("mixcloud_feed.xml").exists():
|
||||
print("❌ RSS-Feed konnte nicht erstellt werden!")
|
||||
sys.exit(1)
|
||||
|
||||
# Starte automatische Updates in separatem Thread
|
||||
update_thread = threading.Thread(
|
||||
target=auto_update_feed,
|
||||
args=(60,), # Aktualisiere jede Stunde
|
||||
daemon=True
|
||||
)
|
||||
update_thread.start()
|
||||
print("⏰ Automatische Updates aktiviert (alle 60 Minuten)")
|
||||
|
||||
# Starte Server
|
||||
start_server()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user