Skip to content

Commit 06009bf

Browse files
committed
Pass current headers/UA/referrer to mpv instances
Fixes #14
1 parent 430e742 commit 06009bf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/thumbnailer_server.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ function create_thumbnail_mpv(file_path, timestamp, size, output_path, options)
1212
local ytdl_disabled = not options.enable_ytdl and (mp.get_property_native("ytdl") == false
1313
or thumbnailer_options.remote_direct_stream)
1414

15+
local header_fields_arg = nil
16+
local header_fields = mp.get_property_native("http-header-fields")
17+
if #header_fields > 0 then
18+
-- We can't escape the headers, mpv won't parse "--http-header-fields='Name: value'" properly
19+
header_fields_arg = "--http-header-fields=" .. table.concat(header_fields, ",")
20+
end
21+
1522
local profile_arg = nil
1623
if thumbnailer_options.mpv_profile ~= "" then
1724
profile_arg = "--profile=" .. thumbnailer_options.mpv_profile
@@ -26,6 +33,11 @@ function create_thumbnail_mpv(file_path, timestamp, size, output_path, options)
2633

2734
-- Disable ytdl
2835
(ytdl_disabled and "--no-ytdl" or nil),
36+
-- Pass HTTP headers from current instance
37+
header_fields_arg,
38+
-- Pass User-Agent and Referer - should do no harm even with ytdl active
39+
"--user-agent=" .. mp.get_property_native("user-agent"),
40+
"--referrer=" .. mp.get_property_native("referrer"),
2941
-- Disable hardware decoding
3042
"--hwdec=no",
3143

0 commit comments

Comments
 (0)