Skip to content

Commit

Permalink
Pass current headers/UA/referrer to mpv instances
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
TheAMM committed Feb 7, 2018
1 parent 430e742 commit 06009bf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/thumbnailer_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ function create_thumbnail_mpv(file_path, timestamp, size, output_path, options)
local ytdl_disabled = not options.enable_ytdl and (mp.get_property_native("ytdl") == false
or thumbnailer_options.remote_direct_stream)

local header_fields_arg = nil
local header_fields = mp.get_property_native("http-header-fields")
if #header_fields > 0 then
-- We can't escape the headers, mpv won't parse "--http-header-fields='Name: value'" properly
header_fields_arg = "--http-header-fields=" .. table.concat(header_fields, ",")
end

local profile_arg = nil
if thumbnailer_options.mpv_profile ~= "" then
profile_arg = "--profile=" .. thumbnailer_options.mpv_profile
Expand All @@ -26,6 +33,11 @@ function create_thumbnail_mpv(file_path, timestamp, size, output_path, options)

-- Disable ytdl
(ytdl_disabled and "--no-ytdl" or nil),
-- Pass HTTP headers from current instance
header_fields_arg,
-- Pass User-Agent and Referer - should do no harm even with ytdl active
"--user-agent=" .. mp.get_property_native("user-agent"),
"--referrer=" .. mp.get_property_native("referrer"),
-- Disable hardware decoding
"--hwdec=no",

Expand Down

0 comments on commit 06009bf

Please sign in to comment.