From 9f8b88ac15aed5f4aea10b203f01a5bd951f4516 Mon Sep 17 00:00:00 2001 From: MikeCol Date: Tue, 28 Jan 2014 17:10:56 +0100 Subject: [PATCH] Retrieve the URLs of all availale thumbnails --- youtube_dl/extractor/tumblr.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/tumblr.py b/youtube_dl/extractor/tumblr.py index 544369068..6ddbbe05d 100644 --- a/youtube_dl/extractor/tumblr.py +++ b/youtube_dl/extractor/tumblr.py @@ -34,11 +34,19 @@ class TumblrIE(InfoExtractor): video_url = video.group('video_url') ext = video.group('ext') - video_thumbnail = self._search_regex( - r'posters.*?\[\\x22(.*?)\\x22', - webpage, 'thumbnail', fatal=False) # We pick the first poster - if video_thumbnail: - video_thumbnail = video_thumbnail.replace('\\\\/', '/') + # retrieve all available thumbnails + thumb_list = [] + ma = re.search(r'posters.*?\[(?P\\x22.*?\\x22)]', webpage) + if not ma is None: + for t in ma.group('thumb').replace('\\\\/', '/').split(','): + t = t.replace('\\x22','"') + if (t[0]=='"') and (t[-1]=='"'): + thumb_list.append(t[1:-1]) + + # take the first, if user only wants one + single_thumb = None + if len(thumb_list)>0: + single_thumb = thumb_list[0] # The only place where you can get a title, it's not complete, # but searching in other places doesn't work for all videos @@ -48,6 +56,7 @@ class TumblrIE(InfoExtractor): return [{'id': video_id, 'url': video_url, 'title': video_title, - 'thumbnail': video_thumbnail, + 'thumbnails': thumb_list, + 'thumbnail': single_thumb, 'ext': ext }]