mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
fix: Update getMeta function to handle missing title, synopsis, and image
This commit is contained in:
2
dist/mod/meta.js
vendored
2
dist/mod/meta.js
vendored
@@ -1 +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 getMeta=function(_a){return __awaiter(this,arguments,void 0,function*({link:link,providerContext:providerContext}){var _b;try{const{axios:axios,cheerio:cheerio}=providerContext,url=link,data=(yield axios.get(url)).data,$=cheerio.load(data),meta={title:$(".imdbwp__title").text(),synopsis:$(".imdbwp__teaser").text(),image:$(".imdbwp__thumb").find("img").attr("src")||"",imdbId:(null===(_b=$(".imdbwp__link").attr("href"))||void 0===_b?void 0:_b.split("/")[4])||"",type:$(".thecontent").text().toLocaleLowerCase().includes("season")?"series":"movie"},links=[];return $("h3,h4").map((i,element)=>{var _a;const seriesTitle=$(element).text(),episodesLink=$(element).next("p").find(".maxbutton-episode-links,.maxbutton-g-drive,.maxbutton-af-download").attr("href"),movieLink=$(element).next("p").find(".maxbutton-download-links").attr("href");(movieLink||episodesLink&&"javascript:void(0);"!==episodesLink)&&links.push({title:seriesTitle.replace("Download ","").trim()||"Download",episodesLink:episodesLink||"",directLinks:movieLink?[{link:movieLink,title:"Movie",type:"movie"}]:[],quality:(null===(_a=null==seriesTitle?void 0:seriesTitle.match(/\d+p\b/))||void 0===_a?void 0:_a[0])||""})}),Object.assign(Object.assign({},meta),{linkList:links})}catch(err){return{title:"",synopsis:"",image:"",imdbId:"",type:"movie",linkList:[]}}})};exports.getMeta=getMeta;
|
||||
"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 getMeta=function(_a){return __awaiter(this,arguments,void 0,function*({link:link,providerContext:providerContext}){var _b;try{const{axios:axios,cheerio:cheerio}=providerContext,url=link,data=(yield axios.get(url)).data,$=cheerio.load(data),meta={title:$(".imdbwp__title").text()||$("strong:contains('Full Name:')").parent().clone().children().remove().end().text().trim(),synopsis:$(".imdbwp__teaser").text()||$(".liTOue").children("p").first().text(),image:$(".imdbwp__thumb").find("img").attr("src")||$("span:contains('ScreenShots:')").parent().next("p").children("img").first().attr("src")||"",imdbId:(null===(_b=$(".imdbwp__link").attr("href"))||void 0===_b?void 0:_b.split("/")[4])||"",type:$(".thecontent").text().toLocaleLowerCase().includes("season")?"series":"movie"},links=[];return $("h3,h4").map((i,element)=>{var _a;const seriesTitle=$(element).text(),episodesLink=$(element).next("p").find(".maxbutton-episode-links,.maxbutton-g-drive,.maxbutton-af-download").attr("href"),movieLink=$(element).next("p").find(".maxbutton-download-links").attr("href");(movieLink||episodesLink&&"javascript:void(0);"!==episodesLink)&&links.push({title:seriesTitle.replace("Download ","").trim()||"Download",episodesLink:episodesLink||"",directLinks:movieLink?[{link:movieLink,title:"Movie",type:"movie"}]:[],quality:(null===(_a=null==seriesTitle?void 0:seriesTitle.match(/\d+p\b/))||void 0===_a?void 0:_a[0])||""})}),Object.assign(Object.assign({},meta),{linkList:links})}catch(err){return{title:"",synopsis:"",image:"",imdbId:"",type:"movie",linkList:[]}}})};exports.getMeta=getMeta;
|
||||
@@ -14,9 +14,28 @@ export const getMeta = async function ({
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
const meta = {
|
||||
title: $(".imdbwp__title").text(),
|
||||
synopsis: $(".imdbwp__teaser").text(),
|
||||
image: $(".imdbwp__thumb").find("img").attr("src") || "",
|
||||
title:
|
||||
$(".imdbwp__title").text() ||
|
||||
$("strong:contains('Full Name:')")
|
||||
.parent()
|
||||
.clone()
|
||||
.children()
|
||||
.remove()
|
||||
.end()
|
||||
.text()
|
||||
.trim(),
|
||||
synopsis:
|
||||
$(".imdbwp__teaser").text() ||
|
||||
$(".liTOue").children("p").first().text(),
|
||||
image:
|
||||
$(".imdbwp__thumb").find("img").attr("src") ||
|
||||
$("span:contains('ScreenShots:')")
|
||||
.parent()
|
||||
.next("p")
|
||||
.children("img")
|
||||
.first()
|
||||
.attr("src") ||
|
||||
"",
|
||||
imdbId: $(".imdbwp__link").attr("href")?.split("/")[4] || "",
|
||||
type: $(".thecontent").text().toLocaleLowerCase().includes("season")
|
||||
? "series"
|
||||
|
||||
Reference in New Issue
Block a user