aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/yt_data_extract
diff options
context:
space:
mode:
authorAstounds <kirito@disroot.org>2026-03-27 19:22:12 -0500
committerAstounds <kirito@disroot.org>2026-03-27 19:22:12 -0500
commit56ecd6cb1b461bd3622c669936050fa7e4d83542 (patch)
treea67dc3b8dc75ea20a00e25162949626bd1c6f2a8 /youtube/yt_data_extract
parentf629565e77ae7178950fceaac7ba650b97bd4c51 (diff)
downloadyt-local-56ecd6cb1b461bd3622c669936050fa7e4d83542.tar.lz
yt-local-56ecd6cb1b461bd3622c669936050fa7e4d83542.tar.xz
yt-local-56ecd6cb1b461bd3622c669936050fa7e4d83542.zip
fix: use YouTube-provided thumbnail URLs instead of hardcoded hq720.jpg
Videos without hq720.jpg thumbnails caused mass 404 errors. Now preserves the actual thumbnail URL from YouTube's API response, falls back to hqdefault.jpg only when no thumbnail is provided. Also picks highest quality thumbnail from API (thumbnails[-1]) and adds progressive fallback for subscription/download functions.
Diffstat (limited to 'youtube/yt_data_extract')
-rw-r--r--youtube/yt_data_extract/common.py6
-rw-r--r--youtube/yt_data_extract/everything_else.py2
2 files changed, 4 insertions, 4 deletions
diff --git a/youtube/yt_data_extract/common.py b/youtube/yt_data_extract/common.py
index 6a98280..7d44fae 100644
--- a/youtube/yt_data_extract/common.py
+++ b/youtube/yt_data_extract/common.py
@@ -369,9 +369,9 @@ def extract_item_info(item, additional_info={}):
['detailedMetadataSnippets', 0, 'snippetText'],
))
info['thumbnail'] = normalize_url(multi_deep_get(item,
- ['thumbnail', 'thumbnails', 0, 'url'], # videos
- ['thumbnails', 0, 'thumbnails', 0, 'url'], # playlists
- ['thumbnailRenderer', 'showCustomThumbnailRenderer', 'thumbnail', 'thumbnails', 0, 'url'], # shows
+ ['thumbnail', 'thumbnails', -1, 'url'], # videos (highest quality)
+ ['thumbnails', 0, 'thumbnails', -1, 'url'], # playlists
+ ['thumbnailRenderer', 'showCustomThumbnailRenderer', 'thumbnail', 'thumbnails', -1, 'url'], # shows
))
info['badges'] = []
diff --git a/youtube/yt_data_extract/everything_else.py b/youtube/yt_data_extract/everything_else.py
index 1f5b6a2..0f64649 100644
--- a/youtube/yt_data_extract/everything_else.py
+++ b/youtube/yt_data_extract/everything_else.py
@@ -229,7 +229,7 @@ def extract_playlist_metadata(polymer_json):
if metadata['first_video_id'] is None:
metadata['thumbnail'] = None
else:
- metadata['thumbnail'] = f"https://i.ytimg.com/vi/{metadata['first_video_id']}/hq720.jpg"
+ metadata['thumbnail'] = f"https://i.ytimg.com/vi/{metadata['first_video_id']}/hqdefault.jpg"
metadata['video_count'] = extract_int(header.get('numVideosText'))
metadata['description'] = extract_str(header.get('descriptionText'), default='')