mirror of
https://github.com/p-stream/providers.git
synced 2026-01-11 20:10:33 +00:00
new validation method for proxied streams
big brain
This commit is contained in:
parent
244fe261d3
commit
a9f8de06d4
2 changed files with 39 additions and 34 deletions
|
|
@ -4,7 +4,7 @@ import { Stream } from '@/providers/streams';
|
|||
// Default proxy URL for general purpose proxying
|
||||
const DEFAULT_PROXY_URL = 'https://proxy.nsbx.ru/proxy';
|
||||
// Default M3U8 proxy URL for HLS stream proxying
|
||||
let CONFIGURED_M3U8_PROXY_URL = 'https://proxy.fifthwit.net';
|
||||
let CONFIGURED_M3U8_PROXY_URL = 'https://proxy2.pstream.org';
|
||||
|
||||
/**
|
||||
* Set a custom M3U8 proxy URL to use for all M3U8 proxy requests
|
||||
|
|
|
|||
|
|
@ -1,20 +1,6 @@
|
|||
// import { alphaScraper, deltaScraper } from '@/providers/embeds/nsbx';
|
||||
// import { astraScraper, novaScraper, orionScraper } from '@/providers/embeds/whvx';
|
||||
import { cinemaosHexaEmbeds } from '@/providers/embeds/cinemaos';
|
||||
import {
|
||||
streamwishEnglishScraper,
|
||||
streamwishLatinoScraper,
|
||||
streamwishSpanishScraper,
|
||||
} from '@/providers/embeds/streamwish';
|
||||
import { turbovidScraper } from '@/providers/embeds/turbovid';
|
||||
import { vidsrcNovaEmbed } from '@/providers/embeds/vidsrcvip';
|
||||
import { viperScraper } from '@/providers/embeds/viper';
|
||||
import { warezcdnembedMp4Scraper } from '@/providers/embeds/warezcdn/mp4';
|
||||
import { embedsuScraper } from '@/providers/sources/embedsu';
|
||||
import { nepuScraper } from '@/providers/sources/nepu';
|
||||
import { pirxcyScraper } from '@/providers/sources/pirxcy';
|
||||
import { vidsrcScraper } from '@/providers/sources/vidsrc';
|
||||
import { wecimaScraper } from '@/providers/sources/wecima';
|
||||
import { Stream } from '@/providers/streams';
|
||||
import { IndividualEmbedRunnerOptions } from '@/runners/individualRunner';
|
||||
import { ProviderRunnerOptions } from '@/runners/runner';
|
||||
|
|
@ -26,18 +12,6 @@ const SKIP_VALIDATION_CHECK_IDS = [
|
|||
// novaScraper.id,
|
||||
// astraScraper.id,
|
||||
// orionScraper.id,
|
||||
viperScraper.id,
|
||||
streamwishLatinoScraper.id,
|
||||
streamwishSpanishScraper.id,
|
||||
streamwishEnglishScraper.id,
|
||||
embedsuScraper.id,
|
||||
wecimaScraper.id,
|
||||
...cinemaosHexaEmbeds.map((e) => e.id),
|
||||
vidsrcScraper.id,
|
||||
turbovidScraper.id,
|
||||
nepuScraper.id,
|
||||
pirxcyScraper.id,
|
||||
vidsrcNovaEmbed.id,
|
||||
];
|
||||
|
||||
export function isValidStream(stream: Stream | undefined): boolean {
|
||||
|
|
@ -56,6 +30,14 @@ export function isValidStream(stream: Stream | undefined): boolean {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a URL is an M3U8 proxy URL that should be validated with normal fetch
|
||||
* instead of proxiedFetcher
|
||||
*/
|
||||
function isM3U8ProxyUrl(url: string): boolean {
|
||||
return url.includes('/m3u8-proxy?url=');
|
||||
}
|
||||
|
||||
export async function validatePlayableStream(
|
||||
stream: Stream,
|
||||
ops: ProviderRunnerOptions | IndividualEmbedRunnerOptions,
|
||||
|
|
@ -67,13 +49,36 @@ export async function validatePlayableStream(
|
|||
// dirty temp fix for base64 urls to prep for fmhy poll
|
||||
if (stream.playlist.startsWith('data:')) return stream;
|
||||
|
||||
const result = await ops.proxiedFetcher.full(stream.playlist, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
...stream.preferredHeaders,
|
||||
...stream.headers,
|
||||
},
|
||||
});
|
||||
const useNormalFetch = isM3U8ProxyUrl(stream.playlist);
|
||||
|
||||
let result;
|
||||
if (useNormalFetch) {
|
||||
try {
|
||||
const response = await fetch(stream.playlist, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
...stream.preferredHeaders,
|
||||
...stream.headers,
|
||||
},
|
||||
});
|
||||
result = {
|
||||
statusCode: response.status,
|
||||
body: await response.text(),
|
||||
finalUrl: response.url,
|
||||
};
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
result = await ops.proxiedFetcher.full(stream.playlist, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
...stream.preferredHeaders,
|
||||
...stream.headers,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (result.statusCode < 200 || result.statusCode >= 400) return null;
|
||||
return stream;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue