added upstream embed provider

This commit is contained in:
Jonathan Barrow
2023-09-28 15:27:11 -04:00
parent 2ab8042317
commit 39c5de3fee
4 changed files with 48 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ import { Embed, Sourcerer } from '@/providers/base';
import { mp4uploadScraper } from '@/providers/embeds/mp4upload';
import { streamsbScraper } from '@/providers/embeds/streamsb';
import { upcloudScraper } from '@/providers/embeds/upcloud';
import { upstreamScraper } from '@/providers/embeds/upstream';
import { flixhqScraper } from '@/providers/sources/flixhq/index';
import { goMoviesScraper } from '@/providers/sources/gomovies/index';
import { kissAsianScraper } from '@/providers/sources/kissasian/index';
@@ -15,5 +16,5 @@ export function gatherAllSources(): Array<Sourcerer> {
export function gatherAllEmbeds(): Array<Embed> {
// all embeds are gathered here
return [upcloudScraper, mp4uploadScraper, streamsbScraper];
return [upcloudScraper, mp4uploadScraper, streamsbScraper, upstreamScraper];
}

View File

@@ -0,0 +1,35 @@
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],
},
};
}
}
throw new Error('upstream source not found');
},
});