fix: update version to 1.17 in manifest.json and improve meta and posts data extraction logic

This commit is contained in:
Himanshu
2026-02-23 20:49:06 +05:30
parent 316f4c7e0c
commit 099b4aba4f
5 changed files with 117 additions and 35 deletions

2
dist/vega/meta.js vendored

File diff suppressed because one or more lines are too long

2
dist/vega/posts.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@
{ {
"display_name": "VegaMovies", "display_name": "VegaMovies",
"value": "vega", "value": "vega",
"version": "1.16", "version": "1.17",
"icon": "", "icon": "",
"type": "global", "type": "global",
"disabled": false "disabled": false

View File

@@ -40,34 +40,91 @@ 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
const titleRegex = /Name: (.+)/; let title = $("h1.post-title").text().trim();
const title = heading?.next("p")?.text()?.match(titleRegex)?.[1] || ""; if (!title) {
const heading = infoContainer?.find("h3");
const titleRegex = /Name: (.+)/;
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 categories = $(".post-categories a")
.map((i, el) => $(el).text().toLowerCase())
.get();
if (
categories.some(
(c) => c.includes("series") || c.includes("drama") || c.includes("anime")
) ||
title.toLowerCase().includes("season")
) {
type = "series";
} else {
const heading = infoContainer?.find("h3");
if (heading?.next("p")?.text()?.includes("Series Name")) {
type = "series";
}
}
// console.log(type);
// synopsis // synopsis
const synopsisNode = //@ts-ignore let synopsis = "";
infoContainer?.find("p")?.next("h3,h4")?.next("p")?.[0]?.children?.[0]; const synopsisHeader = $("h3").filter(
const synopsis = (i, el) =>
synopsisNode && "data" in synopsisNode ? synopsisNode.data : ""; $(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
infoContainer?.find("p")?.next("h3,h4")?.next("p")?.[0]?.children?.[0];
synopsis =
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;
} }
@@ -75,7 +132,21 @@ export const getMeta = async ({
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,14 +157,22 @@ 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 =
?.next() element
.find(".dwd-button") ?.next()
.text() .find(".dwd-button")
.toLowerCase() .text()
.includes("download") .toLowerCase()
? element?.next().find(".dwd-button")?.parent()?.attr("href") .includes("download") ||
: ""; 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

View File

@@ -72,7 +72,7 @@ async function posts(
signal: AbortSignal, signal: AbortSignal,
headers: Record<string, string> = {}, headers: Record<string, string> = {},
axios: ProviderContext["axios"], axios: ProviderContext["axios"],
cheerio: ProviderContext["cheerio"] cheerio: ProviderContext["cheerio"],
): Promise<Post[]> { ): Promise<Post[]> {
try { try {
const urlRes = await fetch(url, { const urlRes = await fetch(url, {
@@ -84,8 +84,8 @@ async function posts(
}); });
const $ = cheerio.load(await urlRes.text()); const $ = cheerio.load(await urlRes.text());
const posts: Post[] = []; const posts: Post[] = [];
$(".blog-items,.post-list,#archive-container") $(".blog-items,.post-list,#archive-container,.movies-grid")
?.children("article,.entry-list-item") ?.children("article,.entry-list-item,a")
?.each((index, element) => { ?.each((index, element) => {
const post = { const post = {
title: ( title: (
@@ -99,7 +99,10 @@ async function posts(
"" ""
).trim(), ).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") ||