mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-18 08:01:43 +00:00
Co-authored-by: shaker <your_github_username@users.noreply.github.com> Co-authored-by: himanshu8443 <sangwanhimanshu8443@gmail.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { EpisodeLink, ProviderContext } from "../types";
|
|
|
|
export const getEpisodes = async function ({
|
|
url,
|
|
providerContext,
|
|
}: {
|
|
url: string;
|
|
providerContext: ProviderContext;
|
|
}): Promise<EpisodeLink[]> {
|
|
const { axios, cheerio, getBaseUrl } = providerContext;
|
|
try {
|
|
const res = await axios.get(url);
|
|
const baseUrl = await getBaseUrl("moviezwap");
|
|
const html = res.data;
|
|
const $ = cheerio.load(html);
|
|
|
|
const episodeLinks: EpisodeLink[] = [];
|
|
|
|
$('a[href*="download.php?file="], a[href*="dwload.php?file="]').each(
|
|
(i, el) => {
|
|
const downloadPage =
|
|
$(el).attr("href")?.replace("dwload.php", "download.php") || "";
|
|
let text = $(el).text().trim();
|
|
if (text.includes("Download page")) {
|
|
// Remove "Download" from the text
|
|
text = "Play";
|
|
}
|
|
if (downloadPage && text) {
|
|
// Only add links with quality in text
|
|
episodeLinks.push({
|
|
title: text,
|
|
link: baseUrl + downloadPage,
|
|
});
|
|
}
|
|
}
|
|
);
|
|
|
|
return episodeLinks;
|
|
} catch (err) {
|
|
console.error(err);
|
|
return [];
|
|
}
|
|
};
|