77 lines
2.4 KiB
Python
77 lines
2.4 KiB
Python
"""Bassdrive: worldwide drum & bass, on air since the dial-up days.
|
|
|
|
One stream with three mounts, a schedule full of live DJ shows and a
|
|
``display-title`` that names the show rather than the track. Everything
|
|
Bassdrive-specific — the Icecast status schema, the homepage schedule grid, the
|
|
rolling show history and the bundled fallback — lives in this package; the app
|
|
only sees :class:`BassdriveProvider`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import httpx
|
|
|
|
from ... import config
|
|
from ...models import Broadcast, Song, Station
|
|
from ..base import RadioProvider
|
|
from . import api, fallback
|
|
from . import hero as hero_art
|
|
|
|
__all__ = ["BassdriveProvider"]
|
|
|
|
|
|
class BassdriveProvider(RadioProvider):
|
|
id = "bassdrive"
|
|
name = "Bassdrive"
|
|
homepage = "bassdrive.com"
|
|
brand = "BASSDRIVE"
|
|
tagline = "worldwide drum & bass · live shows"
|
|
station_source = "bassdrive.com + icecast status"
|
|
history_source = "icecast status (rolling)"
|
|
|
|
# The wordmark in the station's own two blues, in the shared half-block
|
|
# font; the caption is the station's own description.
|
|
hero = hero_art.HERO
|
|
hero_lines = (
|
|
"BASSDRIVE",
|
|
"WORLDWIDE DRUM & BASS",
|
|
"LIVE SHOWS 24/7",
|
|
)
|
|
|
|
# One stream and a schedule full of DJ slots: the left pane is the schedule.
|
|
has_schedule = True
|
|
# DJ-mix station: the rotation is not a Bandcamp catalogue.
|
|
bandcamp = False
|
|
|
|
@property
|
|
def user_agent(self) -> str:
|
|
return f"{config.USER_AGENT}; +https://bassdrive.com"
|
|
|
|
async def fetch_stations(self, client: httpx.AsyncClient) -> list[Station]:
|
|
return [await api.fetch_station(client)]
|
|
|
|
def load_cached_stations(self) -> list[Station]:
|
|
return api.load_cached_station()
|
|
|
|
def fallback_stations(self) -> list[Station]:
|
|
return fallback.fallback_stations()
|
|
|
|
async def fetch_history(
|
|
self, client: httpx.AsyncClient, station_id: str
|
|
) -> list[Song]:
|
|
return await api.fetch_songs(client, station_id)
|
|
|
|
def load_cached_history(self, station_id: str) -> list[Song]:
|
|
return api.load_cached_songs(station_id)
|
|
|
|
async def fetch_schedule(
|
|
self, client: httpx.AsyncClient
|
|
) -> list[Broadcast]:
|
|
return await api.fetch_schedule(client)
|
|
|
|
def load_cached_schedule(self) -> list[Broadcast]:
|
|
return api.load_cached_schedule()
|
|
|
|
def fallback_urls(self, station: Station) -> list[str]:
|
|
return fallback.known_stream_urls()
|