/
base.py
37 lines (29 loc) · 957 Bytes
/
base.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
34
35
36
37
from typing import List
from dataclasses import dataclass
from ..base import Item
from ..artist import SimpleArtist
from ..member import Image, ReleaseDatePrecision
from ..serialise import StrEnum, ModelList
class AlbumType(StrEnum):
"""Type of album."""
album = 'album'
compilation = 'compilation'
single = 'single'
@dataclass(repr=False)
class Album(Item):
"""Album base."""
album_type: AlbumType
artists: List[SimpleArtist]
external_urls: dict
images: List[Image]
name: str
total_tracks: int
release_date: str
release_date_precision: ReleaseDatePrecision
def __post_init__(self):
self.album_type = AlbumType[self.album_type.lower()]
self.artists = ModelList(SimpleArtist(**a) for a in self.artists)
self.images = ModelList(Image(**i) for i in self.images)
self.release_date_precision = ReleaseDatePrecision[
self.release_date_precision
]