]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[xvideos] Extract all thumbnails (closes #20432)
authorSergey M․ <dstftw@gmail.com>
Sat, 6 Apr 2019 19:58:40 +0000 (02:58 +0700)
committerSergey M․ <dstftw@gmail.com>
Sat, 6 Apr 2019 19:59:09 +0000 (02:59 +0700)
youtube_dl/extractor/xvideos.py

index ec2d913fcadd5cb8e594460a5bf53b2ab5fce562..166bcf44380813e53686724e2ee629a232fcf190 100644 (file)
@@ -57,10 +57,17 @@ class XVideosIE(InfoExtractor):
             webpage, 'title', default=None,
             group='title') or self._og_search_title(webpage)
 
-        thumbnail = self._search_regex(
-            (r'setThumbUrl\(\s*(["\'])(?P<thumbnail>(?:(?!\1).)+)\1',
-             r'url_bigthumb=(?P<thumbnail>.+?)&amp'),
-            webpage, 'thumbnail', fatal=False, group='thumbnail')
+        thumbnails = []
+        for preference, thumbnail in enumerate(('', '169')):
+            thumbnail_url = self._search_regex(
+                r'setThumbUrl%s\(\s*(["\'])(?P<thumbnail>(?:(?!\1).)+)\1' % thumbnail,
+                webpage, 'thumbnail', default=None, group='thumbnail')
+            if thumbnail_url:
+                thumbnails.append({
+                    'url': thumbnail_url,
+                    'preference': preference,
+                })
+
         duration = int_or_none(self._og_search_property(
             'duration', webpage, default=None)) or parse_duration(
             self._search_regex(
@@ -98,6 +105,6 @@ class XVideosIE(InfoExtractor):
             'formats': formats,
             'title': title,
             'duration': duration,
-            'thumbnail': thumbnail,
+            'thumbnails': thumbnails,
             'age_limit': 18,
         }