]> Raphaƫl G. Git Repositories - youtubedl/blobdiff - youtube_dl/extractor/youporn.py
Merge tag 'upstream/2015.07.21'
[youtubedl] / youtube_dl / extractor / youporn.py
index 8123928be982dbaccb98638ea0b915007ebc7066..4ba7c36db78fb457b63e05fe161a75b00383c78c 100644 (file)
@@ -6,10 +6,11 @@ import re
 import sys
 
 from .common import InfoExtractor
-from ..utils import (
+from ..compat import (
     compat_urllib_parse_urlparse,
     compat_urllib_request,
-
+)
+from ..utils import (
     ExtractorError,
     unescapeHTML,
     unified_strdate,
@@ -45,10 +46,13 @@ class YouPornIE(InfoExtractor):
         age_limit = self._rta_search(webpage)
 
         # Get JSON parameters
-        json_params = self._search_regex(r'var currentVideo = new Video\((.*)\);', webpage, 'JSON parameters')
+        json_params = self._search_regex(
+            [r'videoJa?son\s*=\s*({.+})',
+             r'var\s+currentVideo\s*=\s*new\s+Video\((.+?)\)[,;]'],
+            webpage, 'JSON parameters')
         try:
             params = json.loads(json_params)
-        except:
+        except ValueError:
             raise ExtractorError('Invalid JSON')
 
         self.report_extraction(video_id)