aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2017-06-12 22:06:15 -0700
committerMike Crute <mcrute@gmail.com>2017-06-12 22:18:31 -0700
commit75caf919f102f7f4f30936ad74a0aa91e17b0557 (patch)
tree492792829a243d8637043e1d98e965b3f6185823
parent709a25482a0e9a6b4d66561d5ea48253a230d01c (diff)
downloadpydora-75caf919f102f7f4f30936ad74a0aa91e17b0557.tar.bz2
pydora-75caf919f102f7f4f30936ad74a0aa91e17b0557.tar.xz
pydora-75caf919f102f7f4f30936ad74a0aa91e17b0557.zip
Add encoding field to track
Previously Pandora only surfaced mp3 files in their responses which worked fairly universally. Recently they started surfacing AAC files which don't work in the pydora player as-is. Add the encoding to the sock model so that players can make a decision based on it. see: #52
-rw-r--r--pandora/models/pandora.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/pandora/models/pandora.py b/pandora/models/pandora.py
index 0b138b3..2df464e 100644
--- a/pandora/models/pandora.py
+++ b/pandora/models/pandora.py
@@ -68,6 +68,10 @@ class PlaylistModel(PandoraModel):
68 newval = cls.get_audio_bitrate( 68 newval = cls.get_audio_bitrate(
69 data, api_client.default_audio_quality) 69 data, api_client.default_audio_quality)
70 70
71 if value.field == "encoding" and newval is None:
72 newval = cls.get_audio_encoding(
73 data, api_client.default_audio_quality)
74
71 if newval and value.formatter: 75 if newval and value.formatter:
72 newval = value.formatter(newval) 76 newval = value.formatter(newval)
73 77
@@ -129,6 +133,16 @@ class PlaylistModel(PandoraModel):
129 """ 133 """
130 return cls.get_audio_field(data, "bitrate", preferred_quality) 134 return cls.get_audio_field(data, "bitrate", preferred_quality)
131 135
136 @classmethod
137 def get_audio_encoding(cls, data,
138 preferred_quality=BaseAPIClient.MED_AUDIO_QUALITY):
139 """Get audio encoding
140
141 Try to find encoding of audio url for specified preferred quality
142 level, or next-lowest available quality url otherwise.
143 """
144 return cls.get_audio_field(data, "encoding", preferred_quality)
145
132 def get_is_playable(self): 146 def get_is_playable(self):
133 if not self.audio_url: 147 if not self.audio_url:
134 return False 148 return False
@@ -169,6 +183,7 @@ class PlaylistItem(PlaylistModel):
169 track_token = Field("trackToken") 183 track_token = Field("trackToken")
170 audio_url = Field("audioUrl") 184 audio_url = Field("audioUrl")
171 bitrate = Field("bitrate") 185 bitrate = Field("bitrate")
186 encoding = Field("encoding")
172 album_art_url = Field("albumArtUrl") 187 album_art_url = Field("albumArtUrl")
173 allow_feedback = Field("allowFeedback") 188 allow_feedback = Field("allowFeedback")
174 station_id = Field("stationId") 189 station_id = Field("stationId")