mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-18 08:01:43 +00:00
86 lines
2.6 KiB
JavaScript
86 lines
2.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.ridoGetInfo = void 0;
|
|
const ridoGetInfo = async function ({ link, providerContext, }) {
|
|
try {
|
|
const { getBaseUrl, axios } = providerContext;
|
|
const res = await axios.get(link);
|
|
const data = res.data;
|
|
const meta = {
|
|
title: '',
|
|
synopsis: '',
|
|
image: '',
|
|
imdbId: data?.meta?.imdb_id || '',
|
|
type: data?.meta?.type || 'movie',
|
|
};
|
|
const baseUrl = await getBaseUrl('ridomovies');
|
|
let slug = '';
|
|
try {
|
|
const res2 = await axios.get(baseUrl + '/core/api/search?q=' + meta.imdbId);
|
|
const data2 = res2.data;
|
|
slug = data2?.data?.items[0]?.fullSlug;
|
|
if (!slug || meta?.type === 'series') {
|
|
return {
|
|
title: '',
|
|
synopsis: '',
|
|
image: '',
|
|
imdbId: data?.meta?.imdb_id || '',
|
|
type: meta?.type || 'movie',
|
|
linkList: [],
|
|
};
|
|
}
|
|
}
|
|
catch (err) {
|
|
return {
|
|
title: '',
|
|
synopsis: '',
|
|
image: '',
|
|
imdbId: meta?.imdbId || '',
|
|
type: meta?.type || 'movie',
|
|
linkList: [],
|
|
};
|
|
}
|
|
const links = [];
|
|
let directLinks = [];
|
|
let season = new Map();
|
|
if (meta.type === 'series') {
|
|
data?.meta?.videos?.map((video) => {
|
|
if (video?.season <= 0)
|
|
return;
|
|
if (!season.has(video?.season)) {
|
|
season.set(video?.season, []);
|
|
}
|
|
season.get(video?.season).push({
|
|
title: 'Episode ' + video?.episode,
|
|
link: '',
|
|
});
|
|
});
|
|
for (const [seasonNum, episodes] of season.entries()) {
|
|
links.push({
|
|
title: 'Season ' + seasonNum,
|
|
directLinks: episodes,
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
directLinks.push({ title: 'Movie', link: link });
|
|
links.push({ title: 'Movie', directLinks: directLinks });
|
|
}
|
|
return {
|
|
...meta,
|
|
linkList: links,
|
|
};
|
|
}
|
|
catch (err) {
|
|
return {
|
|
title: '',
|
|
synopsis: '',
|
|
image: '',
|
|
imdbId: '',
|
|
type: 'movie',
|
|
linkList: [],
|
|
};
|
|
}
|
|
};
|
|
exports.ridoGetInfo = ridoGetInfo;
|