[tunein] Fix stream data extraction (Closes #8899, closes #8924)
authorSergey M․ <dstftw@gmail.com>
Wed, 23 Mar 2016 14:45:39 +0000 (20:45 +0600)
committerSergey M․ <dstftw@gmail.com>
Wed, 23 Mar 2016 14:45:39 +0000 (20:45 +0600)
youtube_dl/extractor/tunein.py

index 8322cc14da821f4615a4a8038904039b01c18827..ae4cfaec29b493c3b8b8e11705629901a07a2bf2 100644 (file)
@@ -1,7 +1,7 @@
 # coding: utf-8
 from __future__ import unicode_literals
 
-import json
+import re
 
 from .common import InfoExtractor
 from ..utils import ExtractorError
@@ -27,10 +27,9 @@ class TuneInBaseIE(InfoExtractor):
         if not streams_url.startswith('http://'):
             streams_url = compat_urlparse.urljoin(url, streams_url)
 
-        stream_data = self._download_webpage(
-            streams_url, content_id, note='Downloading stream data')
-        streams = json.loads(self._search_regex(
-            r'\((.*)\);', stream_data, 'stream info'))['Streams']
+        streams = self._download_json(
+            streams_url, content_id, note='Downloading stream data',
+            transform_source=lambda s: re.sub(r'^\s*\((.*)\);\s*$', r'\1', s))['Streams']
 
         is_live = None
         formats = []