diff --git a/.config/mpv/scripts/hydra-auth.lua b/.config/mpv/scripts/hydra-auth.lua new file mode 100644 index 0000000..ac4f0ad --- /dev/null +++ b/.config/mpv/scripts/hydra-auth.lua @@ -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)