-
Notifications
You must be signed in to change notification settings - Fork 3
/
model.py
34 lines (30 loc) · 914 Bytes
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""This module contains the Channel class, which represents a TV channel."""
import dataclasses
import datetime
import typing
@dataclasses.dataclass
class Channel:
id: str
name: str
alt_names: list[str]
network: typing.Optional[str]
owners: list[str]
country: str
subdivision: typing.Optional[str]
city: typing.Optional[str]
broadcast_area: str
languages: list[str]
categories: list[str]
is_nsfw: bool
launched: typing.Optional[datetime.datetime]
closed: typing.Optional[datetime.datetime]
replaced_by: typing.Optional[str]
website: typing.Optional[str]
logo: str
@property
def as_dict(self):
"""Returns a dictionary representation of the object."""
return {
key: value.timestamp() if isinstance(value, datetime.datetime) else value
for key, value in dataclasses.asdict(self).items()
}