From d8bf7fa398d6d928325be9b5c64ca24875bfeef8 Mon Sep 17 00:00:00 2001 From: Agando Date: Sat, 30 May 2026 18:01:51 +0200 Subject: auto: 2026-05-30_18:00 changes --- modules/core/module-searxng.js | 65 +++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 16 deletions(-) (limited to 'modules/core/module-searxng.js') diff --git a/modules/core/module-searxng.js b/modules/core/module-searxng.js index f2c2e72..24db0f5 100644 --- a/modules/core/module-searxng.js +++ b/modules/core/module-searxng.js @@ -5,29 +5,41 @@ class SearXNGModule { } getHelpInfo() { return { - 'search': 'search [--summarize] [--fetch] — Search using SearXNG; --summarize/-s adds AI overview, --fetch/-f fetches page content', - 's': 's [--summarize] [--fetch] — Alias for search', + 'search': 'search [--summarize/-s] [--fetch/-f] [--images/-i] [--videos/-v] — Search using SearXNG; --summarize/-s adds AI overview, --fetch/-f fetches page content, --images/-i searches for images, --videos/-v searches for videos', + 's': 's [--summarize] [--fetch] [--images] [--videos] — Alias for search', + 'images': 'images — Search for images', + 'videos': 'videos — Search for videos', }; } registerCommands() { this.commands['search'] = (args) => this.search(args); this.commands['s'] = (args) => this.search(args); + this.commands['images'] = (args) => this.search(args, 'images'); + this.commands['videos'] = (args) => this.search(args, 'videos'); } - async search(args) { - if (!args[0]) { - this.terminal.print("Usage: search [--summarize] [--fetch]", "warning"); + async search(args, forceCategory) { + if (!args[0] && !forceCategory) { + this.terminal.print("Usage: search [--summarize] [--fetch] [--images] [--videos]", "warning"); this.terminal.print("Example: search quantum computing --summarize", "info"); + this.terminal.print("Example: search cats --images", "info"); + this.terminal.print("Example: search cats --videos", "info"); + this.terminal.print("Shortcuts: images or videos ", "info"); return; } const argsList = args.slice(); const summarize = argsList.includes('--summarize') || argsList.includes('-s'); const fetchContent = argsList.includes('--fetch') || argsList.includes('-f'); + const wantImages = forceCategory === 'images' || argsList.includes('--images') || argsList.includes('-i'); + const wantVideos = forceCategory === 'videos' || argsList.includes('--videos') || argsList.includes('-v'); const query = argsList.filter(a => !a.startsWith('-')).join(' '); if (!query) { this.terminal.print('Search query is required', 'warning'); return; } - this.terminal.print(`🔍 Searching: ${query}`, 'info'); + const category = wantImages ? 'images' : (wantVideos ? 'videos' : 'general'); + const categoryLabel = category === 'images' ? '🖼️' : (category === 'videos' ? '🎬' : '🔍'); - let params = 'q=' + encodeURIComponent(query); + this.terminal.print(`${categoryLabel} Searching ${category}: ${query}`, 'info'); + + let params = 'q=' + encodeURIComponent(query) + '&categories=' + category; if (summarize) params += '&summarize=true'; if (fetchContent) params += '&fetch_content=true'; @@ -46,7 +58,7 @@ class SearXNGModule { return; } - this.terminal.print(`\n=== ${results.length} results (via ${data.source || 'unknown'}) ===\n`, 'success'); + this.terminal.print(`\n=== ${results.length} results (${category}, via ${data.source || 'unknown'}) ===\n`, 'success'); if (data.ai_overview) { this.terminal.print('🤖 AI Overview:', 'info'); @@ -57,14 +69,35 @@ class SearXNGModule { results.forEach((r, i) => { const snippet = r.content || ''; const contentSnippet = r.content_snippet || ''; - this.terminal.printHTML(` -
- ${i + 1}. ${r.title || 'No Title'}
- ${r.url || 'No URL'}
- ${(snippet || '').substring(0, 200)}... - ${contentSnippet ? `
📄 ${contentSnippet.substring(0, 150)}...` : ''} -
- `); + const imgSrc = r.img_src || r.thumbnail_src || ''; + const videoThumb = r.thumbnail || ''; + + if (category === 'images' && imgSrc) { + this.terminal.printHTML(` +
+ ${r.title || ''} +
${i + 1}. ${r.title || 'No Title'} +
+ `); + } else if (category === 'videos' && videoThumb) { + this.terminal.printHTML(` +
+ ${r.title || ''} +
${i + 1}. ${r.title || 'No Title'}
+ ${r.url || ''} +
+ `); + } else { + this.terminal.printHTML(` +
+ ${i + 1}. ${r.title || 'No Title'}
+ ${r.url || 'No URL'}
+ ${(snippet || '').substring(0, 200)}... + ${contentSnippet ? `
📄 ${contentSnippet.substring(0, 150)}...` : ''} + ${imgSrc && category === 'general' ? `
🖼️ View image` : ''} +
+ `); + } }); } catch (e) { this.terminal.print('Search failed: ' + e.message, 'error'); -- cgit v1.2.3