mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
Add new providers for kmMovies, movies4u,katmoviefix, and zeefliz
Co-authored-by: DHR-Store <boss@dhrgroup.ai>
This commit is contained in:
5
providers/kmMovies/catalog.ts
Normal file
5
providers/kmMovies/catalog.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const catalog = [
|
||||
{ title: "Latest", filter: "" },
|
||||
{ title: "Bollywood", filter: "category/movies/" },
|
||||
{ title: "Dual", filter: "category/dual-audio/" },
|
||||
];
|
||||
64
providers/kmMovies/episodes.ts
Normal file
64
providers/kmMovies/episodes.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
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[] = [];
|
||||
|
||||
$("h4.fittexted_for_content_h4").each((_, h4El) => {
|
||||
const epTitle = $(h4El).text().trim();
|
||||
if (!epTitle) return;
|
||||
|
||||
// Next until next <h4> or <hr> ke andar saare <a> links
|
||||
$(h4El)
|
||||
.nextUntil("h4, hr")
|
||||
.find("a[href]") // sirf <a> tags
|
||||
.each((_, linkEl) => {
|
||||
let href = ($(linkEl).attr("href") || "").trim();
|
||||
if (!href) return;
|
||||
if (!href.startsWith("http")) href = new URL(href, url).href;
|
||||
|
||||
const btnText = $(linkEl).text().trim() || "Watch Episode";
|
||||
|
||||
// --- Sirf SkyDrop links include karo
|
||||
const lowerHref = href.toLowerCase();
|
||||
if (lowerHref.includes("skydro") || lowerHref.includes("flexplayer.buzz")) {
|
||||
episodes.push({
|
||||
title: `${epTitle} - ${btnText}`,
|
||||
link: href,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// --- Sort by episode number extracted from title
|
||||
episodes.sort((a, b) => {
|
||||
const numA = parseInt(a.title.match(/\d+/)?.[0] || "0");
|
||||
const numB = parseInt(b.title.match(/\d+/)?.[0] || "0");
|
||||
return numA - numB;
|
||||
});
|
||||
|
||||
return episodes;
|
||||
} catch (err) {
|
||||
console.error("getEpisodeLinks error:", err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// --- System wrapper
|
||||
export async function getEpisodes({
|
||||
url,
|
||||
providerContext,
|
||||
}: {
|
||||
url: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<EpisodeLink[]> {
|
||||
return await getEpisodeLinks({ url, providerContext });
|
||||
}
|
||||
171
providers/kmMovies/meta.ts
Normal file
171
providers/kmMovies/meta.ts
Normal file
@@ -0,0 +1,171 @@
|
||||
import { Info, Link, ProviderContext } from "../types";
|
||||
|
||||
const kmmHeaders = {
|
||||
Referer: "https://google.com",
|
||||
"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 const getMeta = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
try {
|
||||
const { axios, cheerio } = providerContext;
|
||||
|
||||
if (!link.startsWith("http")) {
|
||||
const baseUrl = await providerContext.getBaseUrl("kmmovies");
|
||||
link = `${baseUrl}${link.startsWith("/") ? "" : "/"}${link}`;
|
||||
}
|
||||
|
||||
const res = await axios.get(link, { headers: kmmHeaders });
|
||||
const $ = cheerio.load(res.data);
|
||||
|
||||
// --- Title
|
||||
const title =
|
||||
$("h1, h2, .animated-text").first().text().trim() ||
|
||||
$("meta[property='og:title']").attr("content")?.trim() ||
|
||||
$("title").text().trim() ||
|
||||
"Unknown";
|
||||
|
||||
// --- Poster Image
|
||||
let image =
|
||||
$("div.wp-slider-container img").first().attr("src") ||
|
||||
$("meta[property='og:image']").attr("content") ||
|
||||
$("meta[name='twitter:image']").attr("content") ||
|
||||
"";
|
||||
if (!image || !image.startsWith("http")) {
|
||||
image = new URL(image || "/placeholder.png", link).href;
|
||||
}
|
||||
|
||||
// --- Synopsis
|
||||
let synopsis = "";
|
||||
$("p").each((_, el) => {
|
||||
const text = $(el).text().trim();
|
||||
if (
|
||||
text &&
|
||||
text.length > 40 &&
|
||||
!text.toLowerCase().includes("download") &&
|
||||
!text.toLowerCase().includes("quality")
|
||||
) {
|
||||
synopsis = text;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!synopsis) {
|
||||
synopsis =
|
||||
$("meta[property='og:description']").attr("content") ||
|
||||
$("meta[name='description']").attr("content") ||
|
||||
"";
|
||||
}
|
||||
|
||||
// --- Tags / Genre
|
||||
const tags: string[] = [];
|
||||
if (res.data.toLowerCase().includes("action")) tags.push("Action");
|
||||
if (res.data.toLowerCase().includes("drama")) tags.push("Drama");
|
||||
if (res.data.toLowerCase().includes("romance")) tags.push("Romance");
|
||||
if (res.data.toLowerCase().includes("thriller")) tags.push("Thriller");
|
||||
|
||||
// --- Cast
|
||||
const cast: string[] = [];
|
||||
$("p").each((_, el) => {
|
||||
const text = $(el).text().trim();
|
||||
if (/starring|cast/i.test(text)) {
|
||||
text.split(",").forEach((name) => cast.push(name.trim()));
|
||||
}
|
||||
});
|
||||
|
||||
// --- Rating
|
||||
let rating =
|
||||
$("p")
|
||||
.text()
|
||||
.match(/IMDb Rating[:\s]*([0-9.]+)/i)?.[1] || "";
|
||||
if (rating && !rating.includes("/")) rating = rating + "/10";
|
||||
|
||||
// --- IMDb ID
|
||||
const imdbLink = $("p a[href*='imdb.com']").attr("href") || "";
|
||||
const imdbId =
|
||||
imdbLink && imdbLink.includes("/tt")
|
||||
? "tt" + imdbLink.split("/tt")[1].split("/")[0]
|
||||
: "";
|
||||
|
||||
// --- Download Links
|
||||
const linkList: Link[] = [];
|
||||
const isSeries = $(".download-options-grid").length > 0; // Series tab structure
|
||||
|
||||
if (isSeries) {
|
||||
// --- Series: loop through each download-card
|
||||
$(".download-card").each((_, card) => {
|
||||
const card$ = $(card);
|
||||
const quality = card$.find(".download-quality-text").text().trim();
|
||||
const size = card$.find(".download-size-info").text().trim() || "";
|
||||
const href = card$.find("a.tabs-download-button").attr("href") || "";
|
||||
if (href) {
|
||||
const titleText = `Download ${quality} ${size}`.trim();
|
||||
linkList.push({
|
||||
title: titleText,
|
||||
episodesLink: href,
|
||||
quality: quality || "AUTO",
|
||||
directLinks: [
|
||||
{
|
||||
link: href,
|
||||
title: titleText,
|
||||
type: "series",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// --- Movie: same as before
|
||||
$("a.modern-download-button").each((_, a) => {
|
||||
const parent = $(a).closest(".modern-option-card");
|
||||
const quality = parent.find(".modern-badge").text().trim() || "AUTO";
|
||||
const href = $(a).attr("href") || "";
|
||||
const titleText = `Download ${quality}`;
|
||||
if (href) {
|
||||
linkList.push({
|
||||
title: titleText,
|
||||
episodesLink: href,
|
||||
quality,
|
||||
directLinks: [
|
||||
{
|
||||
link: href,
|
||||
title: titleText,
|
||||
type: "movie",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
title,
|
||||
synopsis,
|
||||
image,
|
||||
imdbId,
|
||||
type: isSeries ? "series" : "movie",
|
||||
tags,
|
||||
cast,
|
||||
rating,
|
||||
linkList,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error("KMMOVIES getMeta error:", err);
|
||||
return {
|
||||
title: "",
|
||||
synopsis: "",
|
||||
image: "https://via.placeholder.com/300x450",
|
||||
imdbId: "",
|
||||
type: "movie",
|
||||
tags: [],
|
||||
cast: [],
|
||||
rating: "",
|
||||
linkList: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
144
providers/kmMovies/posts.ts
Normal file
144
providers/kmMovies/posts.ts
Normal file
@@ -0,0 +1,144 @@
|
||||
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 = providerContext.getBaseUrl("kmmovies");
|
||||
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[] = [];
|
||||
|
||||
// --- 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(
|
||||
"Cinevood fetchPosts error:",
|
||||
err instanceof Error ? err.message : String(err)
|
||||
);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
70
providers/kmMovies/stream.ts
Normal file
70
providers/kmMovies/stream.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
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",
|
||||
"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",
|
||||
"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/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
|
||||
};
|
||||
|
||||
export async function getStream({
|
||||
link,
|
||||
type,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
type: string;
|
||||
signal: AbortSignal;
|
||||
providerContext: ProviderContext;
|
||||
}) {
|
||||
const { axios, cheerio } = providerContext;
|
||||
|
||||
try {
|
||||
const streamLinks: Stream[] = [];
|
||||
|
||||
// Fetch the page HTML
|
||||
const res = await axios.get(link, { headers, signal });
|
||||
const $ = cheerio.load(res.data);
|
||||
|
||||
const ALLOWED_SERVERS = ["ONE CLICK", "ZIP-ZAP", "ULTRA FAST", "SKYDROP"];
|
||||
// --- Scrape all <a class="download-button"> links
|
||||
$("a.download-button").each((_, el) => {
|
||||
const btn = $(el);
|
||||
const href = btn.attr("href")?.trim();
|
||||
const serverName = btn.text().trim() || "Unknown Server";
|
||||
|
||||
// Check for partial matches in server names
|
||||
const isAllowed = ALLOWED_SERVERS.some(
|
||||
(allowed) =>
|
||||
serverName.toUpperCase().includes(allowed) ||
|
||||
allowed.includes(serverName.toUpperCase())
|
||||
);
|
||||
|
||||
if (href && isAllowed) {
|
||||
streamLinks.push({
|
||||
server: serverName,
|
||||
link: href,
|
||||
type: "mkv", // Boss, mostly KMMOVIES MKV hota hai
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return streamLinks;
|
||||
} catch (error: any) {
|
||||
console.log("getStream error: ", error.message);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user