From f4aa8c13b549069d14bf6139dcc831e6cd9125c4 Mon Sep 17 00:00:00 2001 From: Andrea Lazzaretti Date: Tue, 13 Apr 2021 13:36:49 +0200 Subject: [PATCH] Corrected a small error --- youtube_dl/YoutubeDL.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 8a7521f8b..0ba40684c 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -2428,17 +2428,18 @@ class YoutubeDL(object): if self.params.get('writethumbnail', False): thumbnails = info_dict.get('thumbnails') thumbnailformat = self.params.get('thumbnailformat', False) - if thumbnailformat: - if thumbnailformat in [i.get('id') for i in thumbnails]: - thumbnails = [i for i in thumbnails if i.get('id')==thumbnailformat] + 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: - 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') else: