diff options
author | wm4 <wm4@nowhere> | 2020-02-21 14:18:35 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-02-21 14:18:35 +0100 |
commit | 4c32468241fbc6b6a6837c4030532bd9363b7441 (patch) | |
tree | 37fd2b3f588cab527d2f8ff76c84600455860f92 /player/lua | |
parent | a77780e6be2760d2deeaef316516b943ea29f1bc (diff) | |
download | mpv-4c32468241fbc6b6a6837c4030532bd9363b7441.tar.bz2 mpv-4c32468241fbc6b6a6837c4030532bd9363b7441.tar.xz |
ytdl_hook: enable default selection via --ytdl-format with all_formats
In all_formats mode, we've ignored what --ytdl-format did so far, since
we've converted the full format list, instead of just the formats
selected by youtube-dl.
But we can easily restore --ytdl-format behavior: just mark the selected
tracks as default tracks.
Diffstat (limited to 'player/lua')
-rw-r--r-- | player/lua/ytdl_hook.lua | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 5cf64849b8..cb1544b38d 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -25,6 +25,14 @@ function Set (t) return set end +-- ?: surrogate (keep in mind that there is no lazy evaluation) +function iif(cond, if_true, if_false) + if cond then + return if_true + end + return if_false +end + local safe_protos = Set { "http", "https", "ftp", "ftps", "rtmp", "rtmps", "rtmpe", "rtmpt", "rtmpts", "rtmpte", @@ -340,6 +348,17 @@ local function formats_to_edl(json, formats, use_all_formats) muxed_needed = false, } + local default_formats = {} + local requested_formats = json["requested_formats"] + if use_all_formats and requested_formats then + for _, track in ipairs(requested_formats) do + local id = track["format_id"] + if id then + default_formats[id] = true + end + end + end + local duration = as_integer(json["duration"]) local single_url = nil local streams = {} @@ -414,8 +433,13 @@ local function formats_to_edl(json, formats, use_all_formats) end title = title .. "muxed-" .. index end + local flags = {} + if default_formats[track["format_id"]] then + flags[#flags + 1] = "default" + end hdr[#hdr + 1] = "!track_meta,title=" .. - edl_escape(title) .. ",byterate=" .. byterate + edl_escape(title) .. ",byterate=" .. byterate .. + iif(#flags > 0, ",flags=" .. table.concat(flags, "+"), "") end if duration > 0 then |