mirror of
https://github.com/p-stream/providers.git
synced 2026-04-21 14:02:16 +00:00
Update valid.ts
This commit is contained in:
parent
3a0bfa2ad4
commit
e822356e46
1 changed files with 21 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
// import { alphaScraper, deltaScraper } from '@/providers/embeds/nsbx';
|
// import { alphaScraper, deltaScraper } from '@/providers/embeds/nsbx';
|
||||||
// import { astraScraper, novaScraper, orionScraper } from '@/providers/embeds/whvx';
|
// import { astraScraper, novaScraper, orionScraper } from '@/providers/embeds/whvx';
|
||||||
|
import { bombtheirishScraper } from '@/providers/archive/sources/bombtheirish';
|
||||||
import { warezcdnembedMp4Scraper } from '@/providers/embeds/warezcdn/mp4';
|
import { warezcdnembedMp4Scraper } from '@/providers/embeds/warezcdn/mp4';
|
||||||
import { Stream } from '@/providers/streams';
|
import { Stream } from '@/providers/streams';
|
||||||
import { IndividualEmbedRunnerOptions } from '@/runners/individualRunner';
|
import { IndividualEmbedRunnerOptions } from '@/runners/individualRunner';
|
||||||
|
|
@ -14,6 +15,11 @@ const SKIP_VALIDATION_CHECK_IDS = [
|
||||||
// orionScraper.id,
|
// orionScraper.id,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const UNPROXIED_VALIDATION_CHECK_IDS = [
|
||||||
|
// sources here are always proxied, so we dont need to validate with a proxy
|
||||||
|
bombtheirishScraper.id, // this one is dead, but i'll keep it here for now
|
||||||
|
];
|
||||||
|
|
||||||
export function isValidStream(stream: Stream | undefined): boolean {
|
export function isValidStream(stream: Stream | undefined): boolean {
|
||||||
if (!stream) return false;
|
if (!stream) return false;
|
||||||
if (stream.type === 'hls') {
|
if (stream.type === 'hls') {
|
||||||
|
|
@ -45,11 +51,13 @@ export async function validatePlayableStream(
|
||||||
): Promise<Stream | null> {
|
): Promise<Stream | null> {
|
||||||
if (SKIP_VALIDATION_CHECK_IDS.includes(sourcererId)) return stream;
|
if (SKIP_VALIDATION_CHECK_IDS.includes(sourcererId)) return stream;
|
||||||
|
|
||||||
|
const alwaysUseNormalFetch = UNPROXIED_VALIDATION_CHECK_IDS.includes(sourcererId);
|
||||||
|
|
||||||
if (stream.type === 'hls') {
|
if (stream.type === 'hls') {
|
||||||
// dirty temp fix for base64 urls to prep for fmhy poll
|
// dirty temp fix for base64 urls to prep for fmhy poll
|
||||||
if (stream.playlist.startsWith('data:')) return stream;
|
if (stream.playlist.startsWith('data:')) return stream;
|
||||||
|
|
||||||
const useNormalFetch = isAlreadyProxyUrl(stream.playlist);
|
const useNormalFetch = alwaysUseNormalFetch || isAlreadyProxyUrl(stream.playlist);
|
||||||
|
|
||||||
let result;
|
let result;
|
||||||
if (useNormalFetch) {
|
if (useNormalFetch) {
|
||||||
|
|
@ -82,10 +90,11 @@ export async function validatePlayableStream(
|
||||||
if (result.statusCode < 200 || result.statusCode >= 400) return null;
|
if (result.statusCode < 200 || result.statusCode >= 400) return null;
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream.type === 'file') {
|
if (stream.type === 'file') {
|
||||||
const validQualitiesResults = await Promise.all(
|
const validQualitiesResults = await Promise.all(
|
||||||
Object.values(stream.qualities).map(async (quality) => {
|
Object.values(stream.qualities).map(async (quality) => {
|
||||||
const useNormalFetch = isAlreadyProxyUrl(quality.url);
|
const useNormalFetch = alwaysUseNormalFetch || isAlreadyProxyUrl(quality.url);
|
||||||
|
|
||||||
if (useNormalFetch) {
|
if (useNormalFetch) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -105,16 +114,16 @@ export async function validatePlayableStream(
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { statusCode: 500, body: '', finalUrl: quality.url };
|
return { statusCode: 500, body: '', finalUrl: quality.url };
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return ops.proxiedFetcher.full(quality.url, {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
...stream.preferredHeaders,
|
|
||||||
...stream.headers,
|
|
||||||
Range: 'bytes=0-1',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ops.proxiedFetcher.full(quality.url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
...stream.preferredHeaders,
|
||||||
|
...stream.headers,
|
||||||
|
Range: 'bytes=0-1',
|
||||||
|
},
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// remove invalid qualities from the stream
|
// remove invalid qualities from the stream
|
||||||
|
|
@ -128,6 +137,7 @@ export async function validatePlayableStream(
|
||||||
if (Object.keys(validQualities).length === 0) return null;
|
if (Object.keys(validQualities).length === 0) return null;
|
||||||
return { ...stream, qualities: validQualities };
|
return { ...stream, qualities: validQualities };
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue