mirror of
https://github.com/mpv-player/mpv
synced 2025-04-18 21:27:00 +00:00
ytdl: Include Referer header as well
Some videos require correct Referer header for downloading, or 403 Forbidden is thrown.
This commit is contained in:
parent
9628edede0
commit
459b40cc4b
@ -27,9 +27,12 @@ local function set_http_headers(http_headers)
|
|||||||
if useragent and not option_was_set("user-agent") then
|
if useragent and not option_was_set("user-agent") then
|
||||||
mp.set_property("file-local-options/user-agent", useragent)
|
mp.set_property("file-local-options/user-agent", useragent)
|
||||||
end
|
end
|
||||||
local cookies = http_headers["Cookie"]
|
local additional_fields = {"Cookie", "Referer"}
|
||||||
if cookies then
|
for idx, item in pairs(additional_fields) do
|
||||||
headers[#headers + 1] = "Cookie: " .. cookies
|
local field_value = http_headers[item]
|
||||||
|
if field_value then
|
||||||
|
headers[#headers + 1] = item .. ": " .. field_value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if #headers > 0 and not option_was_set("http-header-fields") then
|
if #headers > 0 and not option_was_set("http-header-fields") then
|
||||||
mp.set_property_native("file-local-options/http-header-fields", headers)
|
mp.set_property_native("file-local-options/http-header-fields", headers)
|
||||||
|
Loading…
Reference in New Issue
Block a user