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:
1
dist/1cinevood/catalog.js
vendored
Normal file
1
dist/1cinevood/catalog.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.catalog=void 0,exports.catalog=[{title:"Latest",filter:""},{title:"Hollywood",filter:"hollywood/"}];
|
||||
1
dist/1cinevood/episodes.js
vendored
Normal file
1
dist/1cinevood/episodes.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P(function(resolve){resolve(value)})).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getEpisodes=void 0;const formatEpisodeTitle=fileName=>{try{const match=fileName.match(/S(\d+)E(\d+)/i);if(match){const season=match[1].padStart(2,"0");return`S${season} E${match[2].padStart(2,"0")}`}return fileName}catch(_a){return fileName}},getEpisodes=function(_a){return __awaiter(this,arguments,void 0,function*({url:url,providerContext:providerContext}){var _b,_c,_d,_e;const{axios:axios,cheerio:cheerio,commonHeaders:headers}=providerContext;try{const baseUrl=url.split("/").slice(0,3).join("/"),id=url.split("/").filter(Boolean).pop()||"",apiUrl=`${baseUrl}/api/packs/${id}`;let res;try{res=yield axios.get(apiUrl,{headers:headers})}catch(error){if(404===(null===(_b=error.response)||void 0===_b?void 0:_b.status)){const alternativeUrl=`${baseUrl}/api/s/${id}/`,altRes=yield axios.get(alternativeUrl,{headers:headers});if(null===(_c=altRes.data)||void 0===_c?void 0:_c.hasHubcloud){const hubcloudUrl=`${baseUrl}/api/s/${id}/hubcloud`;return[{title:formatEpisodeTitle(altRes.data.fileName||"Movie"),link:hubcloudUrl}]}return[]}throw error}const episodes=[],items=(null===(_e=null===(_d=res.data)||void 0===_d?void 0:_d.pack)||void 0===_e?void 0:_e.items)||[];for(const item of items)item.file_name&&item.hubcloud_link&&episodes.push({title:formatEpisodeTitle(item.file_name),link:item.hubcloud_link});return episodes}catch(err){throw err}})};exports.getEpisodes=getEpisodes;
|
||||
1
dist/1cinevood/meta.js
vendored
Normal file
1
dist/1cinevood/meta.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P(function(resolve){resolve(value)})).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getMeta=void 0;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",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"},getMeta=function(_a){return __awaiter(this,arguments,void 0,function*({link:link,providerContext:providerContext}){var _b;const{axios:axios,cheerio:cheerio}=providerContext,url=link,baseUrl=url.split("/").slice(0,3).join("/"),emptyResult={title:"",synopsis:"",image:"",imdbId:"",type:"movie",linkList:[]};try{const response=yield axios.get(url,{headers:Object.assign(Object.assign({},headers),{Referer:baseUrl})}),$=cheerio.load(response.data),infoContainer=$(".entry-content, .post-inner").first(),result={title:"",synopsis:"",image:"",imdbId:"",type:"movie",linkList:[]},downloadTitleMatch=infoContainer.find("h6 span").first().text().match(/(.*)\s*\(\d{4}\)/);if(downloadTitleMatch&&(result.title=downloadTitleMatch[1].trim()),!result.title||"Unknown Title"===result.title){const rawTitle=$("#movie_title a").text().trim();result.title=rawTitle.replace(/<small>.*<\/small>/,"").trim()||"Unknown Title"}const firstDownloadHeadingText=infoContainer.find("h6").first().text(),isSeries=firstDownloadHeadingText.includes("S01")||firstDownloadHeadingText.includes("E01")||firstDownloadHeadingText.toLowerCase().includes("season");result.type=isSeries?"series":"movie";const imdbMatch=null===(_b=$("#movie_title a").attr("href"))||void 0===_b?void 0:_b.match(/tt\d+/);result.imdbId=imdbMatch?imdbMatch[0]:"";let image=infoContainer.find('img[decoding="async"]').first().attr("src")||"";image.startsWith("//")&&(image="https:"+image),result.image=image,result.synopsis=infoContainer.find("#summary b:contains('Summary:')").parent().text().replace("Summary:","").trim()||"";const links=[];return infoContainer.find("h6").filter((_,el)=>!$(el).text().includes("Watch Online")).each((index,element)=>{var _a,_b;const el=$(element),fullTitle=el.text().trim(),qualityMatch=(null===(_a=fullTitle.match(/\d{3,4}p\b/))||void 0===_a?void 0:_a[0])||"",fileSizeMatch=(null===(_b=fullTitle.match(/\[([^\]]+)\](?=[^\[]*$)/))||void 0===_b?void 0:_b[1])||"",nextSiblings=el.nextUntil("h6, hr");nextSiblings.find("a").add(nextSiblings.filter("a")).each((i,btn)=>{const link=$(btn).attr("href"),seMatch=fullTitle.match(/(S\d{2}E\d{2}|S\d{2}|E\d{2})/),seasonEpisode=seMatch?`${seMatch[0]} | `:"";links.push({title:`${seasonEpisode}${qualityMatch}${fileSizeMatch?" | "+fileSizeMatch:""}`.trim().replace(/\|$/,"").trim(),quality:qualityMatch,episodesLink:link})})}),result.linkList=links,result}catch(err){return emptyResult}})};exports.getMeta=getMeta;
|
||||
1
dist/1cinevood/posts.js
vendored
Normal file
1
dist/1cinevood/posts.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P(function(resolve){resolve(value)})).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPosts=getPosts,exports.getSearchPosts=getSearchPosts;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"};function getPosts(_a){return __awaiter(this,arguments,void 0,function*({filter:filter,page:page=1,signal:signal,providerContext:providerContext}){return fetchPosts({filter:filter,page:page,query:"",signal:signal,providerContext:providerContext})})}function getSearchPosts(_a){return __awaiter(this,arguments,void 0,function*({searchQuery:searchQuery,page:page=1,signal:signal,providerContext:providerContext}){return fetchPosts({filter:"",page:page,query:searchQuery,signal:signal,providerContext:providerContext})})}function fetchPosts(_a){return __awaiter(this,arguments,void 0,function*({filter:filter,query:query,page:page=1,signal:signal,providerContext:providerContext}){try{const baseUrl=yield providerContext.getBaseUrl("1cinevood");let url;url=query&&query.trim()?`${baseUrl}/?s=${encodeURIComponent(query)}${page>1?`&paged=${page}`:""}`:filter?filter.startsWith("/")?`${baseUrl}${filter.replace(/\/$/,"")}${page>1?`/page/${page}`:""}`:`${baseUrl}/${filter}${page>1?`/page/${page}`:""}`:`${baseUrl}${page>1?`/page/${page}`:""}`;const{axios:axios,cheerio:cheerio}=providerContext,res=yield axios.get(url,{headers:defaultHeaders,signal:signal}),$=cheerio.load(res.data||""),resolveUrl=href=>(null==href?void 0:href.startsWith("http"))?href:new URL(href,url).href,seen=new Set,catalog=[],POST_SELECTORS=[".pstr_box","article",".result-item",".post",".item",".thumbnail",".latest-movies",".movie-item"].join(",");return $(POST_SELECTORS).each((_,el)=>{var _a;const card=$(el);let link=card.find("a[href]").first().attr("href")||"";if(!link)return;if(link=resolveUrl(link),seen.has(link))return;let title=card.find("h2").first().text().trim()||(null===(_a=card.find("a[title]").first().attr("title"))||void 0===_a?void 0:_a.trim())||card.text().trim();if(title=title.replace(/\[.*?\]/g,"").replace(/\(.+?\)/g,"").replace(/\s{2,}/g," ").trim(),!title)return;const img=card.find("img").first().attr("src")||card.find("img").first().attr("data-src")||card.find("img").first().attr("data-original")||"",image=img?resolveUrl(img):"";seen.add(link),catalog.push({title:title,link:link,image:image})}),catalog.slice(0,100)}catch(err){return[]}})}
|
||||
1
dist/1cinevood/stream.js
vendored
Normal file
1
dist/1cinevood/stream.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P(function(resolve){resolve(value)})).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStream=getStream;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"};function getStream(_a){return __awaiter(this,arguments,void 0,function*({link:link,type:type,signal:signal,providerContext:providerContext}){const{extractors:extractors}=providerContext,{hubcloudExtracter:hubcloudExtracter}=extractors;try{return yield hubcloudExtracter(link,signal)}catch(error){return error.message.includes("Aborted"),[]}})}
|
||||
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