mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 23:00:41 +00:00
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.
This commit is contained in:
parent
a3b2d3f930
commit
813dfe1924
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user