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:
Shaker
2025-06-30 12:04:26 +05:30
committed by GitHub
parent 6b0a4b7484
commit 305e3d2552
6 changed files with 281 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
import { Post, ProviderContext } from "../types";
export const getPosts = async function ({
filter,
page,
signal,
providerContext,
}: {
filter: string;
page: number;
providerValue: string;
signal: AbortSignal;
providerContext: ProviderContext;
}): Promise<Post[]> {
const { getBaseUrl, cheerio } = providerContext;
const baseUrl = await getBaseUrl("moviezwap");
const url = `${baseUrl}${filter}`;
return posts({ url, signal, cheerio });
};
export const getSearchPosts = async function ({
searchQuery,
page,
signal,
providerContext,
}: {
searchQuery: string;
page: number;
providerValue: string;
signal: AbortSignal;
providerContext: ProviderContext;
}): Promise<Post[]> {
const { getBaseUrl, cheerio } = providerContext;
const baseUrl = await getBaseUrl("moviezwap");
const url = `${baseUrl}/search.php?q=${encodeURIComponent(searchQuery)}`;
return posts({ url, signal, cheerio });
};
async function posts({
url,
signal,
cheerio,
}: {
url: string;
signal: AbortSignal;
cheerio: ProviderContext["cheerio"];
}): Promise<Post[]> {
try {
const res = await fetch(url, { signal });
const data = await res.text();
const $ = cheerio.load(data);
const catalog: Post[] = [];
$('a[href^="/movie/"]').each((i, el) => {
const title = $(el).text().trim();
const link = $(el).attr("href");
const image = "";
if (title && link) {
catalog.push({
title: title,
link: link,
image: image,
});
}
});
return catalog;
} catch (err) {
console.error("moviezwapGetPosts error ", err);
return [];
}
}