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:
16
providers/flixhq/flixhqCatalog.ts
Normal file
16
providers/flixhq/flixhqCatalog.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export const flixhqCatalog = [
|
||||
{
|
||||
title: 'Trending',
|
||||
filter: '/trending',
|
||||
},
|
||||
{
|
||||
title: 'Movies',
|
||||
filter: '/recent-movies',
|
||||
},
|
||||
{
|
||||
title: 'TV Shows',
|
||||
filter: '/recent-shows',
|
||||
},
|
||||
];
|
||||
|
||||
export const flixhqGenresList = [];
|
||||
61
providers/flixhq/flixhqGetInfo.ts
Normal file
61
providers/flixhq/flixhqGetInfo.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import {Info, Link, ProviderContext} from '../types';
|
||||
|
||||
export const flixhqGetInfo = async function ({
|
||||
link: id,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const {axios, getBaseUrl} = providerContext;
|
||||
const baseUrl = await getBaseUrl('consumet');
|
||||
const url = `${baseUrl}/movies/flixhq/info?id=` + id;
|
||||
const res = await axios.get(url);
|
||||
const data = res.data;
|
||||
const meta = {
|
||||
title: data.title,
|
||||
synopsis: data.description.replace(/<[^>]*>?/gm, '').trim(),
|
||||
image: data.cover,
|
||||
cast: data.casts,
|
||||
rating: data.rating,
|
||||
tags: [data?.type, data?.duration, data.releaseDate.split('-')[0]],
|
||||
imdbId: '',
|
||||
type: data.episodes.length > 1 ? 'series' : 'movie',
|
||||
};
|
||||
|
||||
const links: Link['directLinks'] = [];
|
||||
data.episodes.forEach((episode: any) => {
|
||||
const title = episode?.number
|
||||
? 'Season-' + episode?.season + ' Ep-' + episode.number
|
||||
: episode.title;
|
||||
const link = episode.id + '*' + data.id;
|
||||
if (link && title) {
|
||||
links.push({
|
||||
title,
|
||||
link,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
...meta,
|
||||
linkList: [
|
||||
{
|
||||
title: meta.title,
|
||||
directLinks: links,
|
||||
},
|
||||
],
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return {
|
||||
title: '',
|
||||
synopsis: '',
|
||||
image: '',
|
||||
imdbId: '',
|
||||
type: 'movie',
|
||||
linkList: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
71
providers/flixhq/flixhqGetPosts.ts
Normal file
71
providers/flixhq/flixhqGetPosts.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import {Post, ProviderContext} from '../types';
|
||||
|
||||
export const flixhqGetPosts = async function ({
|
||||
filter,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl} = providerContext;
|
||||
const urlRes = await getBaseUrl('consumet');
|
||||
const baseUrl = urlRes + '/movies/flixhq';
|
||||
const url = `${baseUrl + filter}`;
|
||||
return posts({url, signal, providerContext});
|
||||
};
|
||||
|
||||
export const flixhqGetSearchPost = async function ({
|
||||
searchQuery,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const {getBaseUrl} = providerContext;
|
||||
const urlRes = await getBaseUrl('consumet');
|
||||
const baseUrl = urlRes + '/movies/flixhq';
|
||||
const url = `${baseUrl}/${searchQuery}?page=${page}`;
|
||||
return posts({url, signal, providerContext});
|
||||
};
|
||||
|
||||
async function posts({
|
||||
url,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
url: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
try {
|
||||
const {axios} = providerContext;
|
||||
const res = await axios.get(url, {signal});
|
||||
const data = res.data?.results || res.data;
|
||||
const catalog: Post[] = [];
|
||||
data?.map((element: any) => {
|
||||
const title = element.title;
|
||||
const link = element.id;
|
||||
const image = element.image;
|
||||
if (title && link && image) {
|
||||
catalog.push({
|
||||
title: title,
|
||||
link: link,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
return catalog;
|
||||
} catch (err) {
|
||||
console.error('flixhq error ', err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
59
providers/flixhq/flixhqGetStream.ts
Normal file
59
providers/flixhq/flixhqGetStream.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import {ProviderContext, Stream, TextTrackType} from '../types';
|
||||
|
||||
export const flixhqGetStream = async function ({
|
||||
link: id,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
try {
|
||||
const {getBaseUrl} = providerContext;
|
||||
const episodeId = id.split('*')[0];
|
||||
const mediaId = id.split('*')[1];
|
||||
const baseUrl = await getBaseUrl('consumet');
|
||||
const serverUrl = `${baseUrl}/movies/flixhq/servers?episodeId=${episodeId}&mediaId=${mediaId}`;
|
||||
const res = await fetch(serverUrl);
|
||||
const servers = await res.json();
|
||||
const streamLinks: Stream[] = [];
|
||||
for (const server of servers) {
|
||||
const streamUrl =
|
||||
`${baseUrl}/movies/flixhq/watch?server=` +
|
||||
server.name +
|
||||
'&episodeId=' +
|
||||
episodeId +
|
||||
'&mediaId=' +
|
||||
mediaId;
|
||||
const streamRes = await fetch(streamUrl);
|
||||
const streamData = await streamRes.json();
|
||||
const subtitles: Stream['subtitles'] = [];
|
||||
if (streamData?.sources?.length > 0) {
|
||||
if (streamData.subtitles) {
|
||||
streamData.subtitles.forEach((sub: {lang: string; url: string}) => {
|
||||
subtitles.push({
|
||||
language: sub?.lang?.slice(0, 2) as any,
|
||||
uri: sub?.url,
|
||||
type: TextTrackType.VTT,
|
||||
title: sub?.lang,
|
||||
});
|
||||
});
|
||||
}
|
||||
streamData.sources.forEach((source: any) => {
|
||||
streamLinks.push({
|
||||
server:
|
||||
server?.name +
|
||||
'-' +
|
||||
source?.quality?.replace('auto', 'MultiQuality'),
|
||||
link: source.url,
|
||||
type: source.isM3U8 ? 'm3u8' : 'mp4',
|
||||
subtitles: subtitles,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
return streamLinks;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
25
providers/flixhq/index.ts
Normal file
25
providers/flixhq/index.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {ProviderType} from '../types';
|
||||
import {flixhqCatalog, flixhqGenresList} from './flixhqCatalog';
|
||||
import {flixhqGetInfo} from './flixhqGetInfo';
|
||||
import {flixhqGetPosts, flixhqGetSearchPost} from './flixhqGetPosts';
|
||||
import {flixhqGetStream} from './flixhqGetStream';
|
||||
|
||||
export const flixhq: ProviderType = {
|
||||
catalog: flixhqCatalog,
|
||||
genres: flixhqGenresList,
|
||||
GetMetaData: flixhqGetInfo,
|
||||
GetHomePosts: flixhqGetPosts,
|
||||
GetStream: flixhqGetStream,
|
||||
GetSearchPosts: flixhqGetSearchPost,
|
||||
nonDownloadableServer: ['upcloud-MultiQuality', 'vidcloud-MultiQuality'],
|
||||
nonStreamableServer: [
|
||||
'upcloud-1080',
|
||||
'upcloud-720',
|
||||
'upcloud-480',
|
||||
'upcloud-360',
|
||||
'vidcloud-1080',
|
||||
'vidcloud-720',
|
||||
'vidcloud-480',
|
||||
'vidcloud-360',
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user