diff options
author | Christoph Heinrich <christoph.heinrich@student.tugraz.at> | 2023-10-24 00:51:29 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-10-30 16:46:17 +0000 |
commit | 045f4a73154b51281cd5cb7e7fc89c677347318e (patch) | |
tree | 91e39834ee2bef8d153de443ceb2c2a9310b8b9b /player/lua/ytdl_hook.lua | |
parent | a5b0eceeba2051d593e0fee46c17c86c4d71a0af (diff) | |
download | mpv-045f4a73154b51281cd5cb7e7fc89c677347318e.tar.bz2 mpv-045f4a73154b51281cd5cb7e7fc89c677347318e.tar.xz |
ytdl_hook: add thumbnail option
Opening speed could be improved with the "async" prefix, but then the
tracks would be out of order.
Diffstat (limited to 'player/lua/ytdl_hook.lua')
-rw-r--r-- | player/lua/ytdl_hook.lua | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 25bc970d66..00a75d23f2 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -8,6 +8,7 @@ local o = { use_manifests = false, all_formats = false, force_all_formats = true, + thumbnails = "none", ytdl_path = "", } @@ -616,7 +617,7 @@ local function formats_to_edl(json, formats, use_all_formats) return res end -local function add_single_video(json, thumbnail, allthumbs) +local function add_single_video(json) local streamurl = "" local format_info = "" local max_bitrate = 0 @@ -755,13 +756,13 @@ local function add_single_video(json, thumbnail, allthumbs) end -- add thumbnails - if (thumbnail == true) and not (json.thumbnails == nil) then + if (o.thumbnails == 'all' or o.thumbnails == 'best') and not (json.thumbnails == nil) then local thumb = nil local thumb_height = -1 for _, thumb_info in ipairs(json.thumbnails) do if not (thumb_info.url == nil) then - if (allthumbs == true) then + if (o.thumbnails == 'all') then msg.verbose("adding thumbnail") mp.commandv("video-add", thumb_info.url, "auto") thumb_height = 0 @@ -885,8 +886,6 @@ function run_ytdl_hook(url) local format = mp.get_property("options/ytdl-format") local raw_options = mp.get_property_native("options/ytdl-raw-options") local allsubs = true - local thumbnail = false - local allthumbs = false local proxy = nil local use_playlist = false @@ -918,11 +917,6 @@ function run_ytdl_hook(url) end if (param == "sub-lang" or param == "sub-langs" or param == "srt-lang") and (arg ~= "") then allsubs = false - elseif (param == "write-thumbnail") then - thumbnail = true - elseif (param == "write-all-thumbnails") then - thumbnail = true - allthumbs = true elseif (param == "proxy") and (arg ~= "") then proxy = arg elseif (param == "yes-playlist") then @@ -1094,7 +1088,7 @@ function run_ytdl_hook(url) elseif self_redirecting_url and #json.entries == 1 then msg.verbose("Playlist with single entry detected.") - add_single_video(json.entries[1], thumbnail, allthumbs) + add_single_video(json.entries[1]) else local playlist_index = parse_yt_playlist(url, json) local playlist = {"#EXTM3U"} @@ -1148,7 +1142,7 @@ function run_ytdl_hook(url) end else -- probably a video - add_single_video(json, thumbnail, allthumbs) + add_single_video(json) end msg.debug('script running time: '..os.clock()-start_time..' seconds') end |