mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
feat: Add 1cinevood provider
This commit is contained in:
4
providers/1cinevood/catalog.ts
Normal file
4
providers/1cinevood/catalog.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const catalog = [
|
||||
{ title: "Latest", filter: "" },
|
||||
{ title: "Hollywood", filter: "hollywood/" },
|
||||
];
|
||||
81
providers/1cinevood/episodes.ts
Normal file
81
providers/1cinevood/episodes.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { EpisodeLink, ProviderContext } from "../types";
|
||||
|
||||
const formatEpisodeTitle = (fileName: string): string => {
|
||||
try {
|
||||
// Match patterns like S03E01, S03E1, s03e01, etc.
|
||||
const match = fileName.match(/S(\d+)E(\d+)/i);
|
||||
if (match) {
|
||||
const season = match[1].padStart(2, "0");
|
||||
const episode = match[2].padStart(2, "0");
|
||||
return `S${season} E${episode}`;
|
||||
}
|
||||
return fileName;
|
||||
} catch {
|
||||
return fileName;
|
||||
}
|
||||
};
|
||||
|
||||
export const getEpisodes = async function ({
|
||||
url,
|
||||
providerContext,
|
||||
}: {
|
||||
url: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<EpisodeLink[]> {
|
||||
const { axios, cheerio, commonHeaders: headers } = providerContext;
|
||||
console.log("getEpisodeLinks", url);
|
||||
try {
|
||||
const baseUrl = url.split("/").slice(0, 3).join("/");
|
||||
const id = url.split("/").filter(Boolean).pop() || "";
|
||||
const apiUrl = `${baseUrl}/api/packs/${id}`;
|
||||
console.log("apiUrl:", apiUrl);
|
||||
|
||||
let res;
|
||||
try {
|
||||
res = await axios.get(apiUrl, {
|
||||
headers: headers,
|
||||
});
|
||||
} catch (error: any) {
|
||||
// If 404, try alternative API endpoint
|
||||
if (error.response?.status === 404) {
|
||||
const alternativeUrl = `${baseUrl}/api/s/${id}/`;
|
||||
console.log("Trying alternative URL:", alternativeUrl);
|
||||
|
||||
const altRes = await axios.get(alternativeUrl, {
|
||||
headers: headers,
|
||||
});
|
||||
|
||||
// Check if hubcloud is available
|
||||
if (altRes.data?.hasHubcloud) {
|
||||
const hubcloudUrl = `${baseUrl}/api/s/${id}/hubcloud`;
|
||||
return [
|
||||
{
|
||||
title: formatEpisodeTitle(altRes.data.fileName || "Movie"),
|
||||
link: hubcloudUrl,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
const episodes: EpisodeLink[] = [];
|
||||
|
||||
const items = res.data?.pack?.items || [];
|
||||
|
||||
for (const item of items) {
|
||||
if (item.file_name && item.hubcloud_link) {
|
||||
episodes.push({
|
||||
title: formatEpisodeTitle(item.file_name),
|
||||
link: item.hubcloud_link,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return episodes;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
167
providers/1cinevood/meta.ts
Normal file
167
providers/1cinevood/meta.ts
Normal file
@@ -0,0 +1,167 @@
|
||||
import { Info, Link, ProviderContext } from "../types";
|
||||
|
||||
// Headers
|
||||
const headers = {
|
||||
Accept:
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,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",
|
||||
"Sec-Fetch-Site": "none",
|
||||
"Sec-Fetch-User": "?1",
|
||||
// NOTE: Cookies often expire or change, use caution with hardcoding.
|
||||
Cookie:
|
||||
"xla=s4t; _ga=GA1.1.1081149560.1756378968; _ga_BLZGKYN5PF=GS2.1.s1756378968$o1$g1$t1756378984$j44$l0$h0",
|
||||
"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 const getMeta = async function ({
|
||||
link,
|
||||
providerContext,
|
||||
}: {
|
||||
link: string;
|
||||
providerContext: ProviderContext;
|
||||
}): Promise<Info> {
|
||||
const { axios, cheerio } = providerContext;
|
||||
const url = link;
|
||||
const baseUrl = url.split("/").slice(0, 3).join("/");
|
||||
|
||||
const emptyResult: Info = {
|
||||
title: "",
|
||||
synopsis: "",
|
||||
image: "",
|
||||
imdbId: "",
|
||||
type: "movie",
|
||||
linkList: [],
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.get(url, {
|
||||
headers: { ...headers, Referer: baseUrl },
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const infoContainer = $(".entry-content, .post-inner").first();
|
||||
|
||||
const result: Info = {
|
||||
title: "",
|
||||
synopsis: "",
|
||||
image: "",
|
||||
imdbId: "",
|
||||
type: "movie",
|
||||
linkList: [],
|
||||
};
|
||||
|
||||
// --- Title ---
|
||||
// Prioritize title from the main download heading
|
||||
const downloadTitleMatch = infoContainer
|
||||
.find("h6 span")
|
||||
.first()
|
||||
.text()
|
||||
.match(/(.*)\s*\(\d{4}\)/);
|
||||
if (downloadTitleMatch) {
|
||||
result.title = downloadTitleMatch[1].trim();
|
||||
}
|
||||
|
||||
// Fallback to movie title selector if main heading failed
|
||||
if (!result.title || result.title === "Unknown Title") {
|
||||
const rawTitle = $("#movie_title a").text().trim();
|
||||
// Clean up title from IMDb box: "Kantara A Legend: Chapter 1<small></small>" -> "Kantara A Legend: Chapter 1"
|
||||
result.title =
|
||||
rawTitle.replace(/<small>.*<\/small>/, "").trim() || "Unknown Title";
|
||||
}
|
||||
|
||||
// --- Type determination ---
|
||||
// Check if the page title (or URL) suggests a series, otherwise default to movie
|
||||
const firstDownloadHeadingText = infoContainer.find("h6").first().text();
|
||||
// Improved check: look for Season/Episode patterns (S01, E01, Season 1)
|
||||
const isSeries =
|
||||
firstDownloadHeadingText.includes("S01") ||
|
||||
firstDownloadHeadingText.includes("E01") ||
|
||||
firstDownloadHeadingText.toLowerCase().includes("season");
|
||||
result.type = isSeries ? "series" : "movie";
|
||||
|
||||
// --- IMDb ID ---
|
||||
const imdbMatch = $("#movie_title a").attr("href")?.match(/tt\d+/);
|
||||
result.imdbId = imdbMatch ? imdbMatch[0] : "";
|
||||
|
||||
// --- Image ---
|
||||
// Search for an image within the info container
|
||||
let image =
|
||||
infoContainer.find('img[decoding="async"]').first().attr("src") || "";
|
||||
if (image.startsWith("//")) image = "https:" + image;
|
||||
result.image = image;
|
||||
|
||||
// --- Synopsis ---
|
||||
result.synopsis =
|
||||
infoContainer
|
||||
.find("#summary b:contains('Summary:')")
|
||||
.parent()
|
||||
.text()
|
||||
.replace("Summary:", "")
|
||||
.trim() || "";
|
||||
|
||||
// --- LinkList extraction (Updated for flexible title and link structure) ---
|
||||
const links: Link[] = [];
|
||||
|
||||
// Select all <h6> tags that contain quality/file size info.
|
||||
const qualityBlocks = infoContainer.find("h6").filter((_, el) => {
|
||||
return !$(el).text().includes("Watch Online");
|
||||
});
|
||||
|
||||
qualityBlocks.each((index, element) => {
|
||||
const el = $(element);
|
||||
const fullTitle = el.text().trim();
|
||||
|
||||
// Extract Quality (e.g., 1080p, 720p, 480p)
|
||||
const qualityMatch = fullTitle.match(/\d{3,4}p\b/)?.[0] || "";
|
||||
// Extract File Size (content within the last pair of brackets, e.g., 11.78 GB)
|
||||
// Look for any bracketed text at the end of the title
|
||||
const fileSizeMatch =
|
||||
fullTitle.match(/\[([^\]]+)\](?=[^\[]*$)/)?.[1] || "";
|
||||
|
||||
// Get all immediate sibling elements until the next <h6> or <hr>.
|
||||
const nextSiblings = el.nextUntil("h6, hr");
|
||||
|
||||
// Find all <a> elements that are descendants of the siblings OR are the siblings themselves
|
||||
nextSiblings
|
||||
.find("a")
|
||||
.add(nextSiblings.filter("a"))
|
||||
.each((i, btn) => {
|
||||
const btnEl = $(btn);
|
||||
const link = btnEl.attr("href");
|
||||
|
||||
// Extract the season (S01) and Episode (E01) info
|
||||
const seMatch = fullTitle.match(/(S\d{2}E\d{2}|S\d{2}|E\d{2})/);
|
||||
const seasonEpisode = seMatch ? `${seMatch[0]} | ` : "";
|
||||
|
||||
links.push({
|
||||
// Final title for the link entry (e.g., S01 | 1080p | 11.78 GB)
|
||||
title: `${seasonEpisode}${qualityMatch}${
|
||||
fileSizeMatch ? " | " + fileSizeMatch : ""
|
||||
}`
|
||||
.trim()
|
||||
.replace(/\|$/, "")
|
||||
.trim(),
|
||||
quality: qualityMatch,
|
||||
// Keep original structure: episodesLink is the first direct download link
|
||||
episodesLink: link,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
result.linkList = links;
|
||||
return result;
|
||||
} catch (err) {
|
||||
console.log("getMeta error:", err);
|
||||
return emptyResult;
|
||||
}
|
||||
};
|
||||
142
providers/1cinevood/posts.ts
Normal file
142
providers/1cinevood/posts.ts
Normal file
@@ -0,0 +1,142 @@
|
||||
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("1cinevood");
|
||||
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 : new URL(href, url).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 [];
|
||||
}
|
||||
}
|
||||
48
providers/1cinevood/stream.ts
Normal file
48
providers/1cinevood/stream.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
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",
|
||||
"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",
|
||||
Cookie:
|
||||
"xla=s4t; _ga=GA1.1.1081149560.1756378968; _ga_BLZGKYN5PF=GS2.1.s1756378968$o1$g1$t1756378984$j44$l0$h0",
|
||||
"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 { extractors } = providerContext;
|
||||
const { hubcloudExtracter } = extractors;
|
||||
try {
|
||||
const hubcloudLink = await hubcloudExtracter(link, signal);
|
||||
|
||||
return hubcloudLink;
|
||||
} catch (error: any) {
|
||||
console.log("getStream error: ", error);
|
||||
if (error.message.includes("Aborted")) {
|
||||
} else {
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user