diff --git a/src/utils/proxy.ts b/src/utils/proxy.ts index 30e0291..2defa8f 100644 --- a/src/utils/proxy.ts +++ b/src/utils/proxy.ts @@ -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; }