From 3f1e55b7529fdd7e2ac832abf6cadf4cc08e3667 Mon Sep 17 00:00:00 2001 From: Jixun Moe <5713045+jixunmoe@users.noreply.github.com> Date: Mon, 20 Jan 2025 00:00:48 +0000 Subject: [PATCH] [ie/vimeo] update thumbnail extraction logic (#11931) --- yt_dlp/extractor/vimeo.py | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/yt_dlp/extractor/vimeo.py b/yt_dlp/extractor/vimeo.py index 0ed7b9ec1fe4..e667599826d6 100644 --- a/yt_dlp/extractor/vimeo.py +++ b/yt_dlp/extractor/vimeo.py @@ -217,6 +217,22 @@ def _parse_config(self, config, video_id): 'url': thumbnail, }) + # Thumbnails from Embed API + # `width` and `quality` can be customized by adding query string "mw" and "q" respectively. + # Example: "?mw=1080&q=85". + # mw: default to original width + # q: default to 85 + # Also: When request with "Accept: image/avif, image/webp", it will serve AVIF or WebP format. + thumbnail = video_data.get('thumbnail_url') + if thumbnail: + # Fetch the highest quality thumbnail + thumbnail += '?' if '?' not in thumbnail else '&' + thumbnail += 'q=100' + + thumbnails.append({ + 'url': thumbnail, + }) + owner = video_data.get('owner') or {} video_uploader_url = owner.get('url') @@ -388,7 +404,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/businessofsoftware', 'uploader_id': 'businessofsoftware', 'duration': 3610, - 'thumbnail': 'https://i.vimeocdn.com/video/376682406-f34043e7b766af6bef2af81366eacd6724f3fc3173179a11a97a1e26587c9529-d_1280', + 'thumbnail': 'https://i.vimeocdn.com/video/376682406-f34043e7b766af6bef2af81366eacd6724f3fc3173179a11a97a1e26587c9529-d', }, 'params': { 'format': 'best[protocol=https]', @@ -413,7 +429,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'duration': 10, 'comment_count': int, 'like_count': int, - 'thumbnail': 'https://i.vimeocdn.com/video/440665496-b2c5aee2b61089442c794f64113a8e8f7d5763c3e6b3ebfaf696ae6413f8b1f4-d_1280', + 'thumbnail': 'https://i.vimeocdn.com/video/440665496-b2c5aee2b61089442c794f64113a8e8f7d5763c3e6b3ebfaf696ae6413f8b1f4-d', }, 'params': { 'format': 'best[protocol=https]', @@ -437,7 +453,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'timestamp': 1380339469, 'upload_date': '20130928', 'duration': 187, - 'thumbnail': 'https://i.vimeocdn.com/video/450239872-a05512d9b1e55d707a7c04365c10980f327b06d966351bc403a5d5d65c95e572-d_1280', + 'thumbnail': 'https://i.vimeocdn.com/video/450239872-a05512d9b1e55d707a7c04365c10980f327b06d966351bc403a5d5d65c95e572-d', 'view_count': int, 'comment_count': int, 'like_count': int, @@ -463,7 +479,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'duration': 62, 'comment_count': int, 'like_count': int, - 'thumbnail': 'https://i.vimeocdn.com/video/452001751-8216e0571c251a09d7a8387550942d89f7f86f6398f8ed886e639b0dd50d3c90-d_1280', + 'thumbnail': 'https://i.vimeocdn.com/video/452001751-8216e0571c251a09d7a8387550942d89f7f86f6398f8ed886e639b0dd50d3c90-d', 'subtitles': { 'de': 'count:3', 'en': 'count:3', @@ -488,7 +504,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593', 'uploader_id': 'user28849593', 'duration': 118, - 'thumbnail': 'https://i.vimeocdn.com/video/478636036-c18440305ef3df9decfb6bf207a61fe39d2d17fa462a96f6f2d93d30492b037d-d_1280', + 'thumbnail': 'https://i.vimeocdn.com/video/478636036-c18440305ef3df9decfb6bf207a61fe39d2d17fa462a96f6f2d93d30492b037d-d', }, 'expected_warnings': ['Failed to parse XML: not well-formed'], }, @@ -531,7 +547,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'description': 'md5:f2edc61af3ea7a5592681ddbb683db73', 'upload_date': '20200225', 'duration': 176, - 'thumbnail': 'https://i.vimeocdn.com/video/859377297-836494a4ef775e9d4edbace83937d9ad34dc846c688c0c419c0e87f7ab06c4b3-d_1280', + 'thumbnail': 'https://i.vimeocdn.com/video/859377297-836494a4ef775e9d4edbace83937d9ad34dc846c688c0c419c0e87f7ab06c4b3-d', 'uploader_url': 'https://vimeo.com/frameworkla', }, # 'params': {'format': 'source'}, @@ -556,7 +572,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'duration': 321, 'comment_count': int, 'view_count': int, - 'thumbnail': 'https://i.vimeocdn.com/video/22728298-bfc22146f930de7cf497821c7b0b9f168099201ecca39b00b6bd31fcedfca7a6-d_1280', + 'thumbnail': 'https://i.vimeocdn.com/video/22728298-bfc22146f930de7cf497821c7b0b9f168099201ecca39b00b6bd31fcedfca7a6-d', 'like_count': int, 'tags': ['[the shining', 'vimeohq', 'cv', 'vimeo tribute]'], }, @@ -596,7 +612,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'uploader_id': 'user18948128', 'uploader': 'Jaime Marquínez Ferrándiz', 'duration': 10, - 'thumbnail': 'https://i.vimeocdn.com/video/440665496-b2c5aee2b61089442c794f64113a8e8f7d5763c3e6b3ebfaf696ae6413f8b1f4-d_1280', + 'thumbnail': 'https://i.vimeocdn.com/video/440665496-b2c5aee2b61089442c794f64113a8e8f7d5763c3e6b3ebfaf696ae6413f8b1f4-d', }, 'params': { 'format': 'best[protocol=https]', @@ -764,7 +780,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'uploader': 'Alex Howard', 'uploader_id': 'user54729178', 'uploader_url': 'https://vimeo.com/user54729178', - 'thumbnail': r're:https://i\.vimeocdn\.com/video/1520099929-[\da-f]+-d_1280', + 'thumbnail': r're:https://i\.vimeocdn\.com/video/1520099929-[\da-f]+-d', 'duration': 2636, 'chapters': [ {'start_time': 0, 'end_time': 10, 'title': ''}, @@ -824,7 +840,7 @@ class VimeoIE(VimeoBaseInfoExtractor): 'uploader_id': 'rajavirdi', 'uploader_url': 'https://vimeo.com/rajavirdi', 'duration': 309, - 'thumbnail': r're:https://i\.vimeocdn\.com/video/1716727772-[\da-f]+-d_1280', + 'thumbnail': r're:https://i\.vimeocdn\.com/video/1716727772-[\da-f]+-d', }, # 'params': {'format': 'source'}, 'expected_warnings': ['Failed to parse XML: not well-formed'],