25 lines
743 B
Python
25 lines
743 B
Python
import asyncio
|
|
import datetime
|
|
|
|
from ..api import Api
|
|
from .model import ChannelId, Schedule
|
|
|
|
|
|
class ScheduleApi(Api):
|
|
INTERVAL: float = 0.5
|
|
|
|
async def get_channels(self) -> list[ChannelId]:
|
|
raise NotImplementedError
|
|
|
|
async def get_channel_schedule(self, channel_id: ChannelId, 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
|