icy metadata support for 30 radios added
This commit is contained in:
1 parent
a59ffac93c
commit
4aecc81d2a
7 files changed
+202
-1
No files matched your search
@@ -36,6 +36,7 @@ class Music(PlayerCommands, QueueCommands, MusicEvents, RadioCommands, RadioEven
|
||||
self._radio_channels: dict[int, int] = {} # guild_id → text channel id (for drop notifications)
|
||||
self._music_channels: dict[int, int] = {} # guild_id → text channel id (for now-playing announcements)
|
||||
self._locks: dict[int, asyncio.Lock] = {}
|
||||
self._icy_tasks: dict[int, asyncio.Task] = {} # guild_id → ICY metadata poller task
|
||||
|
||||
# Load radio stations
|
||||
stations_path = Path(__file__).parent / "radio_stations.json"
|
||||
@@ -47,6 +48,13 @@ class Music(PlayerCommands, QueueCommands, MusicEvents, RadioCommands, RadioEven
|
||||
f"in {len(self._radio_stations)} categories"
|
||||
)
|
||||
|
||||
# Load ICY-supported station URLs (for live track metadata)
|
||||
icy_path = Path(__file__).parent / "../icy_supported.json"
|
||||
with open(icy_path, "r", encoding="utf-8") as f:
|
||||
icy_list: list[list[str]] = json.load(f)
|
||||
self._icy_urls: set[str] = {item[1] for item in icy_list}
|
||||
log.info(f"Loaded {len(self._icy_urls)} ICY-capable radio URLs")
|
||||
|
||||
# ── shared helpers (used by all mixins via self) ──────────────────────────
|
||||
def state(self, guild_id: int) -> GuildState:
|
||||
if guild_id not in self._states:
|
||||
@@ -72,6 +80,13 @@ class Music(PlayerCommands, QueueCommands, MusicEvents, RadioCommands, RadioEven
|
||||
return False
|
||||
return event_track.identifier == st.current.identifier
|
||||
|
||||
def _cancel_icy_poller(self, guild_id: int) -> None:
|
||||
"""Cancel and remove the ICY metadata poller for a guild, if any."""
|
||||
task = self._icy_tasks.pop(guild_id, None)
|
||||
if task is None:
|
||||
return
|
||||
task.cancel()
|
||||
|
||||
# ── !music ────────────────────────────────────────────────────────────────
|
||||
@commands.command()
|
||||
async def music(self, ctx: commands.Context):
|
||||
|
||||
Reference in new issue
Block a user