Merge all autoembed embeds in one file

This commit is contained in:
TPN 2024-06-06 21:16:18 +05:30
parent a0d4cb8243
commit cf161e7cd5
No known key found for this signature in database
GPG key ID: 40AE091637892B91
7 changed files with 62 additions and 87 deletions

View file

@ -25,11 +25,13 @@ import { tugaflixScraper } from '@/providers/sources/tugaflix';
import { vidsrcScraper } from '@/providers/sources/vidsrc/index';
import { zoechipScraper } from '@/providers/sources/zoechip';
import { autoembedBenagaliScraper } from './embeds/autoembed/bengali';
import { autoembedEnglishScraper } from './embeds/autoembed/english';
import { autoembedHindiScraper } from './embeds/autoembed/hindi';
import { autoembedTamilScraper } from './embeds/autoembed/tamil';
import { autoembedTeluguScraper } from './embeds/autoembed/telugu';
import {
autoembedBengaliScraper,
autoembedEnglishScraper,
autoembedHindiScraper,
autoembedTamilScraper,
autoembedTeluguScraper,
} from './embeds/autoembed';
import { bflixScraper } from './embeds/bflix';
import { closeLoadScraper } from './embeds/closeload';
import { fileMoonScraper } from './embeds/filemoon';
@ -126,7 +128,7 @@ export function gatherAllEmbeds(): Array<Embed> {
hydraxScraper,
autoembedEnglishScraper,
autoembedHindiScraper,
autoembedBenagaliScraper,
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

@ -1,15 +0,0 @@
import { makeEmbed } from '@/providers/base';
import { autoembedEnglishScraper } from './english';
export const autoembedBenagaliScraper = makeEmbed({
id: 'autoembed-bengali',
name: 'Bengali',
rank: 7,
async scrape(ctx) {
const result = await autoembedEnglishScraper.scrape(ctx);
return {
stream: result.stream,
};
},
});

View file

@ -1,21 +0,0 @@
import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '@/providers/base';
export const autoembedEnglishScraper = makeEmbed({
id: 'autoembed-english',
name: 'English',
rank: 10,
scrape: async (ctx) => {
return {
stream: [
{
id: 'primary',
type: 'hls',
playlist: ctx.url,
flags: [flags.CORS_ALLOWED],
captions: [],
},
],
};
},
});

View file

@ -1,15 +0,0 @@
import { makeEmbed } from '@/providers/base';
import { autoembedEnglishScraper } from './english';
export const autoembedHindiScraper = makeEmbed({
id: 'autoembed-hindi',
name: 'Hindi',
rank: 9,
async scrape(ctx) {
const result = await autoembedEnglishScraper.scrape(ctx);
return {
stream: result.stream,
};
},
});

View file

@ -1,15 +0,0 @@
import { makeEmbed } from '@/providers/base';
import { autoembedEnglishScraper } from './english';
export const autoembedTamilScraper = makeEmbed({
id: 'autoembed-tamil',
name: 'Tamil',
rank: 8,
async scrape(ctx) {
const result = await autoembedEnglishScraper.scrape(ctx);
return {
stream: result.stream,
};
},
});

View file

@ -1,15 +0,0 @@
import { makeEmbed } from '@/providers/base';
import { autoembedEnglishScraper } from './english';
export const autoembedTeluguScraper = makeEmbed({
id: 'autoembed-telugu',
name: 'Telugu',
rank: 6,
async scrape(ctx) {
const result = await autoembedEnglishScraper.scrape(ctx);
return {
stream: result.stream,
};
},
});