mirror of
https://github.com/sussy-code/providers.git
synced 2026-08-20 05:58:49 +00:00
Add fedapi
This commit is contained in:
parent
f58438ba57
commit
564ecd8b8b
2 changed files with 107 additions and 0 deletions
|
|
@ -82,6 +82,7 @@ import { warezPlayerScraper } from './embeds/warezcdn/warezplayer';
|
|||
import { webtor1080Scraper, webtor480Scraper, webtor4kScraper, webtor720Scraper } from './embeds/webtor';
|
||||
import { wootlyScraper } from './embeds/wootly';
|
||||
import { embedsuScraper } from './sources/embedsu';
|
||||
import { FedAPIScraper } from './sources/fedapi';
|
||||
import { goojaraScraper } from './sources/goojara';
|
||||
import { hdRezkaScraper } from './sources/hdrezka';
|
||||
import { m4uScraper } from './sources/m4ufree';
|
||||
|
|
@ -134,6 +135,7 @@ export function gatherAllSources(): Array<Sourcerer> {
|
|||
webtorScraper,
|
||||
embedsuScraper,
|
||||
vidlinkScraper,
|
||||
FedAPIScraper,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
105
src/providers/sources/fedapi.ts
Normal file
105
src/providers/sources/fedapi.ts
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
import { flags } from '@/entrypoint/utils/targets';
|
||||
import { SourcererOutput, makeSourcerer } from '@/providers/base';
|
||||
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
||||
import { NotFoundError } from '@/utils/errors';
|
||||
|
||||
import { Caption } from '../captions';
|
||||
|
||||
const BASE_URL = 'https://febapi.bludclart.com';
|
||||
|
||||
async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promise<SourcererOutput> {
|
||||
const apiUrl =
|
||||
ctx.media.type === 'movie'
|
||||
? `${BASE_URL}/movie/${ctx.media.tmdbId}`
|
||||
: `${BASE_URL}/tv/${ctx.media.tmdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`;
|
||||
|
||||
const data = await ctx.fetcher(apiUrl);
|
||||
if (!data) throw new NotFoundError('No response from API');
|
||||
ctx.progress(50);
|
||||
|
||||
const streams = Object.entries(data.streams.qualities).reduce((acc: Record<string, string>, [quality, url]) => {
|
||||
let qualityKey: number;
|
||||
if (quality === '4K') {
|
||||
qualityKey = 2160;
|
||||
} else if (quality === 'ORG') {
|
||||
return acc;
|
||||
} else {
|
||||
qualityKey = parseInt(quality.replace('P', ''), 10);
|
||||
}
|
||||
if (Number.isNaN(qualityKey) || acc[qualityKey]) return acc;
|
||||
acc[qualityKey] = url as string;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const captions: Caption[] = [];
|
||||
for (const [lang, subs] of Object.entries(data.subtitles)) {
|
||||
const language = lang.replace(' Subtitles', '');
|
||||
for (const sub of subs as any[]) {
|
||||
const url = sub['Subtitle Link'];
|
||||
const isVtt = url.toLowerCase().endsWith('.vtt');
|
||||
captions.push({
|
||||
type: isVtt ? 'vtt' : 'srt',
|
||||
id: sub['Subtitle Link'],
|
||||
url: sub['Subtitle Link'],
|
||||
language,
|
||||
hasCorsRestrictions: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ctx.progress(90);
|
||||
|
||||
return {
|
||||
embeds: [],
|
||||
stream: [
|
||||
{
|
||||
id: 'primary',
|
||||
captions,
|
||||
qualities: {
|
||||
...(streams[2160] && {
|
||||
'4k': {
|
||||
type: 'mp4',
|
||||
url: streams[2160],
|
||||
},
|
||||
}),
|
||||
...(streams[1080] && {
|
||||
1080: {
|
||||
type: 'mp4',
|
||||
url: streams[1080],
|
||||
},
|
||||
}),
|
||||
...(streams[720] && {
|
||||
720: {
|
||||
type: 'mp4',
|
||||
url: streams[720],
|
||||
},
|
||||
}),
|
||||
...(streams[480] && {
|
||||
480: {
|
||||
type: 'mp4',
|
||||
url: streams[480],
|
||||
},
|
||||
}),
|
||||
...(streams[360] && {
|
||||
360: {
|
||||
type: 'mp4',
|
||||
url: streams[360],
|
||||
},
|
||||
}),
|
||||
},
|
||||
type: 'file',
|
||||
flags: [flags.CORS_ALLOWED],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export const FedAPIScraper = makeSourcerer({
|
||||
id: 'fedapi',
|
||||
name: 'FED API',
|
||||
rank: 230,
|
||||
disabled: false,
|
||||
flags: [flags.CORS_ALLOWED],
|
||||
scrapeMovie: comboScraper,
|
||||
scrapeShow: comboScraper,
|
||||
});
|
||||
Loading…
Reference in a new issue