-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
86 lines (62 loc) · 1.71 KB
/
models.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from abc import ABC, abstractmethod
from collections import namedtuple
from enum import Enum
from typing import Callable, List, NamedTuple, Optional, Tuple, Type, Union
class ManiaException(Exception):
exit_code = 0
class ManiaSeriousException(ManiaException):
exit_code = 1
class UnavailableException(Exception):
pass
class Artist(NamedTuple):
id: str
name: str
class Album(NamedTuple):
id: str
name: str
artists: List[Artist]
year: Optional[str]
explicit: bool
cover_url: Optional[str]
best_available_quality: str
class Track(NamedTuple):
id: str
name: str
artists: List[Artist]
album: Album
explicit: bool
track_number: int
disc_number: int
chosen_quality: str
best_available_quality: str
file_extension: str
Media = Union[Track, Album, Artist]
MediaType = Union[Type[Track], Type[Album], Type[Artist]]
class Client(ABC):
@abstractmethod
def authenticate(self):
pass
@abstractmethod
def search(self, query: str, media_type: MediaType, count: int):
pass
@abstractmethod
def get_album_tracks(self, album: Album) -> List[Track]:
pass
@abstractmethod
def get_artist_albums(self, artist: Artist) -> List[Album]:
pass
@abstractmethod
def get_media(self, track: Track) -> Tuple[str, Optional[Callable[[str], None]]]:
pass
@abstractmethod
def get_artist_by_id(self, artist_id: str):
pass
@abstractmethod
def get_album_by_id(self, album_id: str):
pass
@abstractmethod
def get_track_by_id(self, track_id: str):
pass
@abstractmethod
def resolve_url(self, url: str) -> Tuple[MediaType, Optional[Media]]:
pass