mirror of
https://github.com/p-stream/providers.git
synced 2026-04-21 05:32:23 +00:00
Update proxy again
This commit is contained in:
parent
88141f74ec
commit
62a257165c
1 changed files with 5 additions and 7 deletions
|
|
@ -2,29 +2,27 @@ import { flags } from '@/entrypoint/utils/targets';
|
|||
import { Stream } from '@/providers/streams';
|
||||
|
||||
export function requiresProxy(stream: Stream): boolean {
|
||||
if (!stream.flags.includes('cors-allowed') && !!(stream.headers && Object.keys(stream.headers).length > 0))
|
||||
if (!stream.flags.includes(flags.CORS_ALLOWED) && !!(stream.headers && Object.keys(stream.headers).length > 0))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function setupProxy(stream: Stream): Stream {
|
||||
const headers =
|
||||
stream.headers && Object.keys(stream.headers).length > 0
|
||||
? encodeURIComponent(JSON.stringify(stream.headers))
|
||||
: null;
|
||||
stream.headers && Object.keys(stream.headers).length > 0 ? btoa(JSON.stringify(stream.headers)) : null;
|
||||
|
||||
const options = encodeURIComponent(
|
||||
const options = btoa(
|
||||
JSON.stringify({
|
||||
...(stream.type === 'hls' && { depth: stream.proxyDepth ?? 0 }),
|
||||
}),
|
||||
);
|
||||
|
||||
if (stream.type === 'hls')
|
||||
stream.playlist = `https://proxy.nsbx.ru/hls/${encodeURIComponent(stream.playlist)}/${headers}/${options}`;
|
||||
stream.playlist = `https://proxy.nsbx.ru/hls/${btoa(stream.playlist)}/${headers}/${options}`;
|
||||
|
||||
if (stream.type === 'file')
|
||||
Object.entries(stream.qualities).forEach((entry) => {
|
||||
entry[1].url = `https://proxy.nsbx.ru/mp4/${encodeURIComponent(entry[1].url)}/${headers}/${options}`;
|
||||
entry[1].url = `https://proxy.nsbx.ru/mp4/${btoa(entry[1].url)}/${headers}/${options}`;
|
||||
});
|
||||
|
||||
stream.headers = {};
|
||||
|
|
|
|||
Loading…
Reference in a new issue