mirror of
https://github.com/sussy-code/providers.git
synced 2026-08-15 11:46:38 +00:00
fix autoembed
english only
This commit is contained in:
parent
7e1ce1aa2e
commit
beffc68b64
1 changed files with 24 additions and 18 deletions
|
|
@ -3,33 +3,39 @@ import { SourcererEmbed, SourcererOutput, makeSourcerer } from '@/providers/base
|
|||
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
||||
import { NotFoundError } from '@/utils/errors';
|
||||
|
||||
const baseUrl = 'https://autoembed.cc/';
|
||||
const apiUrl = 'https://tom.autoembed.cc';
|
||||
|
||||
async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promise<SourcererOutput> {
|
||||
const playerPage = await ctx.proxiedFetcher(`/embed/player.php`, {
|
||||
baseUrl,
|
||||
// Construct the API endpoint similar to the working example
|
||||
const mediaType = ctx.media.type === 'show' ? 'tv' : 'movie';
|
||||
let id = ctx.media.tmdbId;
|
||||
|
||||
if (ctx.media.type === 'show') {
|
||||
id = `${id}/${ctx.media.season.number}/${ctx.media.episode.number}`;
|
||||
}
|
||||
|
||||
const data = await ctx.proxiedFetcher(`/api/getVideoSource`, {
|
||||
baseUrl: apiUrl,
|
||||
query: {
|
||||
id: ctx.media.tmdbId,
|
||||
...(ctx.media.type === 'show' && {
|
||||
s: ctx.media.season.number.toString(),
|
||||
e: ctx.media.episode.number.toString(),
|
||||
}),
|
||||
type: mediaType,
|
||||
id,
|
||||
},
|
||||
headers: {
|
||||
Referer: apiUrl,
|
||||
},
|
||||
});
|
||||
|
||||
const fileDataMatch = playerPage.match(/"file": (\[.*?\])/s);
|
||||
if (!fileDataMatch[1]) throw new NotFoundError('No data found');
|
||||
if (!data) throw new NotFoundError('Failed to fetch video source');
|
||||
if (!data.videoSource) throw new NotFoundError('No video source found');
|
||||
ctx.progress(50);
|
||||
|
||||
const fileData: { title: string; file: string }[] = JSON.parse(fileDataMatch[1].replace(/,\s*\]$/, ']'));
|
||||
const embeds: SourcererEmbed[] = [
|
||||
{
|
||||
embedId: `autoembed-english`,
|
||||
url: data.videoSource,
|
||||
},
|
||||
];
|
||||
|
||||
const embeds: SourcererEmbed[] = [];
|
||||
|
||||
for (const stream of fileData) {
|
||||
const url = stream.file;
|
||||
if (!url) continue;
|
||||
embeds.push({ embedId: `autoembed-${stream.title.toLowerCase().trim()}`, url });
|
||||
}
|
||||
ctx.progress(90);
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in a new issue