aboutsummaryrefslogtreecommitdiff
path: root/pandora/models/pandora.py
diff options
context:
space:
mode:
Diffstat (limited to 'pandora/models/pandora.py')
-rw-r--r--pandora/models/pandora.py40
1 files changed, 38 insertions, 2 deletions
diff --git a/pandora/models/pandora.py b/pandora/models/pandora.py
index cc57eac..ecc1225 100644
--- a/pandora/models/pandora.py
+++ b/pandora/models/pandora.py
@@ -6,6 +6,18 @@ from . import Field, DateField, SyntheticField
6from . import PandoraModel, PandoraListModel, PandoraDictListModel 6from . import PandoraModel, PandoraListModel, PandoraDictListModel
7 7
8 8
9class AdditionalAudioUrl(Enum):
10 HTTP_40_AAC_MONO = 'HTTP_40_AAC_MONO'
11 HTTP_64_AAC = 'HTTP_64_AAC'
12 HTTP_32_AACPLUS = 'HTTP_32_AACPLUS'
13 HTTP_64_AACPLUS = 'HTTP_64_AACPLUS'
14 HTTP_24_AACPLUS_ADTS = 'HTTP_24_AACPLUS_ADTS'
15 HTTP_32_AACPLUS_ADTS = 'HTTP_32_AACPLUS_ADTS'
16 HTTP_64_AACPLUS_ADTS = 'HTTP_64_AACPLUS_ADTS'
17 HTTP_128_MP3 = 'HTTP_128_MP3'
18 HTTP_32_WMA = 'HTTP_32_WMA'
19
20
9class PandoraType(Enum): 21class PandoraType(Enum):
10 22
11 TRACK = "TR" 23 TRACK = "TR"
@@ -100,8 +112,9 @@ class Station(PandoraModel):
100 seeds = Field("music", model=StationSeeds) 112 seeds = Field("music", model=StationSeeds)
101 feedback = Field("feedback", model=StationFeedback) 113 feedback = Field("feedback", model=StationFeedback)
102 114
103 def get_playlist(self): 115 def get_playlist(self, additional_urls=None):
104 return iter(self._api_client.get_playlist(self.token)) 116 return iter(self._api_client.get_playlist(self.token,
117 additional_urls))
105 118
106 119
107class GenreStation(PandoraModel): 120class GenreStation(PandoraModel):
@@ -178,6 +191,27 @@ class AudioField(SyntheticField):
178 return audio_url[self.field] if audio_url else None 191 return audio_url[self.field] if audio_url else None
179 192
180 193
194class AdditionalUrlField(SyntheticField):
195
196 def formatter(self, api_client, data, value):
197 """Parse additional url fields and map them to inputs
198
199 Attempt to create a dictionary with keys being user input, and
200 response being the returned URL
201 """
202 if value is None:
203 return None
204
205 user_param = data['_paramAdditionalUrls']
206 urls = {}
207 if isinstance(value, str):
208 urls[user_param[0]] = value
209 else:
210 for key, url in zip(user_param, value):
211 urls[key] = url
212 return urls
213
214
181class PlaylistModel(PandoraModel): 215class PlaylistModel(PandoraModel):
182 216
183 def get_is_playable(self): 217 def get_is_playable(self):
@@ -243,6 +277,8 @@ class PlaylistItem(PlaylistModel):
243 song_detail_url = Field("songDetailUrl") 277 song_detail_url = Field("songDetailUrl")
244 song_explore_url = Field("songExplorerUrl") 278 song_explore_url = Field("songExplorerUrl")
245 279
280 additional_audio_urls = AdditionalUrlField("additionalAudioUrl")
281
246 @property 282 @property
247 def is_ad(self): 283 def is_ad(self):
248 return self.ad_token is not None 284 return self.ad_token is not None