Files
vega-providers/dist/multi/multiGetInfo.js
himanshu8443 3f3e12f5df init
2025-06-15 21:29:40 +05:30

77 lines
2.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.multiGetInfo = void 0;
const multiGetInfo = async function ({ link, providerContext, }) {
try {
const { axios, cheerio } = providerContext;
const url = link;
const res = await axios.get(url);
const data = res.data;
const $ = cheerio.load(data);
const type = url.includes('tvshows') ? 'series' : 'movie';
const imdbId = '';
const title = url.split('/')[4].replace(/-/g, ' ');
const image = $('.g-item').find('a').attr('href') || '';
const synopsis = $('.wp-content').find('p').text() || '';
// Links
const links = [];
if (type === 'series') {
$('#seasons')
.children()
.map((i, element) => {
const title = $(element)
.find('.title')
.children()
.remove()
.end()
.text();
let episodesList = [];
$(element)
.find('.episodios')
.children()
.map((i, element) => {
const title = 'Episode' +
$(element).find('.numerando').text().trim().split('-')[1];
const link = $(element).find('a').attr('href');
if (title && link) {
episodesList.push({ title, link });
}
});
if (title && episodesList.length > 0) {
links.push({
title,
directLinks: episodesList,
});
}
});
}
else {
links.push({
title: title,
directLinks: [{ title: title, link: url.slice(0, -1), type: 'movie' }],
});
}
// console.log('multi meta', links);
return {
title,
synopsis,
image,
imdbId,
type,
linkList: links,
};
}
catch (err) {
console.error(err);
return {
title: '',
synopsis: '',
image: '',
imdbId: '',
type: 'movie',
linkList: [],
};
}
};
exports.multiGetInfo = multiGetInfo;