]> Raphaƫl G. Git Repositories - youtubedl/blobdiff - youtube_dl/extractor/youporn.py
Initiate new release.
[youtubedl] / youtube_dl / extractor / youporn.py
index 7bfda45e76e0d4ca3b6bfd6c3a8ec9f38de453e1..4ba7c36db78fb457b63e05fe161a75b00383c78c 100644 (file)
@@ -6,10 +6,11 @@ import re
 import sys
 
 from .common import InfoExtractor
 import sys
 
 from .common import InfoExtractor
-from ..utils import (
+from ..compat import (
     compat_urllib_parse_urlparse,
     compat_urllib_request,
     compat_urllib_parse_urlparse,
     compat_urllib_request,
-
+)
+from ..utils import (
     ExtractorError,
     unescapeHTML,
     unified_strdate,
     ExtractorError,
     unescapeHTML,
     unified_strdate,
@@ -45,11 +46,14 @@ class YouPornIE(InfoExtractor):
         age_limit = self._rta_search(webpage)
 
         # Get JSON parameters
         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)
         try:
             params = json.loads(json_params)
-        except:
-            raise ExtractorError(u'Invalid JSON')
+        except ValueError:
+            raise ExtractorError('Invalid JSON')
 
         self.report_extraction(video_id)
         try:
 
         self.report_extraction(video_id)
         try:
@@ -64,7 +68,7 @@ class YouPornIE(InfoExtractor):
         # Get all of the links from the page
         DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
         download_list_html = self._search_regex(DOWNLOAD_LIST_RE,
         # Get all of the links from the page
         DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
         download_list_html = self._search_regex(DOWNLOAD_LIST_RE,
-            webpage, 'download list').strip()
+                                                webpage, 'download list').strip()
         LINK_RE = r'<a href="([^"]+)">'
         links = re.findall(LINK_RE, download_list_html)
 
         LINK_RE = r'<a href="([^"]+)">'
         links = re.findall(LINK_RE, download_list_html)
 
@@ -73,7 +77,7 @@ class YouPornIE(InfoExtractor):
         for encrypted_link in encrypted_links:
             link = aes_decrypt_text(encrypted_link, video_title, 32).decode('utf-8')
             links.append(link)
         for encrypted_link in encrypted_links:
             link = aes_decrypt_text(encrypted_link, video_title, 32).decode('utf-8')
             links.append(link)
-        
+
         formats = []
         for link in links:
             # A link looks like this:
         formats = []
         for link in links:
             # A link looks like this:
@@ -103,8 +107,8 @@ class YouPornIE(InfoExtractor):
         self._sort_formats(formats)
 
         if not formats:
         self._sort_formats(formats)
 
         if not formats:
-            raise ExtractorError(u'ERROR: no known formats available for video')
-        
+            raise ExtractorError('ERROR: no known formats available for video')
+
         return {
             'id': video_id,
             'uploader': video_uploader,
         return {
             'id': video_id,
             'uploader': video_uploader,