42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from typing import Annotated, NamedTuple
|
|
|
|
from fastapi import Depends
|
|
|
|
from gallery.sketch.schedule.api import ScheduleApi
|
|
|
|
from .api import api_resolver
|
|
|
|
ScheduleApiDepends = Annotated[ScheduleApi, Depends(api_resolver(ScheduleApi))]
|
|
|
|
|
|
class ChannelDef(NamedTuple):
|
|
provider: str
|
|
id: str
|
|
|
|
|
|
GROUP_CANNELS_MAP: dict[str, list[ChannelDef]] = {
|
|
"central": [
|
|
ChannelDef("yandex", "pervyy-16"),
|
|
ChannelDef("yandex", "rossiya-1-31"),
|
|
ChannelDef("yandex", "ntv-11"),
|
|
ChannelDef("yandex", "sts-8"),
|
|
],
|
|
"sport": [
|
|
ChannelDef("matchtv", "matchtv"),
|
|
ChannelDef("matchtv", "igra"),
|
|
ChannelDef("matchtv", "arena"),
|
|
ChannelDef("matchtv", "futbol-1"),
|
|
ChannelDef("matchtv", "futbol-2"),
|
|
ChannelDef("matchtv", "futbol-3"),
|
|
ChannelDef("matchtv", "strana"),
|
|
ChannelDef("yandex", "start-103"),
|
|
],
|
|
}
|
|
|
|
|
|
def resolve_group_channels(group_id: str) -> list[ChannelDef]:
|
|
return GROUP_CANNELS_MAP.get(group_id) or [ChannelDef(*item.split(":")) for item in group_id.split(",")]
|
|
|
|
|
|
ScheduleGroupChannelsDepends = Annotated[list[ChannelDef], Depends(resolve_group_channels)]
|