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>
86 lines
2.5 KiB
JavaScript
86 lines
2.5 KiB
JavaScript
/**
|
|
* Kinogo.biz search script
|
|
*
|
|
* This script searches for movies/series on kinogo.biz
|
|
*
|
|
* @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}/index.php`;
|
|
|
|
// Prepare request config
|
|
const config = {
|
|
params: {
|
|
do: 'search',
|
|
subaction: 'search',
|
|
story: query
|
|
},
|
|
timeout: 15000,
|
|
headers: {
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
|
}
|
|
};
|
|
|
|
// 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 cards
|
|
$('.shortstory').each((index, element) => {
|
|
const $item = $(element);
|
|
|
|
// Extract title
|
|
const titleEl = $item.find('.shortstory-title a, .title a, h2 a').first();
|
|
const name = titleEl.text().trim();
|
|
const url = titleEl.attr('href');
|
|
|
|
if (!name || !url) return;
|
|
|
|
// Extract image
|
|
const imageEl = $item.find('.shortstory-img img, .poster img, img').first();
|
|
const image = imageEl.attr('src') || imageEl.attr('data-src');
|
|
|
|
// Extract year
|
|
const yearText = $item.find('.year, .shortstory-year').text().trim();
|
|
const yearMatch = yearText.match(/(\d{4})/);
|
|
const year = yearMatch ? yearMatch[1] : '';
|
|
|
|
// Extract description
|
|
const description = $item.find('.shortstory-desc, .description').text().trim();
|
|
|
|
results.push({
|
|
name,
|
|
url: url.startsWith('http') ? url : siteUrl + url,
|
|
image: image ? (image.startsWith('http') ? image : siteUrl + image) : undefined,
|
|
year,
|
|
description: description || undefined
|
|
});
|
|
});
|
|
|
|
return results;
|
|
} catch (error) {
|
|
console.error('Kinogo search error:', error.message);
|
|
return [];
|
|
}
|
|
}
|