From 437f1dc1595a7a0bbb89e94cf26a0ffd4d55c232 Mon Sep 17 00:00:00 2001 From: Andrea Lazzaretti Date: Tue, 13 Apr 2021 00:33:56 +0200 Subject: [PATCH] Trying to add a thumbnail-format feature --- youtube_dl/YoutubeDL.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index eb591f6bc..8a7521f8b 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -2426,17 +2426,11 @@ class YoutubeDL(object): def _write_thumbnails(self, info_dict, filename): 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') - thumbnailformat = try_and_return_int(self.params.get('thumbnailformat', False)) + thumbnailformat = self.params.get('thumbnailformat', False) if thumbnailformat: - if thumbnailformat in range(len(thumbnails)): - thumbnails = [thumbnails[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.'