mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
init
This commit is contained in:
44
providers/guardahd/guardahdGetPosts.ts
Normal file
44
providers/guardahd/guardahdGetPosts.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import {Post, ProviderContext} from '../types';
|
||||
|
||||
export const guardahdGetSearchPosts = async function ({
|
||||
searchQuery,
|
||||
page,
|
||||
signal,
|
||||
providerContext,
|
||||
}: {
|
||||
searchQuery: string;
|
||||
page: number;
|
||||
providerValue: string;
|
||||
providerContext: ProviderContext;
|
||||
signal: AbortSignal;
|
||||
}): Promise<Post[]> {
|
||||
try {
|
||||
const {axios, commonHeaders: headers} = providerContext;
|
||||
if (page > 1) {
|
||||
return [];
|
||||
}
|
||||
const catalog: Post[] = [];
|
||||
const url2 = `https://v3-cinemeta.strem.io/catalog/movie/top/search=${encodeURI(
|
||||
searchQuery,
|
||||
)}.json`;
|
||||
const res2 = await axios.get(url2, {headers, signal});
|
||||
const data2 = res2.data;
|
||||
data2?.metas.map((result: any) => {
|
||||
const title = result?.name || '';
|
||||
const id = result?.imdb_id || result?.id;
|
||||
const image = result?.poster;
|
||||
const type = result?.type;
|
||||
if (id) {
|
||||
catalog.push({
|
||||
title: title,
|
||||
link: `https://v3-cinemeta.strem.io/meta/${type}/${id}.json`,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
return catalog;
|
||||
} catch (err) {
|
||||
console.error('AutoEmbed error ', err);
|
||||
return [];
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user