[redditr] Extract all thumbnails
authorozburo <hq@ozburo.com>
Tue, 22 Dec 2020 12:12:14 +0000 (06:12 -0600)
committerSergey M․ <dstftw@gmail.com>
Wed, 30 Dec 2020 22:07:51 +0000 (05:07 +0700)
youtube_dl/extractor/reddit.py

index 3b2abb262838e8c4ee24d9aac1107a74eb31a545..2d1a1fd9963f833d41e949825f3c5bb328dc80cd 100644 (file)
@@ -9,6 +9,7 @@ from ..utils import (
     float_or_none,
     try_get,
     url_or_none,
+    unescapeHTML,
 )
 
 
@@ -118,11 +119,23 @@ class RedditRIE(InfoExtractor):
         else:
             age_limit = None
 
+        thumbnails = []
+        images = try_get(
+            data, lambda x: x['preview']['images'][0]['resolutions']) or []
+        for image in images:
+            url = url_or_none(unescapeHTML(image['url']))
+            if url is not None:
+                thumbnails.append({
+                    'url': url,
+                    'width': int_or_none(image['width']),
+                    'height': int_or_none(image['height']),
+                })
+
         return {
             '_type': 'url_transparent',
             'url': video_url,
             'title': data.get('title'),
-            'thumbnail': url_or_none(data.get('thumbnail')),
+            'thumbnails': thumbnails,
             'timestamp': float_or_none(data.get('created_utc')),
             'uploader': data.get('author'),
             'duration': int_or_none(try_get(