|
|
@ -15,6 +15,7 @@ class Zap2it: |
|
|
_BASE_URL = "https://tvlistings.zap2it.com/api/" |
|
|
_BASE_URL = "https://tvlistings.zap2it.com/api/" |
|
|
_listings: dict[str, Program] = field(default_factory=dict) |
|
|
_listings: dict[str, Program] = field(default_factory=dict) |
|
|
_last_fetch: float = 0 |
|
|
_last_fetch: float = 0 |
|
|
|
|
|
_channel_icons: dict[str, str] = field(default_factory=dict) |
|
|
|
|
|
|
|
|
def _get_client(self) -> httpx.AsyncClient: |
|
|
def _get_client(self) -> httpx.AsyncClient: |
|
|
return httpx.AsyncClient( |
|
|
return httpx.AsyncClient( |
|
|
@ -77,6 +78,12 @@ class Zap2it: |
|
|
if call_sign not in events: |
|
|
if call_sign not in events: |
|
|
events[call_sign] = {} |
|
|
events[call_sign] = {} |
|
|
|
|
|
|
|
|
|
|
|
if ch_data.get("thumbnail"): |
|
|
|
|
|
thumbnail = ch_data["thumbnail"] |
|
|
|
|
|
if thumbnail.startswith("//"): |
|
|
|
|
|
thumbnail = f"https:{thumbnail}" |
|
|
|
|
|
self._channel_icons[call_sign] = thumbnail |
|
|
|
|
|
|
|
|
for evt in ch_data["events"]: |
|
|
for evt in ch_data["events"]: |
|
|
key = (evt["startTime"], evt["endTime"]) |
|
|
key = (evt["startTime"], evt["endTime"]) |
|
|
if key not in events[call_sign]: |
|
|
if key not in events[call_sign]: |
|
|
@ -149,3 +156,10 @@ class Zap2it: |
|
|
return [] |
|
|
return [] |
|
|
|
|
|
|
|
|
return self._listings[channel.call_sign] |
|
|
return self._listings[channel.call_sign] |
|
|
|
|
|
|
|
|
|
|
|
async def get_channel_icon(self, channel: DLHDChannel) -> str | None: |
|
|
|
|
|
if not channel.call_sign: |
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
await self._refresh_listings() |
|
|
|
|
|
return self._channel_icons.get(channel.call_sign) |