mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
init
This commit is contained in:
16
providers/showbox/index.ts
Normal file
16
providers/showbox/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import {ProviderType} from '../types';
|
||||
import {catalogList, sbGenresList} from './sbCatalog';
|
||||
import {sbGetEpisodeLinks} from './sbGetEpisodeList';
|
||||
import {sbGetInfo} from './sbGetMeta';
|
||||
import {sbGetPosts, sbGetPostsSearch} from './sbGetPosts';
|
||||
import {sbGetStream} from './sbGetStream';
|
||||
|
||||
export const showBox: ProviderType = {
|
||||
catalog: catalogList,
|
||||
genres: sbGenresList,
|
||||
GetMetaData: sbGetInfo,
|
||||
GetHomePosts: sbGetPosts,
|
||||
GetStream: sbGetStream,
|
||||
GetSearchPosts: sbGetPostsSearch,
|
||||
GetEpisodeLinks: sbGetEpisodeLinks,
|
||||
};
|
||||
16
providers/showbox/sbCatalog.ts
Normal file
16
providers/showbox/sbCatalog.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export const catalogList = [
|
||||
{
|
||||
title: 'Home',
|
||||
filter: '',
|
||||
},
|
||||
{
|
||||
title: 'Movies',
|
||||
filter: '/movie',
|
||||
},
|
||||
{
|
||||
title: 'TV Shows',
|
||||
filter: '/tv',
|
||||
},
|
||||
];
|
||||
|
||||
export const sbGenresList = [];
|
||||
46
providers/showbox/sbGetEpisodeList.ts
Normal file
46
providers/showbox/sbGetEpisodeList.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import {EpisodeLink, ProviderContext} from '../types';
|
||||
|
||||
export const sbGetEpisodeLinks = async function ({
|
||||
url: id,
|
||||
providerContext,
|
||||
}: {
|
||||
url: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<EpisodeLink[]> {
|
||||
const {axios} = providerContext;
|
||||
try {
|
||||
const [fileId, febboxId] = id.split('&');
|
||||
const febLink = febboxId
|
||||
? `https://www.febbox.com/file/file_share_list?share_key=${fileId}&pwd=&parent_id=${febboxId}&is_html=0`
|
||||
: `https://www.febbox.com/file/file_share_list?share_key=${fileId}&pwd=&is_html=0`;
|
||||
const res = await axios.get(febLink);
|
||||
const data = res.data;
|
||||
const fileList = data.data.file_list;
|
||||
const episodeLinks: EpisodeLink[] = [];
|
||||
fileList?.map((file: any) => {
|
||||
const fileName = formatEpisodeName(file.file_name);
|
||||
const epId = file?.fid;
|
||||
if (!file.is_dir && fileName && epId) {
|
||||
episodeLinks.push({
|
||||
title: fileName,
|
||||
link: `${fileId}&${epId}`,
|
||||
});
|
||||
}
|
||||
});
|
||||
return episodeLinks;
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
function formatEpisodeName(title: string): string {
|
||||
const regex = /[sS](\d+)\s*[eE](\d+)/;
|
||||
const match = title.match(regex);
|
||||
if (match) {
|
||||
const season = match[1].padStart(2, '0');
|
||||
const episode = match[2].padStart(2, '0');
|
||||
return `Season${season} Episode${episode}`;
|
||||
} else {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
72
providers/showbox/sbGetMeta.ts
Normal file
72
providers/showbox/sbGetMeta.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import {Info, Link, ProviderContext} from '../types';
|
||||
|
||||
export const sbGetInfo = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const {axios, cheerio} = providerContext;
|
||||
const url = link;
|
||||
const res = await axios.get(url);
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
const type = url.includes('tv') ? 'series' : 'movie';
|
||||
const imdbId = '';
|
||||
const title = $('.heading-name').text();
|
||||
const rating =
|
||||
$('.btn-imdb')
|
||||
.text()
|
||||
?.match(/\d+(\.\d+)?/g)?.[0] || '';
|
||||
const image =
|
||||
$('.cover_follow').attr('style')?.split('url(')[1]?.split(')')[0] || '';
|
||||
const synopsis = $('.description')
|
||||
.text()
|
||||
?.replaceAll(/[\n\t]/g, '')
|
||||
?.trim();
|
||||
const febID = $('.heading-name').find('a').attr('href')?.split('/')?.pop();
|
||||
const baseUrl = url.split('/').slice(0, 3).join('/');
|
||||
const indexUrl = `${baseUrl}/index/share_link?id=${febID}&type=${
|
||||
type === 'movie' ? '1' : '2'
|
||||
}`;
|
||||
const indexRes = await axios.get(indexUrl);
|
||||
const indexData = indexRes.data;
|
||||
const febKey = indexData.data.link.split('/').pop();
|
||||
const febLink = `https://www.febbox.com/file/file_share_list?share_key=${febKey}&is_html=0`;
|
||||
const febRes = await axios.get(febLink);
|
||||
const febData = febRes.data;
|
||||
const fileList = febData?.data?.file_list;
|
||||
const links: Link[] = [];
|
||||
if (fileList) {
|
||||
fileList.map((file: any) => {
|
||||
const fileName = `${file.file_name} (${file.file_size})`;
|
||||
const fileId = file.fid;
|
||||
links.push({
|
||||
title: fileName,
|
||||
episodesLink: file.is_dir ? `${febKey}&${fileId}` : `${febKey}&`,
|
||||
});
|
||||
});
|
||||
}
|
||||
return {
|
||||
title,
|
||||
rating,
|
||||
synopsis,
|
||||
image,
|
||||
imdbId,
|
||||
type,
|
||||
linkList: links,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
title: '',
|
||||
rating: '',
|
||||
synopsis: '',
|
||||
image: '',
|
||||
imdbId: '',
|
||||
type: '',
|
||||
linkList: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
75
providers/showbox/sbGetPosts.ts
Normal file
75
providers/showbox/sbGetPosts.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import {Post, ProviderContext} from '../types';
|
||||
|
||||
export const sbGetPosts = async function ({
|
||||
filter,
|
||||
page,
|
||||
// providerValue,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, axios, cheerio} = providerContext;
|
||||
const baseUrl = await getBaseUrl('showbox');
|
||||
const url = `${baseUrl + filter}?page=${page}/`;
|
||||
return posts({url, signal, baseUrl, axios, cheerio});
|
||||
};
|
||||
|
||||
export const sbGetPostsSearch = async function ({
|
||||
searchQuery,
|
||||
page,
|
||||
// providerValue,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl, axios, cheerio} = providerContext;
|
||||
const baseUrl = await getBaseUrl('showbox');
|
||||
const url = `${baseUrl}/search?keyword=${searchQuery}&page=${page}`;
|
||||
return posts({url, signal, baseUrl, axios, cheerio});
|
||||
};
|
||||
|
||||
async function posts({
|
||||
url,
|
||||
signal,
|
||||
// baseUrl,
|
||||
axios,
|
||||
cheerio,
|
||||
}: {
|
||||
url: string;
|
||||
signal: AbortSignal;
|
||||
baseUrl: string;
|
||||
axios: ProviderContext['axios'];
|
||||
cheerio: ProviderContext['cheerio'];
|
||||
}): Promise<Post[]> {
|
||||
try {
|
||||
const res = await axios.get(url, {signal});
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
const catalog: Post[] = [];
|
||||
$('.movie-item').map((i, element) => {
|
||||
const title = $(element).find('.movie-title').text();
|
||||
const link = $(element).find('a').attr('href');
|
||||
const image = $(element).find('img').attr('src');
|
||||
if (title && link && image) {
|
||||
catalog.push({
|
||||
title: title,
|
||||
link: link,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
return catalog;
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
43
providers/showbox/sbGetStream.ts
Normal file
43
providers/showbox/sbGetStream.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import {Stream, ProviderContext} from '../types';
|
||||
import * as cheerio from 'cheerio';
|
||||
|
||||
export const sbGetStream = async function ({
|
||||
link: id,
|
||||
// type,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
type: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
try {
|
||||
const {axios} = providerContext;
|
||||
const stream: Stream[] = [];
|
||||
const [, epId] = id.split('&');
|
||||
const url = `https://febbox.vercel.app/api/video-quality?fid=${epId}`;
|
||||
const res = await axios.get(url, {signal});
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data.html);
|
||||
$('.file_quality').each((i, el) => {
|
||||
const server =
|
||||
$(el).find('p.name').text() +
|
||||
' - ' +
|
||||
$(el).find('p.size').text() +
|
||||
' - ' +
|
||||
$(el).find('p.speed').text();
|
||||
const link = $(el).attr('data-url');
|
||||
if (link) {
|
||||
stream.push({
|
||||
server: server,
|
||||
type: 'mkv',
|
||||
link: link,
|
||||
});
|
||||
}
|
||||
});
|
||||
return stream;
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user