diff options
Diffstat (limited to 'pandora/models/station.py')
-rw-r--r-- | pandora/models/station.py | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/pandora/models/station.py b/pandora/models/station.py new file mode 100644 index 0000000..d4f4846 --- /dev/null +++ b/pandora/models/station.py | |||
@@ -0,0 +1,123 @@ | |||
1 | from ._base import Field, DateField | ||
2 | from ._base import PandoraModel, PandoraListModel, PandoraDictListModel | ||
3 | from .playlist import PandoraType | ||
4 | |||
5 | |||
6 | class Icon(PandoraModel): | ||
7 | |||
8 | dominant_color = Field("dominantColor") | ||
9 | art_url = Field("artUrl") | ||
10 | |||
11 | |||
12 | class StationSeed(PandoraModel): | ||
13 | |||
14 | seed_id = Field("seedId") | ||
15 | music_token = Field("musicToken") | ||
16 | pandora_id = Field("pandoraId") | ||
17 | pandora_type = Field("pandoraType", formatter=PandoraType.from_model) | ||
18 | |||
19 | genre_name = Field("genreName") | ||
20 | song_name = Field("songName") | ||
21 | artist_name = Field("artistName") | ||
22 | art_url = Field("artUrl") | ||
23 | icon = Field("icon", model=Icon) | ||
24 | |||
25 | |||
26 | class StationSeeds(PandoraModel): | ||
27 | |||
28 | genres = Field("genres", model=StationSeed) | ||
29 | songs = Field("songs", model=StationSeed) | ||
30 | artists = Field("artists", model=StationSeed) | ||
31 | |||
32 | |||
33 | class SongFeedback(PandoraModel): | ||
34 | |||
35 | feedback_id = Field("feedbackId") | ||
36 | song_identity = Field("songIdentity") | ||
37 | is_positive = Field("isPositive") | ||
38 | pandora_id = Field("pandoraId") | ||
39 | album_art_url = Field("albumArtUrl") | ||
40 | music_token = Field("musicToken") | ||
41 | song_name = Field("songName") | ||
42 | artist_name = Field("artistName") | ||
43 | pandora_type = Field("pandoraType", formatter=PandoraType.from_model) | ||
44 | date_created = DateField("dateCreated") | ||
45 | |||
46 | |||
47 | class StationFeedback(PandoraModel): | ||
48 | |||
49 | total_thumbs_up = Field("totalThumbsUp") | ||
50 | total_thumbs_down = Field("totalThumbsDown") | ||
51 | thumbs_up = Field("thumbsUp", model=SongFeedback) | ||
52 | thumbs_down = Field("thumbsDown", model=SongFeedback) | ||
53 | |||
54 | |||
55 | class Station(PandoraModel): | ||
56 | |||
57 | can_add_music = Field("allowAddMusic") | ||
58 | can_delete = Field("allowDelete") | ||
59 | can_rename = Field("allowRename") | ||
60 | can_edit_description = Field("allowEditDescription") | ||
61 | process_skips = Field("processSkips") | ||
62 | is_shared = Field("isShared") | ||
63 | is_quickmix = Field("isQuickMix") | ||
64 | is_genre_station = Field("isGenreStation") | ||
65 | is_thumbprint_station = Field("isThumbprint") | ||
66 | |||
67 | art_url = Field("artUrl") | ||
68 | date_created = DateField("dateCreated") | ||
69 | detail_url = Field("stationDetailUrl") | ||
70 | id = Field("stationId") | ||
71 | name = Field("stationName") | ||
72 | sharing_url = Field("stationSharingUrl") | ||
73 | thumb_count = Field("thumbCount") | ||
74 | token = Field("stationToken") | ||
75 | |||
76 | genre = Field("genre", []) | ||
77 | quickmix_stations = Field("quickMixStationIds", []) | ||
78 | |||
79 | seeds = Field("music", model=StationSeeds) | ||
80 | feedback = Field("feedback", model=StationFeedback) | ||
81 | |||
82 | def get_playlist(self, additional_urls=None): | ||
83 | return iter(self._api_client.get_playlist(self.token, | ||
84 | additional_urls)) | ||
85 | |||
86 | |||
87 | class StationList(PandoraListModel): | ||
88 | |||
89 | checksum = Field("checksum") | ||
90 | |||
91 | __index_key__ = "id" | ||
92 | __list_key__ = "stations" | ||
93 | __list_model__ = Station | ||
94 | |||
95 | def has_changed(self): | ||
96 | checksum = self._api_client.get_station_list_checksum() | ||
97 | return checksum != self.checksum | ||
98 | |||
99 | |||
100 | class GenreStation(PandoraModel): | ||
101 | |||
102 | id = Field("stationId") | ||
103 | name = Field("stationName") | ||
104 | token = Field("stationToken") | ||
105 | category = Field("categoryName") | ||
106 | |||
107 | def get_playlist(self): # pragma: no cover | ||
108 | raise NotImplementedError("Genre stations do not have playlists. " | ||
109 | "Create a real station using the token.") | ||
110 | |||
111 | |||
112 | class GenreStationList(PandoraDictListModel): | ||
113 | |||
114 | checksum = Field("checksum") | ||
115 | |||
116 | __dict_list_key__ = "categories" | ||
117 | __dict_key__ = "categoryName" | ||
118 | __list_key__ = "stations" | ||
119 | __list_model__ = GenreStation | ||
120 | |||
121 | def has_changed(self): | ||
122 | checksum = self._api_client.get_station_list_checksum() | ||
123 | return checksum != self.checksum | ||