aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/utils
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-03-18 15:34:27 +0100
committersalmonik <raisersoft@proton.me>2026-03-18 15:34:27 +0100
commita242dff9bb86882538c4c5d6291a0e5267d54c27 (patch)
treeb9814b699172b15ea6e1584d2eb7c4e2c2491207 /cogs/utils
parentrequirements (diff)
downloadsenator-sperma-a242dff9bb86882538c4c5d6291a0e5267d54c27.tar.gz
senator-sperma-a242dff9bb86882538c4c5d6291a0e5267d54c27.zip
I am perhaps too fast to push
Diffstat (limited to '')
-rw-r--r--cogs/utils/file_search.py42
1 files changed, 1 insertions, 41 deletions
diff --git a/cogs/utils/file_search.py b/cogs/utils/file_search.py
index 4a2bdc4..2685e25 100644
--- a/cogs/utils/file_search.py
+++ b/cogs/utils/file_search.py
@@ -3,53 +3,13 @@
3# Copyright (C) 2026 Salmonik @ salmonik@tuta.io 3# Copyright (C) 2026 Salmonik @ salmonik@tuta.io
4# https://codeberg.org/salmonik/senator-sperma 4# https://codeberg.org/salmonik/senator-sperma
5 5
6"""
7Universal File Searcher
8
9This module provides a universal file searcher that can search for different file types:
10- Audio files (mp3, wav, mp4, opus, m4a, flac, aac, ogg)
11- Video files (mp4, avi, mkv, mov, wmv, flv, webm, m4v, 3gp)
12- Image files (jpg, jpeg, png, gif, bmp, tiff, webp, svg, ico)
13
14Usage Examples:
15 # Search all file types
16 results = await UniversalSearcher.search_local("query")
17
18 # Search only audio files
19 results = await UniversalSearcher.search_local("query", filetype="Audio")
20
21 # Search only video files
22 results = await UniversalSearcher.search_local("query", filetype="Video")
23
24 # Search only image files
25 results = await UniversalSearcher.search_local("query", filetype="Image")
26
27 # Autocomplete search
28 results = await UniversalSearcher.search_local_autocomplete("partial_query", filetype="Video")
29
30Settings.json structure:
31{
32 "file_paths": [
33 "/path/to/your/media/files",
34 "/another/path/with/mixed/content",
35 "relative/path/to/files"
36 ]
37}
38
39Note: file_paths should contain directories that may contain any mix of audio, video,
40and image files. The searcher will filter by file type automatically based on the
41filetype parameter.
42"""
43
44import json 6import json
45import logging 7import logging
46import re 8import re
47import urllib.parse
48from pathlib import Path 9from pathlib import Path
49import aiofiles 10import aiofiles
50from rapidfuzz import fuzz 11from rapidfuzz import fuzz
51import aiohttp 12import aiohttp
52import asyncio
53import os 13import os
54from dotenv import load_dotenv 14from dotenv import load_dotenv
55 15
@@ -405,7 +365,7 @@ class UniversalSearcher:
405 365
406 try: 366 try:
407 baseurl = await UniversalSearcher._load_baseurl() 367 baseurl = await UniversalSearcher._load_baseurl()
408 password = os.getenv("COPYPARTY_R_PASSWORD") 368 password = os.getenv("COPYPARTY_PASSWORD")
409 369
410 async with aiohttp.ClientSession() as session: 370 async with aiohttp.ClientSession() as session:
411 headers = {"Content-Type": "application/json"} 371 headers = {"Content-Type": "application/json"}