feat(tilderadio): add the tildeverse community stream as a catalogue
This commit is contained in:
1 parent
58e9202e25
commit
058d336a2c
8 files changed
+883
-4
No files matched your search
@@ -0,0 +1,56 @@
|
||||
"""Bundled station, so a cold offline start still makes sense.
|
||||
|
||||
tilderadio is a single-station catalogue — one community stream for the whole
|
||||
tildeverse — so "the bundled station list" is that one station. The mounts
|
||||
below are the ones the AzuraCast instance has served for years; the live list
|
||||
from ``/api/now/`` always wins, and the URLs are additionally probed by the
|
||||
player's normal failover.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
# (url, format, quality, bitrate)
|
||||
_MOUNTS: tuple[tuple[str, str, str, str], ...] = (
|
||||
("https://azuracast.tilderadio.org/listen/tilderadio/radio.mp3", "mp3", "high", "192"),
|
||||
("https://azuracast.tilderadio.org/listen/tilderadio/320k.mp3", "mp3", "highest", "320"),
|
||||
("https://azuracast.tilderadio.org/listen/tilderadio/radio.ogg", "ogg", "high", "192"),
|
||||
)
|
||||
|
||||
|
||||
def fallback_payload() -> dict[str, Any]:
|
||||
"""A ``/api/now/``-shaped payload, so the normal parser can eat it."""
|
||||
return {
|
||||
"api_version": 1,
|
||||
"status": "ok",
|
||||
"station": {
|
||||
"id": 1,
|
||||
"name": "tilderadio",
|
||||
"shortcode": "tilderadio",
|
||||
"listen_url": _MOUNTS[2][0],
|
||||
},
|
||||
"is_live": False,
|
||||
"dj": None,
|
||||
"listeners": 0,
|
||||
"now_playing": None,
|
||||
"history": [],
|
||||
}
|
||||
|
||||
|
||||
def fallback_playlists() -> list[dict[str, str]]:
|
||||
return [
|
||||
{"url": url, "format": fmt, "quality": quality, "bitrate": bitrate}
|
||||
for url, fmt, quality, bitrate in _MOUNTS
|
||||
]
|
||||
|
||||
|
||||
def known_stream_urls() -> list[str]:
|
||||
return [url for url, _format, _quality, _bitrate in _MOUNTS]
|
||||
|
||||
|
||||
def fallback_stations() -> list[Any]:
|
||||
from .api import station_from_now
|
||||
|
||||
station = station_from_now(fallback_payload(), fallback_playlists())
|
||||
return [station] if station is not None else []
|
||||
Reference in new issue
Block a user