add hydra auth

This commit is contained in:
JMARyA 2024-03-09 20:09:50 +01:00
parent 96d794798f
commit 30666dca52
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -0,0 +1,29 @@
local utils = require("mp.utils")
function getKey(table, key)
for _, item in ipairs(table) do
local k, v = item:match("([^=]+)=(.+)")
if k == key then
return v
end
end
return nil -- Key not found
end
function auth()
local url = mp.get_property("stream-open-filename")
if url:find("files.hydrar.de") then
local env = utils.get_env_list()
local auth = getKey(env, "FILES_AUTH")
if auth == nil then
auth = mp.get_opt("FILES_AUTH")
end
if auth ~= nil then
mp.set_property("http-header-fields", "Authorization: Basic " .. auth)
else
print("Authorization value not found.")
end
end
end
mp.register_event("start-file", auth)