mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getEpisodes = void 0;
|
|
const getEpisodes = async function ({ url, providerContext, }) {
|
|
const { axios, cheerio } = providerContext;
|
|
try {
|
|
const baseUrl = url?.split("/").slice(0, 3).join("/");
|
|
const res = await axios.get(url);
|
|
const html = res.data;
|
|
let $ = cheerio.load(html);
|
|
const episodeLinks = [];
|
|
$('.file-entry:not(:contains("Parent Directory"))').map((i, element) => {
|
|
const link = $(element).attr("href");
|
|
if (link &&
|
|
($(element).text()?.includes(".mp4") ||
|
|
$(element).text()?.includes(".mkv"))) {
|
|
episodeLinks.push({
|
|
title: $(element).text()?.match(/E\d+/)?.[0]?.replace("E", "Episode ") ||
|
|
i + 1 + ". " + $(element).text()?.replace(".mkv", ""),
|
|
link: baseUrl + link,
|
|
});
|
|
}
|
|
});
|
|
return episodeLinks;
|
|
}
|
|
catch (err) {
|
|
return [];
|
|
}
|
|
};
|
|
exports.getEpisodes = getEpisodes;
|