add support for an external videoplayback proxy
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 21s

This commit is contained in:
Fijxu 2024-12-14 03:17:34 -03:00
parent 687567a09e
commit 428db0810f
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
5 changed files with 20 additions and 3 deletions

View file

@ -1,7 +1,7 @@
[server]
port = 8282
host = "127.0.0.1"
secret_key = "CHANGE_ME"
secret_key = "myBeautifulKey"
base_url = "http://localhost:8282"
verify_requests = false
@ -15,6 +15,8 @@ directory = "/var/tmp"
#proxy = ""
# Enable YouTube new video format UMP
ump = false
# Some external videoplayback
# external_videoplayback_proxy = ""
[jobs]

View file

@ -13,6 +13,7 @@
"npm:@willsoto/node-konfig-file@3.0.0": "3.0.0_@willsoto+node-konfig-core@5.0.0",
"npm:@willsoto/node-konfig-toml-parser@3.0.0": "3.0.0_@willsoto+node-konfig-core@5.0.0",
"npm:acorn@^8.8.0": "8.14.0",
"npm:googlevideo@2.0.0": "2.0.0",
"npm:jsdom@25.0.1": "25.0.1"
},
"jsr": {
@ -40,6 +41,9 @@
}
},
"npm": {
"@bufbuild/protobuf@2.2.3": {
"integrity": "sha512-tFQoXHJdkEOSwj5tRIZSPNUuXK3RaR7T1nUrPgbYX1pUbvqqaaZAsfo+NXBPsz5rZMSKVFrgK1WL8Q/MSLvprg=="
},
"@types/estree@1.0.6": {
"integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw=="
},
@ -123,6 +127,12 @@
"mime-types"
]
},
"googlevideo@2.0.0": {
"integrity": "sha512-OVlNWZ07TPIelaEII6mH9od+Cxljl7P4AzhEYVNN5d4FhFT9L5otpcLtgvraTE9u69KfVVw+L4pVeczArcD33w==",
"dependencies": [
"@bufbuild/protobuf"
]
},
"html-encoding-sniffer@4.0.0": {
"integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==",
"dependencies": [

View file

@ -114,6 +114,8 @@ export const youtubePlayerParsing = async (
invidiousCompanion: {
"baseUrl": Deno.env.get("SERVER_BASE_URL") ||
konfigStore.get("server.base_url") as string,
"external_videoplayback_proxy": Deno.env.get("EXTERNAL_VIDEOPLAYBACK_PROXY") ||
konfigStore.get("networking.external_videoplayback_proxy") as string,
},
}))(videoData);

View file

@ -91,11 +91,12 @@ dashManifest.get("/:videoId", async (c) => {
let dashUrl = url;
if (local) {
// Can't create URL type without host part
dashUrl = (dashUrl.pathname + dashUrl.search + "&host=" +
dashUrl = (konfigStore.get("networking.external_videoplayback_proxy") as string ?? "") + (dashUrl.pathname + dashUrl.search + "&host=" +
dashUrl.host) as unknown as URL;
if (konfigStore.get("networking.ump") as boolean) {
dashUrl = dashUrl + "&ump=1" as unknown as URL;
}
console.log(dashUrl)
return dashUrl;
} else {
return dashUrl;

View file

@ -69,9 +69,11 @@ latestVersion.get("/", async (c) => {
} else if (selectedItagFormat) {
const itagUrl = selectedItagFormat[0].url as string;
const itagUrlParsed = new URL(itagUrl);
console.log(itagUrlParsed)
let urlToRedirect = itagUrlParsed.toString();
if (local) {
urlToRedirect = itagUrlParsed.pathname + urlToRedirect.search +
urlToRedirect = konfigStore.get("networking.external_videoplayback_proxy") as string ?? "" +
itagUrlParsed.pathname + urlToRedirect.search +
"&host=" + itagUrlParsed.host;
}
return c.redirect(urlToRedirect);