mirror of
https://github.com/p-stream/providers.git
synced 2026-05-11 11:00:54 +00:00
36 lines
917 B
TypeScript
36 lines
917 B
TypeScript
import * as unpacker from 'unpacker';
|
|
|
|
import { flags } from '@/main/targets';
|
|
import { makeEmbed } from '@/providers/base';
|
|
|
|
const packedRegex = /(eval\(function\(p,a,c,k,e,d\).*\)\)\))/;
|
|
const linkRegex = /sources:\[{file:"(.*?)"/;
|
|
|
|
export const upstreamScraper = makeEmbed({
|
|
id: 'upstream',
|
|
name: 'UpStream',
|
|
rank: 199,
|
|
async scrape(ctx) {
|
|
// Example url: https://upstream.to/embed-omscqgn6jc8r.html
|
|
const streamRes = await ctx.proxiedFetcher<string>(ctx.url);
|
|
const packed = streamRes.match(packedRegex);
|
|
|
|
if (packed) {
|
|
const unpacked = unpacker.unpack(packed[1]);
|
|
const link = unpacked.match(linkRegex);
|
|
|
|
if (link) {
|
|
return {
|
|
stream: {
|
|
type: 'hls',
|
|
playlist: link[1],
|
|
flags: [flags.NO_CORS],
|
|
captions: [],
|
|
},
|
|
};
|
|
}
|
|
}
|
|
|
|
throw new Error('upstream source not found');
|
|
},
|
|
});
|