diff options
author | Christoph Heinrich <christoph.heinrich@student.tugraz.at> | 2023-10-24 01:04:48 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-10-30 16:46:17 +0000 |
commit | 21609953cc9ec839222dfa1568575ce21d99b76a (patch) | |
tree | d13946a1829a56483a537b963c7d2a683fbba394 | |
parent | 045f4a73154b51281cd5cb7e7fc89c677347318e (diff) | |
download | mpv-21609953cc9ec839222dfa1568575ce21d99b76a.tar.bz2 mpv-21609953cc9ec839222dfa1568575ce21d99b76a.tar.xz |
ytdl_hook: support the preference field of thumbnails
yt-dlp has a preference field for it's thumbnails, and not all of it's
listed thumbnails have fields with their dimensions.
Therefore prefere the preference field when available and fall back to
height if it's not.
-rw-r--r-- | player/lua/ytdl_hook.lua | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 00a75d23f2..dd90fc24e4 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -759,6 +759,7 @@ local function add_single_video(json) if (o.thumbnails == 'all' or o.thumbnails == 'best') and not (json.thumbnails == nil) then local thumb = nil local thumb_height = -1 + local thumb_preference = nil for _, thumb_info in ipairs(json.thumbnails) do if not (thumb_info.url == nil) then @@ -766,9 +767,11 @@ local function add_single_video(json) msg.verbose("adding thumbnail") mp.commandv("video-add", thumb_info.url, "auto") thumb_height = 0 - elseif ((thumb_info.height or 0) > thumb_height) then + elseif (thumb_preference ~= nil and thumb_info.preference > thumb_preference) or + (thumb_preference == nil and ((thumb_info.height or 0) > thumb_height)) then thumb = thumb_info.url thumb_height = thumb_info.height or 0 + thumb_preference = thumb_info.preference end end end |