[pornhd] Adapt to new sources scheme (Fixes #4446)
authorPhilipp Hagemeister <phihag@phihag.de>
Thu, 11 Dec 2014 22:50:25 +0000 (23:50 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Thu, 11 Dec 2014 22:50:25 +0000 (23:50 +0100)
youtube_dl/extractor/pornhd.py

index bac484c67dbb01bbafa319c117b7c6d152b7dd5d..63472b33e9e740bf06175fac4ec8988884f0bfa1 100644 (file)
@@ -45,13 +45,18 @@ class PornHdIE(InfoExtractor):
         thumbnail = self._search_regex(
             r"'poster'\s*:\s*'([^']+)'", webpage, 'thumbnail', fatal=False)
 
-        quality = qualities(['SD', 'HD'])
-        formats = [{
-            'url': source['file'],
-            'format_id': '%s-%s' % (source['label'], determine_ext(source['file'])),
-            'quality': quality(source['label']),
-        } for source in json.loads(js_to_json(self._search_regex(
-            r"(?s)'sources'\s*:\s*(\[.+?\])", webpage, 'sources')))]
+        quality = qualities(['sd', 'hd'])
+        sources = json.loads(js_to_json(self._search_regex(
+            r"(?s)'sources'\s*:\s*(\{.+?\})\s*\}\);", webpage, 'sources')))
+        formats = []
+        for container, s in sources.items():
+            for qname, video_url in s.items():
+                formats.append({
+                    'url': video_url,
+                    'container': container,
+                    'format_id': '%s-%s' % (container, qname),
+                    'quality': quality(qname),
+                })
         self._sort_formats(formats)
 
         return {