mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
feat: add moviebox
This commit is contained in:
12
providers/movieBox/catalog.ts
Normal file
12
providers/movieBox/catalog.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export const catalog = [
|
||||
{
|
||||
title: "Trending",
|
||||
filter: "2",
|
||||
},
|
||||
{
|
||||
title: "Cinema",
|
||||
filter: "5",
|
||||
},
|
||||
];
|
||||
|
||||
export const genres = [];
|
||||
49
providers/movieBox/episodes.ts
Normal file
49
providers/movieBox/episodes.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { EpisodeLink, ProviderContext } from "../types";
|
||||
|
||||
export const getEpisodes = async function ({
|
||||
url,
|
||||
providerContext,
|
||||
}: {
|
||||
url: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<EpisodeLink[]> {
|
||||
const { axios, cheerio } = providerContext;
|
||||
try {
|
||||
const episodeLinks: EpisodeLink[] = [];
|
||||
|
||||
const response = await fetch("https://dob-worker.8man.workers.dev", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
url: url,
|
||||
method: "GET",
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
const list = data?.data?.list || [];
|
||||
|
||||
list.forEach((item: any) => {
|
||||
const seriesTitle = item?.ep
|
||||
? `S-${item?.se} E-${item?.ep}`
|
||||
: item?.title || "";
|
||||
const episodesLink = item?.resourceLink || "";
|
||||
if (episodesLink) {
|
||||
episodeLinks.push({
|
||||
title: seriesTitle.trim(),
|
||||
link: JSON.stringify({
|
||||
url: episodesLink,
|
||||
title: seriesTitle.trim(),
|
||||
}),
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return episodeLinks;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
76
providers/movieBox/meta.ts
Normal file
76
providers/movieBox/meta.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { Info, Link, ProviderContext } from "../types";
|
||||
|
||||
export const getMeta = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const { axios, cheerio, getBaseUrl } = providerContext;
|
||||
const baseUrl = getBaseUrl("movieBox");
|
||||
const links: Link[] = [];
|
||||
// this is just a proxy please host your own if you want to use this code:- https://github.com/himanshu8443/Cf-Workers/blob/main/src/dob-worker/index.js
|
||||
const response = await fetch("https://dob-worker.8man.workers.dev", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
url: link,
|
||||
method: "GET",
|
||||
}),
|
||||
});
|
||||
const data = (await response.json()).data;
|
||||
console.log("data", data);
|
||||
|
||||
// metadata
|
||||
const title = (data?.title || "").replace(/\s*\[.*?\]\s*$/, "");
|
||||
const synopsis = data?.description || "";
|
||||
const image = data?.cover?.url || "";
|
||||
const rating = data?.imdbRatingValue || "";
|
||||
const tags =
|
||||
data?.genre?.split(",")?.map((tag: string) => tag.trim()) || [];
|
||||
|
||||
const dubs = data?.dubs || [];
|
||||
|
||||
dubs?.forEach((dub: any) => {
|
||||
const link: Link = {
|
||||
title: dub?.lanName,
|
||||
episodesLink: `${baseUrl}/wefeed-mobile-bff/subject-api/resource?subjectId=${dub?.subjectId}&page=1&perPage=20&all=0&startPosition=1&endPosition=1&pagerMode=0&resolution=1080&se=1&epFrom=1&epTo=1`,
|
||||
};
|
||||
links.push(link);
|
||||
});
|
||||
|
||||
console.log("meta", {
|
||||
title,
|
||||
synopsis,
|
||||
image,
|
||||
rating,
|
||||
tags,
|
||||
links,
|
||||
});
|
||||
|
||||
return {
|
||||
title,
|
||||
synopsis,
|
||||
image,
|
||||
rating,
|
||||
tags,
|
||||
imdbId: "",
|
||||
type: "movie",
|
||||
linkList: links,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return {
|
||||
title: "",
|
||||
synopsis: "",
|
||||
image: "",
|
||||
imdbId: "",
|
||||
type: "movie",
|
||||
linkList: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
90
providers/movieBox/posts.ts
Normal file
90
providers/movieBox/posts.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import { Post, ProviderContext } from "../types";
|
||||
|
||||
export const getPosts = async function ({
|
||||
filter,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const posts: Post[] = [];
|
||||
const { getBaseUrl } = providerContext;
|
||||
if (page > 1) {
|
||||
return posts;
|
||||
}
|
||||
const baseUrl = getBaseUrl("movieBox");
|
||||
const url = `${baseUrl}/wefeed-mobile-bff/tab-operating?page=3&tabId=0&version=2fe0d7c224603ff7b0df294b46d3b84b`;
|
||||
|
||||
const response = await fetch("https://dob-worker.8man.workers.dev", {
|
||||
signal: signal,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
url: url,
|
||||
method: "GET",
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
const list = data?.data?.items?.[parseInt(filter)]?.subjects;
|
||||
console.log("list", list);
|
||||
for (const item of list) {
|
||||
const post: Post = {
|
||||
image: item?.cover.url,
|
||||
title: item?.title?.replace(/\s*\[.*?\]\s*$/, ""),
|
||||
link: `${baseUrl}/wefeed-mobile-bff/subject-api/get?subjectId=${item?.subjectId}`,
|
||||
};
|
||||
posts.push(post);
|
||||
}
|
||||
return posts;
|
||||
};
|
||||
|
||||
export const getSearchPosts = async function ({
|
||||
searchQuery,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
const { getBaseUrl, axios, cheerio } = providerContext;
|
||||
const baseUrl = getBaseUrl("movieBox");
|
||||
const url = `${baseUrl}/wefeed-mobile-bff/subject-api/search/v2`;
|
||||
if (page > 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// this is just a proxy please host your own if you want to use this code:- https://github.com/himanshu8443/Cf-Workers/blob/main/src/dob-worker/index.js
|
||||
const response = await fetch("https://dob-worker.8man.workers.dev", {
|
||||
signal: signal,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
url: url,
|
||||
method: "POST",
|
||||
body: { page: 1, perPage: 20, keyword: searchQuery, tabId: "Movie" },
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
const list = data?.data?.results?.[0]?.subjects || [];
|
||||
const posts: Post[] = list.map((item: any) => ({
|
||||
image: item?.cover?.url,
|
||||
title: item?.title,
|
||||
link: `${baseUrl}/wefeed-mobile-bff/subject-api/get?subjectId=${item?.subjectId}`,
|
||||
}));
|
||||
return posts;
|
||||
};
|
||||
27
providers/movieBox/stream.ts
Normal file
27
providers/movieBox/stream.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Stream, ProviderContext, EpisodeLink } from "../types";
|
||||
|
||||
export const getStream = async function ({
|
||||
link: url,
|
||||
type,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
type: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Stream[]> {
|
||||
const { axios, cheerio } = providerContext;
|
||||
try {
|
||||
const stream: Stream[] = [];
|
||||
const data = JSON.parse(url);
|
||||
stream.push({
|
||||
link: data.url,
|
||||
server: data.title || "Unknown Server",
|
||||
type: "mp4",
|
||||
});
|
||||
console.log("stream", stream);
|
||||
return stream;
|
||||
} catch (err) {
|
||||
console.log("getStream error", err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user