mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-01-03 14:47:58 +00:00
Trying to add a thumbnail-format feature
This commit is contained in:
parent
e3d1f76f0e
commit
437f1dc159
1 changed files with 3 additions and 9 deletions
|
@ -2426,17 +2426,11 @@ class YoutubeDL(object):
|
||||||
|
|
||||||
def _write_thumbnails(self, info_dict, filename):
|
def _write_thumbnails(self, info_dict, filename):
|
||||||
if self.params.get('writethumbnail', False):
|
if self.params.get('writethumbnail', False):
|
||||||
def try_and_return_int(s):
|
|
||||||
try:
|
|
||||||
int(s)
|
|
||||||
return int(s)
|
|
||||||
except ValueError:
|
|
||||||
return -1
|
|
||||||
thumbnails = info_dict.get('thumbnails')
|
thumbnails = info_dict.get('thumbnails')
|
||||||
thumbnailformat = try_and_return_int(self.params.get('thumbnailformat', False))
|
thumbnailformat = self.params.get('thumbnailformat', False)
|
||||||
if thumbnailformat:
|
if thumbnailformat:
|
||||||
if thumbnailformat in range(len(thumbnails)):
|
if thumbnailformat in [i.get('id') for i in thumbnails]:
|
||||||
thumbnails = [thumbnails[thumbnailformat]]
|
thumbnails = [i for i in thumbnails if i.get('id')==thumbnailformat]
|
||||||
else:
|
else:
|
||||||
self.report_warning(
|
self.report_warning(
|
||||||
'Thumbnail ID unavailable, falling back to default.'
|
'Thumbnail ID unavailable, falling back to default.'
|
||||||
|
|
Loading…
Reference in a new issue