mirror of https://github.com/mpv-player/mpv
ytdl_hook: whitelist segmented DASH and HLS for the manifests code
Close #5453
This commit is contained in:
parent
3c1566e736
commit
2a0f9fc158
|
@ -226,10 +226,14 @@ local function has_native_dash_demuxer()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function proto_is_dash(json)
|
local function valid_manifest(json)
|
||||||
local reqfmts = json["requested_formats"]
|
local reqfmt = json["requested_formats"] and json["requested_formats"][1] or {}
|
||||||
return (reqfmts ~= nil and reqfmts[1]["protocol"] == "http_dash_segments")
|
if not reqfmt["manifest_url"] and not json["manifest_url"] then
|
||||||
or json["protocol"] == "http_dash_segments"
|
return false
|
||||||
|
end
|
||||||
|
local proto = reqfmt["protocol"] or json["protocol"] or ""
|
||||||
|
return (has_native_dash_demuxer() and proto == "http_dash_segments") or
|
||||||
|
proto:find("^m3u8")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_single_video(json)
|
local function add_single_video(json)
|
||||||
|
@ -238,9 +242,7 @@ local function add_single_video(json)
|
||||||
local reqfmts = json["requested_formats"]
|
local reqfmts = json["requested_formats"]
|
||||||
|
|
||||||
-- prefer manifest_url if present
|
-- prefer manifest_url if present
|
||||||
if (has_native_dash_demuxer() and proto_is_dash(json)) or
|
if valid_manifest(json) then
|
||||||
(reqfmts and reqfmts[1]["manifest_url"]) or
|
|
||||||
json["manifest_url"] then
|
|
||||||
local mpd_url = reqfmts and reqfmts[1]["manifest_url"] or
|
local mpd_url = reqfmts and reqfmts[1]["manifest_url"] or
|
||||||
json["manifest_url"]
|
json["manifest_url"]
|
||||||
if not mpd_url then
|
if not mpd_url then
|
||||||
|
|
Loading…
Reference in New Issue