if info_dict['thumbnail'] contains a list of strings instead of a single
string => perform multiple thumbnail download
This commit is contained in:
parent
5700e7792a
commit
bd6c347c85
BIN
youtube-dl
BIN
youtube-dl
Binary file not shown.
@ -898,24 +898,38 @@ class YoutubeDL(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if self.params.get('writethumbnail', False):
|
if self.params.get('writethumbnail', False):
|
||||||
if info_dict.get('thumbnail') is not None:
|
thumblist = info_dict.get('thumbnail')
|
||||||
thumb_format = determine_ext(info_dict['thumbnail'], 'jpg')
|
if thumblist is not None:
|
||||||
thumb_filename = os.path.splitext(filename)[0] + '.' + thumb_format
|
single_thumb = not type(thumblist) is list
|
||||||
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(thumb_filename)):
|
if single_thumb:
|
||||||
self.to_screen('[%s] %s: Thumbnail is already present' %
|
thumblist = [ thumblist ]
|
||||||
(info_dict['extractor'], info_dict['id']))
|
|
||||||
else:
|
else:
|
||||||
self.to_screen('[%s] %s: Downloading thumbnail ...' %
|
digitfmt = '_%%0%sd.' % (len(str(len(thumblist))))
|
||||||
(info_dict['extractor'], info_dict['id']))
|
count = 0
|
||||||
try:
|
|
||||||
uf = compat_urllib_request.urlopen(info_dict['thumbnail'])
|
for fnm in thumblist:
|
||||||
with open(thumb_filename, 'wb') as thumbf:
|
count += 1
|
||||||
shutil.copyfileobj(uf, thumbf)
|
thumb_format = determine_ext(fnm, 'jpg')
|
||||||
self.to_screen('[%s] %s: Writing thumbnail to: %s' %
|
if single_thumb:
|
||||||
(info_dict['extractor'], info_dict['id'], thumb_filename))
|
thumb_filename = os.path.splitext(filename)[0] + '.' + thumb_format
|
||||||
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
else:
|
||||||
self.report_warning('Unable to download thumbnail "%s": %s' %
|
thumb_filename = os.path.splitext(filename)[0] + (digitfmt % count) + thumb_format
|
||||||
(info_dict['thumbnail'], compat_str(err)))
|
|
||||||
|
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(thumb_filename)):
|
||||||
|
self.to_screen('[%s] %s: Thumbnail is already present' %
|
||||||
|
(info_dict['extractor'], info_dict['id']))
|
||||||
|
else:
|
||||||
|
self.to_screen('[%s] %s: Downloading thumbnail ...' %
|
||||||
|
(info_dict['extractor'], info_dict['id']))
|
||||||
|
try:
|
||||||
|
uf = compat_urllib_request.urlopen(fnm)
|
||||||
|
with open(thumb_filename, 'wb') as thumbf:
|
||||||
|
shutil.copyfileobj(uf, thumbf)
|
||||||
|
self.to_screen('[%s] %s: Writing thumbnail to: %s' %
|
||||||
|
(info_dict['extractor'], info_dict['id'], thumb_filename))
|
||||||
|
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
||||||
|
self.report_warning('Unable to download thumbnail "%s": %s' %
|
||||||
|
(fnm, compat_str(err)))
|
||||||
|
|
||||||
if not self.params.get('skip_download', False):
|
if not self.params.get('skip_download', False):
|
||||||
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(filename)):
|
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(filename)):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user