summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Constantino <wiiaboo@gmail.com>2018-01-27 12:23:03 +0000
committerRicardo Constantino <wiiaboo@gmail.com>2018-01-27 12:24:40 +0000
commit2a0f9fc1588d8bda51a6340197c54285f3f62755 (patch)
tree8b0353e599b8309466e66ac11a6582c9737bd6a2
parent3c1566e736079c968537fe7af0e1e5bbfcd80ec1 (diff)
downloadmpv-2a0f9fc1588d8bda51a6340197c54285f3f62755.tar.bz2
mpv-2a0f9fc1588d8bda51a6340197c54285f3f62755.tar.xz
ytdl_hook: whitelist segmented DASH and HLS for the manifests code
Close #5453
-rw-r--r--player/lua/ytdl_hook.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua
index 959b8179db..18325066d4 100644
--- a/player/lua/ytdl_hook.lua
+++ b/player/lua/ytdl_hook.lua
@@ -226,10 +226,14 @@ local function has_native_dash_demuxer()
return false
end
-local function proto_is_dash(json)
- local reqfmts = json["requested_formats"]
- return (reqfmts ~= nil and reqfmts[1]["protocol"] == "http_dash_segments")
- or json["protocol"] == "http_dash_segments"
+local function valid_manifest(json)
+ local reqfmt = json["requested_formats"] and json["requested_formats"][1] or {}
+ if not reqfmt["manifest_url"] and not json["manifest_url"] then
+ 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
local function add_single_video(json)
@@ -238,9 +242,7 @@ local function add_single_video(json)
local reqfmts = json["requested_formats"]
-- prefer manifest_url if present
- if (has_native_dash_demuxer() and proto_is_dash(json)) or
- (reqfmts and reqfmts[1]["manifest_url"]) or
- json["manifest_url"] then
+ if valid_manifest(json) then
local mpd_url = reqfmts and reqfmts[1]["manifest_url"] or
json["manifest_url"]
if not mpd_url then