YoutubeIE: extract the thumbnail in the best possible quality
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 7 Jul 2013 19:21:15 +0000 (21:21 +0200)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 7 Jul 2013 19:21:15 +0000 (21:21 +0200)
youtube_dl/extractor/youtube.py

index 7a2a8a4f811bb574ab419db26c5cc13e08d16cab..e2296d153c7dbd473daf7154cbff7550f3841e76 100644 (file)
@@ -473,7 +473,12 @@ class YoutubeIE(InfoExtractor):
         video_title = compat_urllib_parse.unquote_plus(video_info['title'][0])
 
         # thumbnail image
-        if 'thumbnail_url' not in video_info:
+        # We try first to get a high quality image:
+        m_thumb = re.search(r'<span itemprop="thumbnail".*?href="(.*?)">',
+                            video_webpage, re.DOTALL)
+        if m_thumb is not None:
+            video_thumbnail = m_thumb.group(1)
+        elif 'thumbnail_url' not in video_info:
             self._downloader.report_warning(u'unable to extract video thumbnail')
             video_thumbnail = ''
         else:   # don't panic if we can't find it