mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
95 lines
3.4 KiB
JavaScript
95 lines
3.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.nfGetPostsSearch = exports.nfGetPost = void 0;
|
|
const nfGetPost = async function ({ filter, page, providerValue, signal, providerContext, }) {
|
|
try {
|
|
const { getBaseUrl, cheerio } = providerContext;
|
|
const baseUrl = await getBaseUrl('nfMirror');
|
|
const catalog = [];
|
|
if (page > 1) {
|
|
return [];
|
|
}
|
|
// console.log(filter);
|
|
const isPrime = providerValue === 'primeMirror' ? 'isPrime=true' : 'isPrime=false';
|
|
const url = `https://netmirror.8man.me/api/net-proxy?${isPrime}&url=${baseUrl + filter}`;
|
|
const res = await fetch(url, {
|
|
signal: signal,
|
|
method: 'GET',
|
|
credentials: 'omit',
|
|
});
|
|
const data = await res.text();
|
|
// console.log('nfPost', data);
|
|
const $ = cheerio.load(data);
|
|
$('a.post-data').map((i, element) => {
|
|
const title = '';
|
|
const id = $(element).attr('data-post');
|
|
// console.log('id', id);
|
|
const image = $(element).find('img').attr('data-src') || '';
|
|
if (id) {
|
|
catalog.push({
|
|
title: title,
|
|
link: baseUrl +
|
|
`${providerValue === 'netflixMirror'
|
|
? '/post.php?id='
|
|
: '/pv/post.php?id='}` +
|
|
id +
|
|
'&t=' +
|
|
Math.round(new Date().getTime() / 1000),
|
|
image: image,
|
|
});
|
|
}
|
|
});
|
|
// console.log(catalog);
|
|
return catalog;
|
|
}
|
|
catch (err) {
|
|
console.error('nf error ', err);
|
|
return [];
|
|
}
|
|
};
|
|
exports.nfGetPost = nfGetPost;
|
|
const nfGetPostsSearch = async function ({ searchQuery, page, providerValue, signal, providerContext, }) {
|
|
const { getBaseUrl } = providerContext;
|
|
try {
|
|
if (page > 1) {
|
|
return [];
|
|
}
|
|
const catalog = [];
|
|
const baseUrl = await getBaseUrl('nfMirror');
|
|
const isPrime = providerValue === 'primeMirror' ? 'isPrime=true' : 'isPrime=false';
|
|
const url = `https://netmirror.8man.me/api/net-proxy?${isPrime}&url=${baseUrl}${providerValue === 'netflixMirror' ? '' : '/pv'}/search.php?s=${encodeURI(searchQuery)}`;
|
|
const res = await fetch(url, {
|
|
signal: signal,
|
|
method: 'GET',
|
|
credentials: 'omit',
|
|
});
|
|
const data = await res.json();
|
|
data?.searchResult?.forEach((result) => {
|
|
const title = result?.t || '';
|
|
const id = result?.id;
|
|
const image = providerValue === 'netflixMirror'
|
|
? `https://imgcdn.media/poster/v/${id}.jpg`
|
|
: '';
|
|
if (id) {
|
|
catalog.push({
|
|
title: title,
|
|
link: baseUrl +
|
|
`${providerValue === 'netflixMirror'
|
|
? '/mobile/post.php?id='
|
|
: '/mobile/pv/post.php?id='}` +
|
|
id +
|
|
'&t=' +
|
|
Math.round(new Date().getTime() / 1000),
|
|
image: image,
|
|
});
|
|
}
|
|
});
|
|
return catalog;
|
|
}
|
|
catch (err) {
|
|
console.error('Search error:', err);
|
|
return [];
|
|
}
|
|
};
|
|
exports.nfGetPostsSearch = nfGetPostsSearch;
|