Don't try to save the thumbnail if it's None
[youtube-dl] / youtube_dl / YoutubeDL.py
index e2470611512698745181dcf45cebbebc67acdb65..c76f1118ee54e66df89d52e09cc85c80914c5f75 100644 (file)
@@ -529,10 +529,8 @@ class YoutubeDL(object):
                 return
 
         if self.params.get('writethumbnail', False):
-            if 'thumbnail' in info_dict:
-                thumb_format = info_dict['thumbnail'].rpartition(u'/')[2].rpartition(u'.')[2]
-                if not thumb_format:
-                    thumb_format = 'jpg'
+            if info_dict.get('thumbnail') is not None:
+                thumb_format = determine_ext(info_dict['thumbnail'], u'jpg')
                 thumb_filename = filename.rpartition('.')[0] + u'.' + thumb_format
                 self.to_screen(u'[%s] %s: Downloading thumbnail ...' %
                                (info_dict['extractor'], info_dict['id']))