feat(schedule): implement multiple schedule providers

This commit is contained in:
2026-06-26 16:36:40 +03:00
parent 8b20eb1220
commit a41b4e5308
20 changed files with 669 additions and 164 deletions

View File

@@ -1,25 +1,15 @@
import asyncio
import datetime
from ..api import Api
from .model import ChannelId, Schedule
from .model import Channel, Schedule
class ScheduleApi(Api):
TYPE = "schedule"
INTERVAL: float = 0.5
async def get_channels(self) -> list[ChannelId]:
async def find_channels(self, query: str) -> list[Channel]:
raise NotImplementedError
async def get_channel_schedule(self, channel_id: ChannelId, date: datetime.date) -> Schedule:
async def get_schedule(self, channel_id: str, date: datetime.date) -> Schedule:
raise NotImplementedError
async def get_all_schedules(self, date: datetime.date) -> list[Schedule]:
channels = await self.get_channels()
results = []
for channel in channels:
results.append(await self.get_channel_schedule(channel_id=channel, date=date))
if self.INTERVAL > 0:
await asyncio.sleep(self.INTERVAL)
return results