Skip to content
Snippets Groups Projects
typing.py 2.95 KiB
from typing import Literal, NotRequired, TypedDict


class NestedTimeslot(TypedDict):
    end: str
    id: int | None
    is_virtual: bool
    memo: str
    playlist_id: int | None
    repetition_of_id: int | None
    start: str


class NestedShow(TypedDict):
    default_playlist_id: int | None
    id: int
    name: str


class NestedSchedule(TypedDict):
    id: int | None
    default_playlist_id: int | None


class NestedEpisode(TypedDict):
    id: int | None
    title: str


class DayScheduleEntry(TypedDict):
    episode: NestedEpisode
    timeslot: NestedTimeslot
    show: NestedShow


class TimerangeEntry(TypedDict):
    episode: NestedEpisode
    schedule: NestedSchedule | None
    show: NestedShow
    timeslot: NestedTimeslot


class Thumbnail(TypedDict):
    width: float
    height: float
    url: str


class RadioCBASettings(TypedDict):
    api_key: NotRequired[str]
    domains: list[str]


class ProgramFallback(TypedDict):
    default_pool: str
    show_id: int | None


class MicroProgram(TypedDict):
    show_id: int | None


class RadioProgramSettings(TypedDict):
    fallback: ProgramFallback
    micro: MicroProgram


class PlayoutPools(TypedDict):
    fallback: str | None


class RadioPlayoutSettings(TypedDict):
    line_in_channels: dict[str, str]
    pools: PlayoutPools


class Logo(TypedDict):
    url: str
    height: int
    width: int


class RadioStationSettings(TypedDict):
    name: str
    logo: Logo | None
    website: str


class ImageFrame(TypedDict):
    aspect_ratio: tuple[int, int] | tuple[float, float]
    shape: Literal["rect", "round"]


class ImageRequirements(TypedDict):
    frame: ImageFrame


# done this way, because the keys have dots (".")
RadioImageRequirementsSettings = TypedDict(
    "RadioImageRequirementsSettings",
    {
        "note.image": ImageRequirements,
        "profile.image": ImageRequirements,
        "show.image": ImageRequirements,
        "show.logo": ImageRequirements,
    },
)


class Link(TypedDict):
    type_id: int
    url: str


class ScheduleData(TypedDict):
    add_business_days_only: bool | None
    add_days_no: int | None
    by_weekday: int | None
    default_playlist_id: int | None
    dryrun: bool | None
    end_time: str
    first_date: str
    id: int | None
    is_repetition: bool | None
    last_date: str | None
    rrule_id: int
    show_id: int | None
    start_time: str


class Collision(TypedDict):
    end: str
    timeslot_id: int
    memo: str
    note_id: int | None
    playlist_id: int | None
    schedule_id: int
    show_id: int
    show_name: str
    start: str


class ProjectedEntry(TypedDict):
    collisions: list[Collision]
    end: str
    error: str | None
    hash: str
    solution_choices: set[str]
    start: str


class Conflicts(TypedDict):
    notes: dict
    playlists: dict
    projected: list[ProjectedEntry]
    solutions: dict[str, str]


class ScheduleCreateUpdateData(TypedDict):
    notes: dict
    playlists: dict
    schedule: ScheduleData
    solutions: dict[str, str]