Compare commits

...

7 Commits

Author SHA1 Message Date
andrea-aus-hh
e3eafabb5a
Merge c4b5b8e231 into c5098961b0 2024-08-07 06:19:12 +02:00
Andrea Lazzaretti
c4b5b8e231 Merge branch 'thumbnails-formats-selection' of https://github.com/lazzand/youtube-dl into thumbnails-formats-selection 2021-04-19 14:48:30 +02:00
lazzand
eaea25ca0e Added code corrections to satisfy flake8 reqs :) 2021-04-19 14:47:19 +02:00
lazzand
f582c49019
Added code corrections to satisfy flake8 reqs :) 2021-04-13 14:00:26 +02:00
Andrea Lazzaretti
f4aa8c13b5 Corrected a small error 2021-04-13 13:36:49 +02:00
Andrea Lazzaretti
437f1dc159 Trying to add a thumbnail-format feature 2021-04-13 00:33:56 +02:00
Andrea Lazzaretti
e3d1f76f0e Trying to add a thumbnail-format feature 2021-04-13 00:19:29 +02:00
3 changed files with 17 additions and 1 deletions

View File

@ -214,6 +214,7 @@ class YoutubeDL(object):
writeannotations: Write the video annotations to a .annotations.xml file
writethumbnail: Write the thumbnail image to a file
write_all_thumbnails: Write all thumbnail formats to files
thumbnailformat: Thumbnail format ID
writesubtitles: Write the video subtitles to a file
writeautomaticsub: Write the automatically generated subtitles to a file
allsubtitles: Downloads all the subtitles of the video
@ -2681,7 +2682,17 @@ class YoutubeDL(object):
def _write_thumbnails(self, info_dict, filename):
if self.params.get('writethumbnail', False):
thumbnails = info_dict.get('thumbnails')
thumbnailformat = self.params.get('thumbnailformat', False)
if thumbnails:
if thumbnailformat:
if thumbnailformat in [i.get('id') for i in thumbnails]:
thumbnails = [i for i in thumbnails if i.get('id') == thumbnailformat]
else:
self.report_warning('Thumbnail ID unavailable, falling back to default.'
' Check available thumbnail formats with the option --list-thumbnails'
)
thumbnails = [thumbnails[-1]]
else:
thumbnails = [thumbnails[-1]]
elif self.params.get('write_all_thumbnails', False):
thumbnails = info_dict.get('thumbnails')

View File

@ -373,6 +373,7 @@ def _real_main(argv=None):
'writeannotations': opts.writeannotations,
'writeinfojson': opts.writeinfojson,
'writethumbnail': opts.writethumbnail,
'thumbnailformat': opts.thumbnailformat,
'write_all_thumbnails': opts.write_all_thumbnails,
'writesubtitles': opts.writesubtitles,
'writeautomaticsub': opts.writeautomaticsub,

View File

@ -781,6 +781,10 @@ def parseOpts(overrideArguments=None):
'--write-thumbnail',
action='store_true', dest='writethumbnail', default=False,
help='Write thumbnail image to disk')
thumbnail.add_option(
'--thumbnail-format',
action='store', dest='thumbnailformat', metavar='ID', default=None,
help='Thumbnail format ID')
thumbnail.add_option(
'--write-all-thumbnails',
action='store_true', dest='write_all_thumbnails', default=False,