aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2017-06-12 22:07:15 -0700
committerMike Crute <mcrute@gmail.com>2017-06-12 22:22:38 -0700
commit9cc2ff1434c0d34452c8e02da63fd4c919261509 (patch)
treeae74537b0721a70f2b19a98e762e6e1eb947acbe
parent75caf919f102f7f4f30936ad74a0aa91e17b0557 (diff)
downloadpydora-9cc2ff1434c0d34452c8e02da63fd4c919261509.tar.bz2
pydora-9cc2ff1434c0d34452c8e02da63fd4c919261509.tar.xz
pydora-9cc2ff1434c0d34452c8e02da63fd4c919261509.zip
Support new-style audio URLs
Pandora now returns two different responses to the API depending on which API key the client is using and the tuner endpoint. Instead of a quality map only a single audio URL is returned which is of AAC SBR format. This change accommodates that and returns the proper bitrate and format based on empirical testing. see: #52
-rw-r--r--pandora/models/pandora.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/pandora/models/pandora.py b/pandora/models/pandora.py
index 2df464e..3ffac7d 100644
--- a/pandora/models/pandora.py
+++ b/pandora/models/pandora.py
@@ -88,9 +88,23 @@ class PlaylistModel(PandoraModel):
88 """ 88 """
89 audio_url = None 89 audio_url = None
90 url_map = data.get("audioUrlMap") 90 url_map = data.get("audioUrlMap")
91 91 audio_url = data.get("audioUrl")
92
93 # Only an audio URL, not a quality map. This happens for most of the
94 # mobile client tokens and some of the others now. In this case
95 # substitute the empirically determined default values in the format
96 # used by the rest of the function so downstream consumers continue to
97 # work.
98 if audio_url and not url_map:
99 url_map = {
100 BaseAPIClient.HIGH_AUDIO_QUALITY: {
101 "audioUrl": audio_url,
102 "bitrate": 64,
103 "encoding": "aacplus",
104 }
105 }
92 # No audio url available (e.g. ad tokens) 106 # No audio url available (e.g. ad tokens)
93 if not url_map: 107 elif not url_map:
94 return None 108 return None
95 109
96 valid_audio_formats = [BaseAPIClient.HIGH_AUDIO_QUALITY, 110 valid_audio_formats = [BaseAPIClient.HIGH_AUDIO_QUALITY,