Complete setup proxy function

This commit is contained in:
TPN 2024-07-01 07:31:27 +01:00
parent 0f95ed0b20
commit 78dbbf7520
No known key found for this signature in database
GPG key ID: 40AE091637892B91

View file

@ -8,9 +8,20 @@ export function requiresProxy(stream: Stream): boolean {
}
export function setupProxy(stream: Stream): Stream {
// todo
const headers =
stream.headers && Object.keys(stream.headers).length > 0
? encodeURIComponent(JSON.stringify(stream.headers))
: null;
// stream.headers = {};
if (stream.type === 'hls')
stream.playlist = `https://busty.prawnhub.ru/proxy/${encodeURIComponent(stream.playlist)}/${headers}`;
if (stream.type === 'file')
Object.entries(stream.qualities).forEach((entry) => {
entry[1].url = `https://mp4proxy.nsbxru.workers.dev/proxy/${encodeURIComponent(entry[1].url)}/${headers}`;
});
stream.headers = {};
stream.flags = [flags.CORS_ALLOWED];
return stream;
}