init: media-center v2
Rewrite of ESH-Media v1 with separated main/renderer/shared architecture (vite-plugin-electron, React 18, react-router-dom). Includes NeDB storage, electron-store config, proxy manager with FoxyProxy/uBlock extensions, custom server-checked updater, NSIS installer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
87
search-scripts/hdrezka.js
Normal file
87
search-scripts/hdrezka.js
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* HDRezka.ag search script
|
||||
*
|
||||
* This script searches for movies/series on hdrezka.ag
|
||||
*
|
||||
* @param {string} query - Search query from user
|
||||
* @param {string} siteUrl - Base URL of the site
|
||||
* @param {boolean} useProxy - Whether to use proxy for requests
|
||||
* @param {object} axios - Axios instance for HTTP requests
|
||||
* @param {object} cheerio - Cheerio instance for HTML parsing
|
||||
* @param {object} proxyConfig - Proxy configuration {host, port}
|
||||
* @returns {Promise<Array>} Array of search results [{name, url, image?, year?, description?}]
|
||||
*/
|
||||
|
||||
async function search(query, siteUrl, useProxy, axios, cheerio, proxyConfig) {
|
||||
try {
|
||||
const searchUrl = `${siteUrl}/search/`;
|
||||
|
||||
// Prepare request config
|
||||
const config = {
|
||||
params: {
|
||||
do: 'search',
|
||||
subaction: 'search',
|
||||
q: query
|
||||
},
|
||||
timeout: 15000,
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'Accept-Language': 'ru-RU,ru;q=0.9,en;q=0.8'
|
||||
}
|
||||
};
|
||||
|
||||
// Add proxy if needed
|
||||
if (useProxy && proxyConfig) {
|
||||
config.proxy = {
|
||||
host: proxyConfig.host,
|
||||
port: proxyConfig.port
|
||||
};
|
||||
}
|
||||
|
||||
// Make request
|
||||
const response = await axios.get(searchUrl, config);
|
||||
const html = response.data;
|
||||
|
||||
// Parse HTML
|
||||
const $ = cheerio.load(html);
|
||||
const results = [];
|
||||
|
||||
// Find all movie/series cards
|
||||
$('.b-content__inline_item').each((index, element) => {
|
||||
const $item = $(element);
|
||||
|
||||
// Extract title and URL
|
||||
const linkEl = $item.find('.b-content__inline_item-link a').first();
|
||||
const name = linkEl.text().trim();
|
||||
const url = linkEl.attr('href');
|
||||
|
||||
if (!name || !url) return;
|
||||
|
||||
// Extract image
|
||||
const imageEl = $item.find('.b-content__inline_item-cover img').first();
|
||||
const image = imageEl.attr('src') || imageEl.attr('data-src');
|
||||
|
||||
// Extract year
|
||||
const infoText = $item.find('.info').text();
|
||||
const yearMatch = infoText.match(/(\d{4})/);
|
||||
const year = yearMatch ? yearMatch[1] : '';
|
||||
|
||||
// Extract rating if available
|
||||
const ratingText = $item.find('.imdb').text().trim();
|
||||
|
||||
results.push({
|
||||
name,
|
||||
url: url.startsWith('http') ? url : siteUrl + url,
|
||||
image: image ? (image.startsWith('http') ? image : siteUrl + image) : undefined,
|
||||
year,
|
||||
rating: ratingText || undefined
|
||||
});
|
||||
});
|
||||
|
||||
return results;
|
||||
} catch (error) {
|
||||
console.error('HDRezka search error:', error.message);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user