mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-08-22 22:34:01 -07:00
adds fallback behavior for --write-thumbnail opt
`_write_thumbnails` falls back on lower quality thumbnails as retrieval of higher quality thumbnails fail. assumes thumbnails are sorted from lowest to highest quality before and after commit.
This commit is contained in:
parent
8bf9591a70
commit
38b3978195
1 changed files with 5 additions and 2 deletions
|
@ -2422,10 +2422,11 @@ class YoutubeDL(object):
|
|||
def _write_thumbnails(self, info_dict, filename):
|
||||
if self.params.get('writethumbnail', False):
|
||||
thumbnails = info_dict.get('thumbnails')
|
||||
if thumbnails:
|
||||
thumbnails = [thumbnails[-1]]
|
||||
thumbnails.reverse()
|
||||
getFirst = True
|
||||
elif self.params.get('write_all_thumbnails', False):
|
||||
thumbnails = info_dict.get('thumbnails')
|
||||
getFirst = False
|
||||
else:
|
||||
return
|
||||
|
||||
|
@ -2451,6 +2452,8 @@ class YoutubeDL(object):
|
|||
shutil.copyfileobj(uf, thumbf)
|
||||
self.to_screen('[%s] %s: Writing thumbnail %sto: %s' %
|
||||
(info_dict['extractor'], info_dict['id'], thumb_display_id, thumb_filename))
|
||||
if getFirst:
|
||||
break
|
||||
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
|
||||
self.report_warning('Unable to download thumbnail "%s": %s' %
|
||||
(t['url'], error_to_compat_str(err)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue