diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2016-01-10 20:33:17 +0800 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-01-10 14:30:31 +0100 |
commit | 459b40cc4bfa57befde753d3bf761d98cac3fd42 (patch) | |
tree | 358437c31c187906c8814392e873f98309d96045 /player/lua | |
parent | 9628edede001e7af0dcf487a3d27d909ad4e87e3 (diff) |
ytdl: Include Referer header as well
Some videos require correct Referer header for downloading, or 403
Forbidden is thrown.
Diffstat (limited to 'player/lua')
-rw-r--r-- | player/lua/ytdl_hook.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 010e90c582..5b90b95cdd 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -27,9 +27,12 @@ local function set_http_headers(http_headers) if useragent and not option_was_set("user-agent") then mp.set_property("file-local-options/user-agent", useragent) end - local cookies = http_headers["Cookie"] - if cookies then - headers[#headers + 1] = "Cookie: " .. cookies + local additional_fields = {"Cookie", "Referer"} + for idx, item in pairs(additional_fields) do + local field_value = http_headers[item] + if field_value then + headers[#headers + 1] = item .. ": " .. field_value + end end if #headers > 0 and not option_was_set("http-header-fields") then mp.set_property_native("file-local-options/http-header-fields", headers) |