mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
Add new providers for kmMovies, movies4u,katmoviefix, and zeefliz
Co-authored-by: DHR-Store <boss@dhrgroup.ai>
This commit is contained in:
10
providers/katMovieFix/catalog.ts
Normal file
10
providers/katMovieFix/catalog.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export const catalog = [
|
||||
{
|
||||
title: "Netflix",
|
||||
filter: "/category/netflix/",
|
||||
},
|
||||
{
|
||||
title: "Anime",
|
||||
filter: "/category/anime/",
|
||||
},
|
||||
];
|
||||
47
providers/katMovieFix/episodes.ts
Normal file
47
providers/katMovieFix/episodes.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { EpisodeLink, ProviderContext } from "../types";
|
||||
|
||||
export async function getEpisodeLinks({
|
||||
url,
|
||||
providerContext,
|
||||
}: {
|
||||
url: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<EpisodeLink[]> {
|
||||
try {
|
||||
const res = await providerContext.axios.get(url);
|
||||
const $ = providerContext.cheerio.load(res.data || "");
|
||||
const episodes: EpisodeLink[] = [];
|
||||
|
||||
// Agar anchor tag me episode links diye hain
|
||||
$("a").each((i, el) => {
|
||||
const $el = $(el);
|
||||
const href = ($el.attr("href") || "").trim();
|
||||
const text = $el.text().trim();
|
||||
|
||||
if (href && (text.includes("Episode") || /E\d+/i.test(text) || href.includes("vcloud.lol"))) {
|
||||
let epNum = text.match(/E\d+/i)?.[0] || text;
|
||||
if (/^\d+$/.test(epNum)) epNum = `Episode ${epNum}`;
|
||||
episodes.push({
|
||||
title: epNum,
|
||||
link: href,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return episodes;
|
||||
} catch (err) {
|
||||
console.error("getEpisodeLinks error:", err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ Ye wrapper export karna zaroori hai
|
||||
export async function getEpisodes({
|
||||
url,
|
||||
providerContext,
|
||||
}: {
|
||||
url: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<EpisodeLink[]> {
|
||||
return await getEpisodeLinks({ url, providerContext });
|
||||
}
|
||||
113
providers/katMovieFix/meta.ts
Normal file
113
providers/katMovieFix/meta.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
import { Info, Link, ProviderContext } from "../types";
|
||||
|
||||
const headers = {
|
||||
Accept:
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
||||
"Cache-Control": "no-store",
|
||||
"Accept-Language": "en-US,en;q=0.9",
|
||||
DNT: "1",
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
|
||||
"(KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
||||
};
|
||||
|
||||
// --- getMeta using Promise ---
|
||||
export const getMeta = function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
const { axios, cheerio } = providerContext;
|
||||
|
||||
return axios
|
||||
.get(link, { headers })
|
||||
.then((response) => {
|
||||
const $ = cheerio.load(response.data);
|
||||
const infoContainer = $(".entry-content,.post-inner");
|
||||
|
||||
const title =
|
||||
$("h1.entry-title").text().trim() ||
|
||||
$("h2.entry-title").text().trim() ||
|
||||
"";
|
||||
|
||||
const imdbMatch = infoContainer.html()?.match(/tt\d+/);
|
||||
const imdbId = imdbMatch ? imdbMatch[0] : "";
|
||||
|
||||
const synopsis =
|
||||
infoContainer
|
||||
.find("h3:contains('SYNOPSIS'), h3:contains('synopsis')")
|
||||
.next("p")
|
||||
.text()
|
||||
.trim() || "";
|
||||
|
||||
let image = infoContainer.find("img").first().attr("src") || "";
|
||||
if (image.startsWith("//")) image = "https:" + image;
|
||||
|
||||
const type = /Season \d+/i.test(infoContainer.text()) ? "series" : "movie";
|
||||
const linkList: Link[] = [];
|
||||
|
||||
if (type === "series") {
|
||||
// Single Episode Links
|
||||
infoContainer.find("h2 a").each((_, el) => {
|
||||
const el$ = $(el);
|
||||
const href = el$.attr("href")?.trim();
|
||||
const linkText = el$.text().trim();
|
||||
if (href && linkText.includes("Single Episode")) {
|
||||
linkList.push({ title: linkText, episodesLink: href, directLinks: [] });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Movies
|
||||
infoContainer.find("a[href]").each((_, aEl) => {
|
||||
const el$ = $(aEl);
|
||||
const href = el$.attr("href")?.trim() || "";
|
||||
if (!href) return;
|
||||
const btnText = el$.text().trim() || "Download";
|
||||
linkList.push({
|
||||
title: btnText,
|
||||
directLinks: [{ title: btnText, link: href, type: "movie" }],
|
||||
episodesLink: "",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return { title, synopsis, image, imdbId, type, linkList };
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("getMeta error:", err);
|
||||
return { title: "", synopsis: "", image: "", imdbId: "", type: "movie", linkList: [] };
|
||||
});
|
||||
};
|
||||
|
||||
// --- scrapeEpisodePage using Promise ---
|
||||
export const scrapeEpisodePage = function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<{ title: string; link: string; type: "series" }[]> {
|
||||
const { axios, cheerio } = providerContext;
|
||||
const result: { title: string; link: string; type: "series" }[] = [];
|
||||
|
||||
return axios
|
||||
.get(link, { headers })
|
||||
.then((response) => {
|
||||
const $ = cheerio.load(response.data);
|
||||
$(".entry-content,.post-inner")
|
||||
.find("h3 a")
|
||||
.each((_, el) => {
|
||||
const el$ = $(el);
|
||||
const href = el$.attr("href")?.trim();
|
||||
const btnText = el$.text().trim() || "Download";
|
||||
if (href) result.push({ title: btnText, link: href, type: "series" });
|
||||
});
|
||||
return result;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("scrapeEpisodePage error:", err);
|
||||
return result;
|
||||
});
|
||||
};
|
||||
145
providers/katMovieFix/posts.ts
Normal file
145
providers/katMovieFix/posts.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
import { Post, ProviderContext } from "../types";
|
||||
|
||||
const defaultHeaders = {
|
||||
Referer: "https://www.google.com",
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
|
||||
"(KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
|
||||
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||
"Accept-Language": "en-US,en;q=0.9",
|
||||
Pragma: "no-cache",
|
||||
"Cache-Control": "no-cache",
|
||||
};
|
||||
|
||||
// --- Normal catalog posts ---
|
||||
export async function getPosts({
|
||||
filter,
|
||||
page = 1,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter?: string;
|
||||
page?: number;
|
||||
signal?: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
return fetchPosts({ filter, page, query: "", signal, providerContext });
|
||||
}
|
||||
|
||||
// --- Search posts ---
|
||||
export async function getSearchPosts({
|
||||
searchQuery,
|
||||
page = 1,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page?: number;
|
||||
signal?: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
return fetchPosts({
|
||||
filter: "",
|
||||
page,
|
||||
query: searchQuery,
|
||||
signal,
|
||||
providerContext,
|
||||
});
|
||||
}
|
||||
|
||||
// --- Core function ---
|
||||
async function fetchPosts({
|
||||
filter,
|
||||
query,
|
||||
page = 1,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
filter?: string;
|
||||
query?: string;
|
||||
page?: number;
|
||||
signal?: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Post[]> {
|
||||
try {
|
||||
const baseUrl = await providerContext.getBaseUrl("katmoviefix");
|
||||
console.log("Base URL:", baseUrl);
|
||||
let url: string;
|
||||
|
||||
// --- Build URL for category filter or search query
|
||||
if (query && query.trim()) {
|
||||
url = `${baseUrl}/?s=${encodeURIComponent(query)}${
|
||||
page > 1 ? `&paged=${page}` : ""
|
||||
}`;
|
||||
} else if (filter) {
|
||||
url = filter.startsWith("/")
|
||||
? `${baseUrl}${filter.replace(/\/$/, "")}${
|
||||
page > 1 ? `/page/${page}` : ""
|
||||
}`
|
||||
: `${baseUrl}/${filter}${page > 1 ? `/page/${page}` : ""}`;
|
||||
} else {
|
||||
url = `${baseUrl}${page > 1 ? `/page/${page}` : ""}`;
|
||||
}
|
||||
|
||||
const { axios, cheerio } = providerContext;
|
||||
const res = await axios.get(url, { headers: defaultHeaders, signal });
|
||||
const $ = cheerio.load(res.data || "");
|
||||
|
||||
const resolveUrl = (href: string) =>
|
||||
href?.startsWith("http")
|
||||
? href
|
||||
: `${baseUrl}${href.startsWith("/") ? "" : "/"}${href}`;
|
||||
|
||||
const seen = new Set<string>();
|
||||
const catalog: Post[] = [];
|
||||
|
||||
// --- HDMovie2 selectors
|
||||
const POST_SELECTORS = [
|
||||
".pstr_box",
|
||||
"article",
|
||||
".result-item",
|
||||
".post",
|
||||
".item",
|
||||
".thumbnail",
|
||||
".latest-movies",
|
||||
".movie-item",
|
||||
].join(",");
|
||||
|
||||
$(POST_SELECTORS).each((_, el) => {
|
||||
const card = $(el);
|
||||
let link = card.find("a[href]").first().attr("href") || "";
|
||||
if (!link) return;
|
||||
link = resolveUrl(link);
|
||||
if (seen.has(link)) return;
|
||||
|
||||
let title =
|
||||
card.find("h2").first().text().trim() ||
|
||||
card.find("a[title]").first().attr("title")?.trim() ||
|
||||
card.text().trim();
|
||||
title = title
|
||||
.replace(/\[.*?\]/g, "")
|
||||
.replace(/\(.+?\)/g, "")
|
||||
.replace(/\s{2,}/g, " ")
|
||||
.trim();
|
||||
if (!title) return;
|
||||
|
||||
const img =
|
||||
card.find("img").first().attr("src") ||
|
||||
card.find("img").first().attr("data-src") ||
|
||||
card.find("img").first().attr("data-original") ||
|
||||
"";
|
||||
const image = img ? resolveUrl(img) : "";
|
||||
|
||||
seen.add(link);
|
||||
catalog.push({ title, link, image });
|
||||
});
|
||||
|
||||
return catalog.slice(0, 100);
|
||||
} catch (err) {
|
||||
console.error(
|
||||
"HDMovie2 fetchPosts error:",
|
||||
err instanceof Error ? err.message : String(err)
|
||||
);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
54
providers/katMovieFix/stream.ts
Normal file
54
providers/katMovieFix/stream.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { ProviderContext, Stream } from "../types";
|
||||
|
||||
const headers = {
|
||||
Accept:
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,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",
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
|
||||
"(KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
||||
};
|
||||
|
||||
export async function getStream({
|
||||
link,
|
||||
type,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
type: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}) {
|
||||
const { axios, cheerio, extractors } = providerContext;
|
||||
const { hubcloudExtracter } = extractors;
|
||||
|
||||
try {
|
||||
const streamLinks: Stream[] = [];
|
||||
const response = await axios.get(link, { headers });
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
// --- PixelDrain link scrape ---
|
||||
$("a[href*='pixeldrain.dev/api/file/']").each((_, el) => {
|
||||
const href = $(el).attr("href")?.trim();
|
||||
if (href) {
|
||||
streamLinks.push({
|
||||
server: "pixeldrain",
|
||||
link: href,
|
||||
type: "mp4",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// --- hubcloud extraction ---
|
||||
const hubcloudStreams = await hubcloudExtracter(link, signal);
|
||||
streamLinks.push(...hubcloudStreams);
|
||||
|
||||
return streamLinks;
|
||||
} catch (error: any) {
|
||||
console.log("getStream error: ", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user