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:
63
search-scripts/rutube.js
Normal file
63
search-scripts/rutube.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Rutube.ru search script
|
||||
*
|
||||
* This script searches for videos on rutube.ru using their API
|
||||
*
|
||||
* @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 (not used)
|
||||
* @param {object} proxyConfig - Proxy configuration {host, port}
|
||||
* @returns {Promise<Array>} Array of search results [{name, url, image?, description?}]
|
||||
*/
|
||||
|
||||
async function search(query, siteUrl, useProxy, axios, cheerio, proxyConfig) {
|
||||
try {
|
||||
const searchUrl = `${siteUrl}/api/search/video/`;
|
||||
|
||||
// Prepare request config
|
||||
const config = {
|
||||
params: {
|
||||
query: query,
|
||||
limit: 20
|
||||
},
|
||||
timeout: 15000,
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
||||
}
|
||||
};
|
||||
|
||||
// Add proxy if needed (Rutube usually doesn't require proxy in Russia)
|
||||
if (useProxy && proxyConfig) {
|
||||
config.proxy = {
|
||||
host: proxyConfig.host,
|
||||
port: proxyConfig.port
|
||||
};
|
||||
}
|
||||
|
||||
// Make request
|
||||
const response = await axios.get(searchUrl, config);
|
||||
const data = response.data;
|
||||
|
||||
// Check if results exist
|
||||
if (!data.results || !Array.isArray(data.results)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Map results to our format
|
||||
const results = data.results.map(item => {
|
||||
return {
|
||||
name: item.title || '',
|
||||
url: item.video_url || (siteUrl + '/video/' + item.id),
|
||||
image: item.thumbnail_url || undefined,
|
||||
description: item.description || undefined
|
||||
};
|
||||
});
|
||||
|
||||
return results.filter(r => r.name && r.url);
|
||||
} catch (error) {
|
||||
console.error('Rutube search error:', error.message);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user