Merge pull request #3 from ztpn/autoembed

Add Autoembed source and split its languages into embeds
This commit is contained in:
Paradox 2024-06-12 23:56:01 +05:30 committed by GitHub
commit d096bfadf1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 113 additions and 0 deletions

View file

@ -12,6 +12,7 @@ import { upcloudScraper } from '@/providers/embeds/upcloud';
import { upstreamScraper } from '@/providers/embeds/upstream';
import { vidsrcembedScraper } from '@/providers/embeds/vidsrc';
import { vTubeScraper } from '@/providers/embeds/vtube';
import { autoembedScraper } from '@/providers/sources/autoembed';
import { flixhqScraper } from '@/providers/sources/flixhq/index';
import { goMoviesScraper } from '@/providers/sources/gomovies/index';
import { insertunitScraper } from '@/providers/sources/insertunit';
@ -24,6 +25,13 @@ import { tugaflixScraper } from '@/providers/sources/tugaflix';
import { vidsrcScraper } from '@/providers/sources/vidsrc/index';
import { zoechipScraper } from '@/providers/sources/zoechip';
import {
autoembedBengaliScraper,
autoembedEnglishScraper,
autoembedHindiScraper,
autoembedTamilScraper,
autoembedTeluguScraper,
} from './embeds/autoembed';
import { bflixScraper } from './embeds/bflix';
import { closeLoadScraper } from './embeds/closeload';
import { fileMoonScraper } from './embeds/filemoon';
@ -78,6 +86,7 @@ export function gatherAllSources(): Array<Sourcerer> {
insertunitScraper,
nitesScraper,
soaperTvScraper,
autoembedScraper,
tugaflixScraper,
];
}
@ -117,5 +126,10 @@ export function gatherAllEmbeds(): Array<Embed> {
bflixScraper,
playm4uNMScraper,
hydraxScraper,
autoembedEnglishScraper,
autoembedHindiScraper,
autoembedBengaliScraper,
autoembedTamilScraper,
autoembedTeluguScraper,
];
}

View file

@ -0,0 +1,54 @@
import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '@/providers/base';
const providers = [
{
id: 'autoembed-english',
rank: 10,
},
{
id: 'autoembed-hindi',
rank: 9,
},
{
id: 'autoembed-tamil',
rank: 8,
},
{
id: 'autoembed-telugu',
rank: 7,
},
{
id: 'autoembed-bengali',
rank: 6,
},
];
function embed(provider: { id: string; rank: number }) {
return makeEmbed({
id: provider.id,
name: provider.id.charAt(0).toUpperCase() + provider.id.slice(1),
rank: provider.rank,
async scrape(ctx) {
return {
stream: [
{
id: 'primary',
type: 'hls',
playlist: ctx.url,
flags: [flags.CORS_ALLOWED],
captions: [],
},
],
};
},
});
}
export const [
autoembedEnglishScraper,
autoembedHindiScraper,
autoembedBengaliScraper,
autoembedTamilScraper,
autoembedTeluguScraper,
] = providers.map(embed);

View file

@ -0,0 +1,45 @@
import { flags } from '@/entrypoint/utils/targets';
import { SourcererEmbed, SourcererOutput, makeSourcerer } from '@/providers/base';
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
import { NotFoundError } from '@/utils/errors';
const baseUrl = 'https://autoembed.cc/';
async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promise<SourcererOutput> {
const playerPage = await ctx.proxiedFetcher(`/embed/player.php`, {
baseUrl,
query: {
id: ctx.media.tmdbId,
...(ctx.media.type === 'show' && {
s: ctx.media.season.number.toString(),
e: ctx.media.episode.number.toString(),
}),
},
});
const fileDataMatch = playerPage.match(/"file": (\[.*?\])/s);
if (!fileDataMatch[1]) throw new NotFoundError('No data found');
const fileData: { title: string; file: string }[] = JSON.parse(fileDataMatch[1].replace(/,\s*\]$/, ']'));
const embeds: SourcererEmbed[] = [];
for (const stream of fileData) {
const url = stream.file;
if (!url) continue;
embeds.push({ embedId: `autoembed-${stream.title.toLowerCase().trim()}`, url });
}
return {
embeds,
};
}
export const autoembedScraper = makeSourcerer({
id: 'autoembed',
name: 'Autoembed',
rank: 10,
flags: [flags.CORS_ALLOWED],
scrapeMovie: comboScraper,
scrapeShow: comboScraper,
});