aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbashonly <bashonly@protonmail.com>2024-11-14 16:08:50 -0600
committerbashonly <88596187+bashonly@users.noreply.github.com>2024-11-15 22:51:55 +0000
commiteb64ae7d5def6df2aba74fb703e7f168fb299865 (patch)
treeda3affa7fd7fb3485b0c47bdec24674b204c3636
parentc014fbcddcb4c8f79d914ac5bb526758b540ea33 (diff)
[ie] Allow `ext` override for thumbnails (#11545)
Authored by: bashonly
-rw-r--r--yt_dlp/YoutubeDL.py4
-rw-r--r--yt_dlp/extractor/common.py1
2 files changed, 4 insertions, 1 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 3186a999d..3130deda3 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -4381,7 +4381,9 @@ class YoutubeDL:
return None
for idx, t in list(enumerate(thumbnails))[::-1]:
- thumb_ext = (f'{t["id"]}.' if multiple else '') + determine_ext(t['url'], 'jpg')
+ thumb_ext = t.get('ext') or determine_ext(t['url'], 'jpg')
+ if multiple:
+ thumb_ext = f'{t["id"]}.{thumb_ext}'
thumb_display_id = f'{label} thumbnail {t["id"]}'
thumb_filename = replace_extension(filename, thumb_ext, info_dict.get('ext'))
thumb_filename_final = replace_extension(thumb_filename_base, thumb_ext, info_dict.get('ext'))
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py
index 01915acf2..23f6fc6c4 100644
--- a/yt_dlp/extractor/common.py
+++ b/yt_dlp/extractor/common.py
@@ -279,6 +279,7 @@ class InfoExtractor:
thumbnails: A list of dictionaries, with the following entries:
* "id" (optional, string) - Thumbnail format ID
* "url"
+ * "ext" (optional, string) - actual image extension if not given in URL
* "preference" (optional, int) - quality of the image
* "width" (optional, int)
* "height" (optional, int)