mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
66 lines
2.5 KiB
JavaScript
66 lines
2.5 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.uhdGetPostsSearch = exports.uhdGetPosts = void 0;
|
|
const headers = {
|
|
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
|
'Cache-Control': 'no-store',
|
|
'Accept-Language': 'en-US,en;q=0.9',
|
|
DNT: '1',
|
|
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
|
|
'sec-ch-ua-mobile': '?0',
|
|
'sec-ch-ua-platform': '"Windows"',
|
|
'Sec-Fetch-Dest': 'document',
|
|
'Sec-Fetch-Mode': 'navigate',
|
|
'Sec-Fetch-Site': 'none',
|
|
'Sec-Fetch-User': '?1',
|
|
'Upgrade-Insecure-Requests': '1',
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0',
|
|
};
|
|
const uhdGetPosts = async ({ filter, page,
|
|
// providerValue,
|
|
signal, providerContext, }) => {
|
|
const { getBaseUrl } = providerContext;
|
|
const baseUrl = await getBaseUrl('UhdMovies');
|
|
const url = page === 1 ? `${baseUrl}/${filter}/` : `${baseUrl + filter}/page/${page}/`;
|
|
console.log('url', url);
|
|
return posts(baseUrl, url, signal, providerContext);
|
|
};
|
|
exports.uhdGetPosts = uhdGetPosts;
|
|
const uhdGetPostsSearch = async ({ searchQuery, page,
|
|
// providerValue,
|
|
signal, providerContext, }) => {
|
|
const { getBaseUrl } = providerContext;
|
|
const baseUrl = await getBaseUrl('UhdMovies');
|
|
const url = `${baseUrl}/search/${searchQuery}/page/${page}/`;
|
|
return posts(baseUrl, url, signal, providerContext);
|
|
};
|
|
exports.uhdGetPostsSearch = uhdGetPostsSearch;
|
|
async function posts(baseURL, url, signal, providerContext) {
|
|
try {
|
|
const { axios, cheerio } = providerContext;
|
|
const res = await axios.get(url, { headers, signal });
|
|
const html = res.data;
|
|
const $ = cheerio.load(html);
|
|
const uhdCatalog = [];
|
|
$('.gridlove-posts')
|
|
.find('.layout-masonry')
|
|
.each((index, element) => {
|
|
const title = $(element).find('a').attr('title');
|
|
const link = $(element).find('a').attr('href');
|
|
const image = $(element).find('a').find('img').attr('src');
|
|
if (title && link && image) {
|
|
uhdCatalog.push({
|
|
title: title.replace('Download', '').trim(),
|
|
link: link,
|
|
image: image,
|
|
});
|
|
}
|
|
});
|
|
return uhdCatalog;
|
|
}
|
|
catch (err) {
|
|
console.error('uhd error ', err);
|
|
return [];
|
|
}
|
|
}
|