diff options
author | Christoph Heinrich <christoph.heinrich@student.tugraz.at> | 2022-07-10 20:07:50 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2022-08-12 14:31:59 +0000 |
commit | 813dfe19242bc7672470077cc37c373f92730e05 (patch) | |
tree | d6f3aa872ad93a69023e91c326e48fc612c16592 /player | |
parent | a3b2d3f9308e763a100d0359749c3691dcb2ab0f (diff) | |
download | mpv-813dfe19242bc7672470077cc37c373f92730e05.tar.bz2 mpv-813dfe19242bc7672470077cc37c373f92730e05.tar.xz |
ytdl_hook: fix default track for single format
Tracks are marked as default tracks based on what yt-dlp/youtube-dl
returns in the field `requested_formats`. The problem is that this field
only exists when there is more then one requested format.
So `ytdl-format=bestvideo+bestaudio` would have that field,
but `ytdl-format=bestaudio` would not,
leading to no tracks being marked as default tracks.
The requested formats can also be found under `requested_downloads`,
which exists regardless of the number of requested formats.
However when there is more then one requested format,
`requested_downloads` doesn't contain those formats directly and instead
has a field `requested_formats` that is identical to the other
`requested_formats`. Therefore use `requested_downloads` as a fallback
for when `requested_formats` doesn't exist.
Diffstat (limited to 'player')
-rw-r--r-- | player/lua/ytdl_hook.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 41fe97bf33..04bb3c30b4 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -390,7 +390,7 @@ local function formats_to_edl(json, formats, use_all_formats) } local default_formats = {} - local requested_formats = json["requested_formats"] + local requested_formats = json["requested_formats"] or json["requested_downloads"] if use_all_formats and requested_formats then for _, track in ipairs(requested_formats) do local id = track["format_id"] @@ -525,7 +525,7 @@ local function add_single_video(json) local streamurl = "" local format_info = "" local max_bitrate = 0 - local requested_formats = json["requested_formats"] + local requested_formats = json["requested_formats"] or json["requested_downloads"] local all_formats = json["formats"] local has_requested_formats = requested_formats and #requested_formats > 0 local http_headers = has_requested_formats |