1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-26 18:32:08 +00:00

ytdl_hook: fix safe url checking with EDL urls

This commit is contained in:
Ricardo Constantino 2018-01-26 18:54:17 +00:00
parent f8263e82cc
commit ce42a96533
No known key found for this signature in database
GPG Key ID: EFD16019AE4FF531

View File

@ -264,18 +264,17 @@ local function add_single_video(json)
edl_track = edl_track_joined(track.fragments, edl_track = edl_track_joined(track.fragments,
track.protocol, json.is_live, track.protocol, json.is_live,
track.fragment_base_url) track.fragment_base_url)
local url = edl_track or track.url if not edl_track and not url_is_safe(track.url) then
if not url_is_safe(url) then
return return
end end
if track.acodec and track.acodec ~= "none" then if track.acodec and track.acodec ~= "none" then
-- audio track -- audio track
mp.commandv("audio-add", mp.commandv("audio-add",
url, "auto", edl_track or track.url, "auto",
track.format_note or "") track.format_note or "")
elseif track.vcodec and track.vcodec ~= "none" then elseif track.vcodec and track.vcodec ~= "none" then
-- video track -- video track
streamurl = url streamurl = edl_track or track.url
end end
end end
@ -284,6 +283,9 @@ local function add_single_video(json)
edl_track = edl_track_joined(json.fragments, json.protocol, edl_track = edl_track_joined(json.fragments, json.protocol,
json.is_live, json.fragment_base_url) json.is_live, json.fragment_base_url)
if not edl_track and not url_is_safe(json.url) then
return
end
-- normal video or single track -- normal video or single track
streamurl = edl_track or json.url streamurl = edl_track or json.url
set_http_headers(json.http_headers) set_http_headers(json.http_headers)
@ -294,13 +296,7 @@ local function add_single_video(json)
msg.debug("streamurl: " .. streamurl) msg.debug("streamurl: " .. streamurl)
streamurl = streamurl:gsub("^data:", "data://", 1) mp.set_property("stream-open-filename", streamurl:gsub("^data:", "data://", 1))
if not url_is_safe(streamurl) then
return
end
mp.set_property("stream-open-filename", streamurl)
mp.set_property("file-local-options/force-media-title", json.title) mp.set_property("file-local-options/force-media-title", json.title)
@ -499,6 +495,10 @@ mp.add_hook(o.try_ytdl_first and "on_load" or "on_load_fail", 10, function ()
msg.debug("EDL: " .. playlist) msg.debug("EDL: " .. playlist)
if not playlist then
return
end
-- can't change the http headers for each entry, so use the 1st -- can't change the http headers for each entry, so use the 1st
if json.entries[1] then if json.entries[1] then
set_http_headers(json.entries[1].http_headers) set_http_headers(json.entries[1].http_headers)