diff options
author | Naglis Jonaitis <njonaitis@gmail.com> | 2014-12-01 18:10:04 +0200 |
---|---|---|
committer | Naglis Jonaitis <njonaitis@gmail.com> | 2014-12-01 18:10:15 +0200 |
commit | 1434bffa1ff2fb1e4d80efc900a13a3541923119 (patch) | |
tree | a7109c00ca0dd810c807df0a4b2a72bf2f8e5ebd | |
parent | 94aa25b99541be80a975fd48c07d096fc8c3203c (diff) |
[tunein] Use station API
-rw-r--r-- | youtube_dl/extractor/tunein.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/youtube_dl/extractor/tunein.py b/youtube_dl/extractor/tunein.py index 8c29f1634..4ce5aeeba 100644 --- a/youtube_dl/extractor/tunein.py +++ b/youtube_dl/extractor/tunein.py @@ -19,6 +19,7 @@ class TuneInIE(InfoExtractor): |tun\.in/(?P<redirect_id>[A-Za-z0-9]+) ) ''' + _API_URL_TEMPLATE = 'http://tunein.com/tuner/tune/?stationId={0:}&tuneType=Station' _INFO_DICT = { 'id': '34682', @@ -56,13 +57,10 @@ class TuneInIE(InfoExtractor): mobj = re.match(self._VALID_URL, url) station_id = mobj.group('id') - webpage = self._download_webpage( - url, station_id, note='Downloading station webpage') + station_info = self._download_json( + self._API_URL_TEMPLATE.format(station_id), + station_id, note='Downloading station JSON') - payload = self._html_search_regex( - r'(?m)TuneIn\.payload\s*=\s*(\{[^$]+?)$', webpage, 'JSON data') - json_data = json.loads(payload) - station_info = json_data['Station']['broadcast'] title = station_info['Title'] thumbnail = station_info.get('Logo') location = station_info.get('Location') |