mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
init
This commit is contained in:
17
providers/topmovies/index.ts
Normal file
17
providers/topmovies/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import {modGetInfo} from '../mod/modGetInfo';
|
||||
import {modGetEpisodeLinks} from '../mod/modGetEpisodesList';
|
||||
import {modGetStream} from '../mod/modGetStream';
|
||||
import {ProviderType} from '../types';
|
||||
import {topGetPosts, topGetPostsSearch} from './topGetPosts';
|
||||
import {topCatalogList, topGenresList} from './topCatalog';
|
||||
|
||||
export const topMovies: ProviderType = {
|
||||
catalog: topCatalogList,
|
||||
genres: topGenresList,
|
||||
GetMetaData: modGetInfo,
|
||||
GetHomePosts: topGetPosts,
|
||||
GetStream: modGetStream,
|
||||
GetEpisodeLinks: modGetEpisodeLinks,
|
||||
nonStreamableServer: [],
|
||||
GetSearchPosts: topGetPostsSearch,
|
||||
};
|
||||
85
providers/topmovies/topCatalog.ts
Normal file
85
providers/topmovies/topCatalog.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
export const topCatalogList = [
|
||||
{
|
||||
title: 'Latest',
|
||||
filter: '',
|
||||
},
|
||||
{
|
||||
title: 'Netflix',
|
||||
filter: '/web-series/tv-shows-by-network/netflix',
|
||||
},
|
||||
{
|
||||
title: 'Hotstar',
|
||||
filter: '/web-series/tv-shows-by-network/hotstar',
|
||||
},
|
||||
{
|
||||
title: 'Amazon Prime',
|
||||
filter: '/web-series/tv-shows-by-network/amazon-prime-video',
|
||||
},
|
||||
];
|
||||
|
||||
export const topGenresList = [
|
||||
{
|
||||
title: 'Apple TV+',
|
||||
filter: '/ott/apple-tv',
|
||||
},
|
||||
{
|
||||
title: 'Disney+',
|
||||
filter: '/ott/disney-plus',
|
||||
},
|
||||
{
|
||||
title: 'Hulu',
|
||||
filter: '/ott/hulu',
|
||||
},
|
||||
{
|
||||
title: 'Crunchyroll',
|
||||
filter: '/ott/crunchyroll',
|
||||
},
|
||||
{
|
||||
title: 'Action',
|
||||
filter: '/movies-by-genre/action/',
|
||||
},
|
||||
{
|
||||
title: 'Adventure',
|
||||
filter: '/movies-by-genre/adventure/',
|
||||
},
|
||||
{
|
||||
title: 'Animation',
|
||||
filter: '/movies-by-genre/animated/',
|
||||
},
|
||||
{
|
||||
title: 'Comedy',
|
||||
filter: '/movies-by-genre/comedy/',
|
||||
},
|
||||
{
|
||||
title: 'Crime',
|
||||
filter: '/movies-by-genre/crime/',
|
||||
},
|
||||
{
|
||||
title: 'Documentary',
|
||||
filter: '/movies-by-genre/documentary/',
|
||||
},
|
||||
{
|
||||
title: 'Fantasy',
|
||||
filter: '/movies-by-genre/fantasy/',
|
||||
},
|
||||
{
|
||||
title: 'Horror',
|
||||
filter: '/movies-by-genre/horror/',
|
||||
},
|
||||
{
|
||||
title: 'Mystery',
|
||||
filter: '/movies-by-genre/mystery/',
|
||||
},
|
||||
{
|
||||
title: 'Romance',
|
||||
filter: '/movies-by-genre/romance/',
|
||||
},
|
||||
{
|
||||
title: 'Thriller',
|
||||
filter: '/movies-by-genre/thriller/',
|
||||
},
|
||||
{
|
||||
title: 'Sci-Fi',
|
||||
filter: '/movies-by-genre/sci-fi/',
|
||||
},
|
||||
];
|
||||
94
providers/topmovies/topGetPosts.ts
Normal file
94
providers/topmovies/topGetPosts.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import {Post, ProviderContext} from '../types';
|
||||
|
||||
const headers = {
|
||||
Accept:
|
||||
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
'Cache-Control': 'no-store',
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
DNT: '1',
|
||||
'sec-ch-ua':
|
||||
'"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
Cookie: 'popads_user_id=6ba8fe60a481387a3249f05aa058822d',
|
||||
'Sec-Fetch-Site': 'none',
|
||||
'Sec-Fetch-User': '?1',
|
||||
'Upgrade-Insecure-Requests': '1',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0',
|
||||
};
|
||||
|
||||
export const topGetPosts = async function ({
|
||||
filter,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl} = providerContext;
|
||||
const baseUrl = await getBaseUrl('Topmovies');
|
||||
const url = `${baseUrl + filter}/page/${page}/`;
|
||||
|
||||
return posts(url, signal, providerContext);
|
||||
};
|
||||
|
||||
export const topGetPostsSearch = async function ({
|
||||
searchQuery,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl} = providerContext;
|
||||
const baseUrl = await getBaseUrl('Topmovies');
|
||||
const url = `${baseUrl}/search/${searchQuery}/page/${page}/`;
|
||||
return posts(url, signal, providerContext);
|
||||
};
|
||||
|
||||
async function posts(
|
||||
url: string,
|
||||
signal: AbortSignal,
|
||||
providerContext: ProviderContext,
|
||||
): Promise<Post[]> {
|
||||
try {
|
||||
const {axios, cheerio} = providerContext;
|
||||
const res = await axios.get(url, {headers, signal});
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
const catalog: Post[] = [];
|
||||
$('.post-cards')
|
||||
.find('article')
|
||||
.map((i, element) => {
|
||||
const title = $(element).find('a').attr('title');
|
||||
const link = $(element).find('a').attr('href');
|
||||
const image =
|
||||
$(element).find('img').attr('data-src') ||
|
||||
$(element).find('img').attr('src') ||
|
||||
'';
|
||||
if (title && link) {
|
||||
catalog.push({
|
||||
title: title.replace('Download', '').trim(),
|
||||
link: link,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
// console.log(catalog);
|
||||
return catalog;
|
||||
} catch (err) {
|
||||
console.error('mod error ', err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user