mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
feat: update version to 2.0 in manifest.json; refactor getMeta and getPosts functions for improved data extraction
This commit is contained in:
2
dist/luxMovies/meta.js
vendored
2
dist/luxMovies/meta.js
vendored
File diff suppressed because one or more lines are too long
2
dist/luxMovies/posts.js
vendored
2
dist/luxMovies/posts.js
vendored
File diff suppressed because one or more lines are too long
@@ -290,7 +290,7 @@
|
|||||||
{
|
{
|
||||||
"display_name": "RogMovies",
|
"display_name": "RogMovies",
|
||||||
"value": "luxMovies",
|
"value": "luxMovies",
|
||||||
"version": "1.9",
|
"version": "2.0",
|
||||||
"icon": "",
|
"icon": "",
|
||||||
"type": "india",
|
"type": "india",
|
||||||
"disabled": false
|
"disabled": false
|
||||||
|
|||||||
@@ -40,42 +40,103 @@ export const getMeta = async ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const $ = cheerio.load(response.data);
|
const $ = cheerio.load(response.data);
|
||||||
const infoContainer = $(".entry-content,.post-inner");
|
const infoContainer = $(
|
||||||
const heading = infoContainer?.find("h3");
|
".entry-content, .post-inner, .post-content, .page-body",
|
||||||
const imdbId =
|
);
|
||||||
//@ts-ignore
|
|
||||||
heading?.next("p")?.find("a")?.[0]?.attribs?.href?.match(/tt\d+/g)?.[0] ||
|
|
||||||
infoContainer.text().match(/tt\d+/g)?.[0] ||
|
|
||||||
"";
|
|
||||||
// console.log(imdbId)
|
|
||||||
|
|
||||||
const type = heading?.next("p")?.text()?.includes("Series Name")
|
|
||||||
? "series"
|
|
||||||
: "movie";
|
|
||||||
// console.log(type);
|
|
||||||
// title
|
// title
|
||||||
|
let title = $("h1.post-title").text().trim();
|
||||||
|
if (!title) {
|
||||||
|
const heading = infoContainer?.find("h3");
|
||||||
const titleRegex = /Name: (.+)/;
|
const titleRegex = /Name: (.+)/;
|
||||||
const title = heading?.next("p")?.text()?.match(titleRegex)?.[1] || "";
|
title = heading?.next("p")?.text()?.match(titleRegex)?.[1] || "";
|
||||||
|
}
|
||||||
// console.log(title);
|
// console.log(title);
|
||||||
|
|
||||||
|
// imdbId
|
||||||
|
let imdbId =
|
||||||
|
$('a[href*="imdb.com"]').attr("href")?.match(/tt\d+/)?.[0] || "";
|
||||||
|
if (!imdbId) {
|
||||||
|
const heading = infoContainer?.find("h3");
|
||||||
|
imdbId =
|
||||||
|
//@ts-ignore
|
||||||
|
heading
|
||||||
|
?.next("p")
|
||||||
|
?.find("a")?.[0]
|
||||||
|
?.attribs?.href?.match(/tt\d+/g)?.[0] ||
|
||||||
|
infoContainer.text().match(/tt\d+/g)?.[0] ||
|
||||||
|
"";
|
||||||
|
}
|
||||||
|
// console.log(imdbId)
|
||||||
|
|
||||||
|
// type
|
||||||
|
let type = "movie";
|
||||||
|
|
||||||
|
const heading = infoContainer?.find("h3");
|
||||||
|
if (heading?.next("p")?.text()?.includes("Series Name")) {
|
||||||
|
type = "series";
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(type);
|
||||||
|
|
||||||
// synopsis
|
// synopsis
|
||||||
|
let synopsis = "";
|
||||||
|
const synopsisHeader = $("h3").filter(
|
||||||
|
(i, el) =>
|
||||||
|
$(el).text().includes("SYNOPSIS/PLOT") || $(el).text().includes("Plot"),
|
||||||
|
);
|
||||||
|
if (synopsisHeader.length > 0) {
|
||||||
|
synopsis = synopsisHeader.next("p").text().trim();
|
||||||
|
}
|
||||||
|
if (!synopsis) {
|
||||||
const synopsisNode = //@ts-ignore
|
const synopsisNode = //@ts-ignore
|
||||||
infoContainer?.find("p")?.next("h3,h4")?.next("p")?.[0]?.children?.[0];
|
infoContainer?.find("p")?.next("h3,h4")?.next("p")?.[0]?.children?.[0];
|
||||||
const synopsis =
|
synopsis =
|
||||||
synopsisNode && "data" in synopsisNode ? synopsisNode.data : "";
|
synopsisNode && "data" in synopsisNode ? synopsisNode.data : "";
|
||||||
|
}
|
||||||
// console.log(synopsis);
|
// console.log(synopsis);
|
||||||
|
|
||||||
// image
|
// image
|
||||||
let image =
|
let image =
|
||||||
infoContainer?.find("img[data-lazy-src]")?.attr("data-lazy-src") || "";
|
infoContainer?.find("img[data-lazy-src]")?.attr("data-lazy-src") ||
|
||||||
|
infoContainer
|
||||||
|
?.find("img")
|
||||||
|
?.filter((i, el) => {
|
||||||
|
const src = $(el).attr("src");
|
||||||
|
return (
|
||||||
|
!!src &&
|
||||||
|
!src.includes("logo") &&
|
||||||
|
!src.includes("svg") &&
|
||||||
|
!src.includes("placeholder") &&
|
||||||
|
!src.includes("icon")
|
||||||
|
);
|
||||||
|
})
|
||||||
|
?.first()
|
||||||
|
?.attr("src") ||
|
||||||
|
"";
|
||||||
|
|
||||||
if (image.startsWith("//")) {
|
if (image.startsWith("//")) {
|
||||||
image = "https:" + image;
|
image = "https:" + image;
|
||||||
}
|
}
|
||||||
// console.log(image);
|
// console.log(image);
|
||||||
|
|
||||||
// console.log({title, synopsis, image, imdbId, type});
|
console.log({ title, synopsis, image, imdbId, type });
|
||||||
/// Links
|
/// Links
|
||||||
const hr = infoContainer?.first()?.find("hr");
|
let hr = infoContainer?.first()?.find("hr");
|
||||||
|
|
||||||
|
// Try to find the HR before the download buttons if possible
|
||||||
|
const firstButton = $(".dwd-button").first();
|
||||||
|
if (firstButton.length > 0) {
|
||||||
|
const containerP = firstButton.closest("p");
|
||||||
|
let prev = containerP.prev();
|
||||||
|
while (prev.length && !prev.is("hr")) {
|
||||||
|
prev = prev.prev();
|
||||||
|
}
|
||||||
|
if (prev.is("hr")) {
|
||||||
|
hr = prev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const list = hr?.nextUntil("hr");
|
const list = hr?.nextUntil("hr");
|
||||||
const links: Link[] = [];
|
const links: Link[] = [];
|
||||||
list.each((index, element: any) => {
|
list.each((index, element: any) => {
|
||||||
@@ -86,24 +147,26 @@ export const getMeta = async ({
|
|||||||
const quality = element?.text().match(/\d+p\b/)?.[0] || "";
|
const quality = element?.text().match(/\d+p\b/)?.[0] || "";
|
||||||
// console.log(title);
|
// console.log(title);
|
||||||
// movieLinks
|
// movieLinks
|
||||||
const movieLinks = element
|
const movieLinks =
|
||||||
|
element
|
||||||
?.next()
|
?.next()
|
||||||
.find(".dwd-button")
|
.find(".dwd-button")
|
||||||
.text()
|
.text()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.includes("download")
|
.includes("download") ||
|
||||||
? element?.next().find(".dwd-button")?.parent()?.attr("href")
|
element.next().find("a").text().toLowerCase().includes("download")
|
||||||
|
? element?.next().find(".dwd-button")?.parent()?.attr("href") ||
|
||||||
|
element?.next().find("a[href]")?.attr("href")
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
// episode links
|
// episode links
|
||||||
const vcloudLinks = element
|
const vcloudLinks = element
|
||||||
?.next()
|
?.next()
|
||||||
.find(
|
.find(
|
||||||
".btn-outline[style='background:linear-gradient(135deg,#ed0b0b,#f2d152); color: white;'],.btn-outline[style='background:linear-gradient(135deg,#ed0b0b,#f2d152); color: #fdf8f2;']"
|
".btn-outline[style='background:linear-gradient(135deg,#ed0b0b,#f2d152); color: white;'],.btn-outline[style='background:linear-gradient(135deg,#ed0b0b,#f2d152); color: #fdf8f2;'],.btn-outline[style='background:linear-gradient(135deg,#ed0b0b,#f2d152);color: white']",
|
||||||
)
|
)
|
||||||
?.parent()
|
?.parent()
|
||||||
?.attr("href");
|
?.attr("href");
|
||||||
console.log(title);
|
|
||||||
const episodesLink =
|
const episodesLink =
|
||||||
(vcloudLinks
|
(vcloudLinks
|
||||||
? vcloudLinks
|
? vcloudLinks
|
||||||
@@ -118,7 +181,7 @@ export const getMeta = async ({
|
|||||||
element
|
element
|
||||||
?.next()
|
?.next()
|
||||||
.find(
|
.find(
|
||||||
".btn-outline[style='background:linear-gradient(135deg,#0ebac3,#09d261); color: white;']"
|
".btn-outline[style='background:linear-gradient(135deg,#0ebac3,#09d261); color: white;']",
|
||||||
)
|
)
|
||||||
?.parent()
|
?.parent()
|
||||||
?.attr("href");
|
?.attr("href");
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ export const getPosts = async ({
|
|||||||
signal: AbortSignal;
|
signal: AbortSignal;
|
||||||
providerContext: ProviderContext;
|
providerContext: ProviderContext;
|
||||||
}): Promise<Post[]> => {
|
}): Promise<Post[]> => {
|
||||||
const { getBaseUrl } = providerContext;
|
const { getBaseUrl, axios, cheerio } = providerContext;
|
||||||
const baseUrl = await getBaseUrl("lux");
|
const baseUrl = await getBaseUrl("Vega");
|
||||||
|
|
||||||
console.log("vegaGetPosts baseUrl:", providerValue, baseUrl);
|
console.log("vegaGetPosts baseUrl:", providerValue, baseUrl);
|
||||||
const url = `${baseUrl}/${filter}/page/${page}/`;
|
const url = `${baseUrl}/${filter}/page/${page}/`;
|
||||||
console.log("lux url:", url);
|
console.log("vegaGetPosts url:", url);
|
||||||
return posts(url, signal, providerContext);
|
return posts(baseUrl, url, signal, headers, axios, cheerio);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSearchPosts = async ({
|
export const getSearchPosts = async ({
|
||||||
@@ -56,58 +56,96 @@ export const getSearchPosts = async ({
|
|||||||
signal: AbortSignal;
|
signal: AbortSignal;
|
||||||
providerContext: ProviderContext;
|
providerContext: ProviderContext;
|
||||||
}): Promise<Post[]> => {
|
}): Promise<Post[]> => {
|
||||||
const { getBaseUrl } = providerContext;
|
const { getBaseUrl, axios, cheerio } = providerContext;
|
||||||
const baseUrl = await getBaseUrl("lux");
|
const baseUrl = await getBaseUrl("Vega");
|
||||||
|
|
||||||
console.log("vegaGetPosts baseUrl:", providerValue, baseUrl);
|
console.log("vegaGetPosts baseUrl:", providerValue, baseUrl);
|
||||||
const url =
|
const url = `${baseUrl}/search.php?q=${searchQuery}&page=${page}`;
|
||||||
page === 1
|
console.log("vegaGetPosts url:", url);
|
||||||
? `https://c.8man.workers.dev/?url=${baseUrl}/?s=${searchQuery}`
|
|
||||||
: `https://c.8man.workers.dev/?url=${baseUrl}/page/${page}/?s=${searchQuery}`;
|
|
||||||
console.log("lux url:", url);
|
|
||||||
|
|
||||||
return posts(url, signal, providerContext);
|
try {
|
||||||
|
const response = await axios.get(url, {
|
||||||
|
headers: {
|
||||||
|
...headers,
|
||||||
|
Referer: baseUrl,
|
||||||
|
},
|
||||||
|
signal,
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
const posts: Post[] = [];
|
||||||
|
|
||||||
|
if (data?.hits) {
|
||||||
|
data.hits.forEach((hit: any) => {
|
||||||
|
const doc = hit.document;
|
||||||
|
const post = {
|
||||||
|
title: doc.post_title.replace("Download", "").trim(),
|
||||||
|
link: doc.permalink.startsWith("http")
|
||||||
|
? doc.permalink
|
||||||
|
: `${baseUrl}${doc.permalink}`,
|
||||||
|
image: doc.post_thumbnail,
|
||||||
|
};
|
||||||
|
posts.push(post);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return posts;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("vegaGetSearchPosts error:", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function posts(
|
async function posts(
|
||||||
|
baseUrl: string,
|
||||||
url: string,
|
url: string,
|
||||||
signal: AbortSignal,
|
signal: AbortSignal,
|
||||||
providerContext: ProviderContext
|
headers: Record<string, string> = {},
|
||||||
|
axios: ProviderContext["axios"],
|
||||||
|
cheerio: ProviderContext["cheerio"],
|
||||||
): Promise<Post[]> {
|
): Promise<Post[]> {
|
||||||
try {
|
try {
|
||||||
const { axios, cheerio } = providerContext;
|
|
||||||
const urlRes = await fetch(url, {
|
const urlRes = await fetch(url, {
|
||||||
headers: {
|
headers: {
|
||||||
...headers,
|
...headers,
|
||||||
Referer: url,
|
Referer: baseUrl,
|
||||||
},
|
},
|
||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
const $ = cheerio.load(await urlRes.text());
|
const $ = cheerio.load(await urlRes.text());
|
||||||
const posts: Post[] = [];
|
const posts: Post[] = [];
|
||||||
$(".blog-items")
|
$(".blog-items,.post-list,#archive-container,.movies-grid")
|
||||||
?.children("article")
|
?.children("article,.entry-list-item,a")
|
||||||
?.each((index, element) => {
|
?.each((index, element) => {
|
||||||
const post = {
|
const post = {
|
||||||
title:
|
title: (
|
||||||
$(element)
|
$(element)
|
||||||
?.find("a")
|
?.find(".entry-title,.poster-title")
|
||||||
?.attr("title")
|
?.text()
|
||||||
?.replace("Download", "")
|
?.replace("Download", "")
|
||||||
?.match(/^(.*?)\s*\((\d{4})\)|^(.*?)\s*\((Season \d+)\)/)?.[0] ||
|
?.match(/^(.*?)\s*\((\d{4})\)|^(.*?)\s*\((Season \d+)\)/)?.[0] ||
|
||||||
$(element)?.find("a")?.attr("title")?.replace("Download", "") ||
|
$(element)?.find("a")?.attr("title")?.replace("Download", "") ||
|
||||||
"",
|
$(element)
|
||||||
|
?.find(".post-title,.poster-title")
|
||||||
|
.text()
|
||||||
|
?.replace("Download", "") ||
|
||||||
|
""
|
||||||
|
).trim(),
|
||||||
|
|
||||||
link: $(element)?.find("a")?.attr("href") || "",
|
link:
|
||||||
|
$(element)?.find("a")?.attr("href") ||
|
||||||
|
$(element)?.attr("href") ||
|
||||||
|
"",
|
||||||
image:
|
image:
|
||||||
$(element).find("a").find("img").attr("data-lazy-src") ||
|
$(element).find("a").find("img").attr("data-lazy-src") ||
|
||||||
$(element).find("a").find("img").attr("data-src") ||
|
$(element).find("a").find("img").attr("data-src") ||
|
||||||
$(element).find("a").find("img").attr("src") ||
|
$(element).find("a").find("img").attr("src") ||
|
||||||
|
$(element).find("img").attr("src") ||
|
||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
if (post.image.startsWith("//")) {
|
if (post.image.startsWith("//")) {
|
||||||
post.image = "https:" + post.image;
|
post.image = "https:" + post.image;
|
||||||
}
|
}
|
||||||
|
console.log("vegaGetPosts post:", post);
|
||||||
posts.push(post);
|
posts.push(post);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user