mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
Add MoviezWap provider and update manifest (#1)
Co-authored-by: shaker <your_github_username@users.noreply.github.com> Co-authored-by: himanshu8443 <sangwanhimanshu8443@gmail.com>
This commit is contained in:
43
providers/moviezwap/episodes.ts
Normal file
43
providers/moviezwap/episodes.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
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 [];
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user