add hydra auth
This commit is contained in:
parent
96d794798f
commit
30666dca52
1 changed files with 29 additions and 0 deletions
29
.config/mpv/scripts/hydra-auth.lua
Normal file
29
.config/mpv/scripts/hydra-auth.lua
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue