Use determine_ext when saving the thumbnail
Urls that contain a query produced filenames with wrong extensionsmain
parent
6543f0dca5
commit
cbdbb76665
|
@ -530,9 +530,7 @@ class YoutubeDL(object):
|
||||||
|
|
||||||
if self.params.get('writethumbnail', False):
|
if self.params.get('writethumbnail', False):
|
||||||
if 'thumbnail' in info_dict:
|
if 'thumbnail' in info_dict:
|
||||||
thumb_format = info_dict['thumbnail'].rpartition(u'/')[2].rpartition(u'.')[2]
|
thumb_format = determine_ext(info_dict['thumbnail'], u'jpg')
|
||||||
if not thumb_format:
|
|
||||||
thumb_format = 'jpg'
|
|
||||||
thumb_filename = filename.rpartition('.')[0] + u'.' + thumb_format
|
thumb_filename = filename.rpartition('.')[0] + u'.' + thumb_format
|
||||||
self.to_screen(u'[%s] %s: Downloading thumbnail ...' %
|
self.to_screen(u'[%s] %s: Downloading thumbnail ...' %
|
||||||
(info_dict['extractor'], info_dict['id']))
|
(info_dict['extractor'], info_dict['id']))
|
||||||
|
|
|
@ -650,12 +650,12 @@ def unified_strdate(date_str):
|
||||||
pass
|
pass
|
||||||
return upload_date
|
return upload_date
|
||||||
|
|
||||||
def determine_ext(url):
|
def determine_ext(url, default_ext=u'unknown_video'):
|
||||||
guess = url.partition(u'?')[0].rpartition(u'.')[2]
|
guess = url.partition(u'?')[0].rpartition(u'.')[2]
|
||||||
if re.match(r'^[A-Za-z0-9]+$', guess):
|
if re.match(r'^[A-Za-z0-9]+$', guess):
|
||||||
return guess
|
return guess
|
||||||
else:
|
else:
|
||||||
return u'unknown_video'
|
return default_ext
|
||||||
|
|
||||||
def date_from_str(date_str):
|
def date_from_str(date_str):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue