feat: serve dynamic M3U playlists for Mopidy robust streaming
This commit is contained in:
@@ -614,23 +614,34 @@ def podcast_rss(station: str, slug_with_ext: str, request: Request, db: Session
|
||||
|
||||
@app.get("/live/{station}")
|
||||
def live_stream_redirect(station: str, db: Session = Depends(db_session)):
|
||||
is_m3u = False
|
||||
|
||||
# Usuwamy sztuczne rozszerzenia dodane dla Mopidy
|
||||
if station.endswith(".aac"):
|
||||
station = station[:-4]
|
||||
elif station.endswith(".mp3"):
|
||||
station = station[:-4]
|
||||
elif station.endswith(".m3u"):
|
||||
station = station[:-4]
|
||||
is_m3u = True
|
||||
|
||||
if station == "radio357":
|
||||
config_url = db.query(Config).filter_by(key="r357_live_url").first()
|
||||
target_url = config_url.value if config_url else "https://stream.rcs.revma.com/ye5kghkgcm0uv"
|
||||
# Doklejamy #.aac dla kompatybilności z Mopidy (GStreamer potrzebuje wskazówki)
|
||||
if is_m3u:
|
||||
m3u_content = f"#EXTM3U\n#EXTINF:-1,Radio 357\n{target_url}\n"
|
||||
from fastapi.responses import PlainTextResponse
|
||||
return PlainTextResponse(content=m3u_content, media_type="audio/x-mpegurl")
|
||||
if "#" not in target_url:
|
||||
target_url += "#.aac"
|
||||
return RedirectResponse(url=target_url, status_code=302)
|
||||
elif station == "rns":
|
||||
config_url = db.query(Config).filter_by(key="rns_live_url").first()
|
||||
target_url = config_url.value if config_url else "https://stream.rcs.revma.com/4md4m0a0fs8uv"
|
||||
# Doklejamy #.mp3 dla pełnej zgodności
|
||||
if is_m3u:
|
||||
m3u_content = f"#EXTM3U\n#EXTINF:-1,Radio Nowy Świat\n{target_url}\n"
|
||||
from fastapi.responses import PlainTextResponse
|
||||
return PlainTextResponse(content=m3u_content, media_type="audio/x-mpegurl")
|
||||
if "#" not in target_url:
|
||||
target_url += "#.mp3"
|
||||
return RedirectResponse(url=target_url, status_code=302)
|
||||
|
||||
Reference in New Issue
Block a user