.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.sogou_videos Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ["videos"]
 
bool paging = True
 
int results_per_page = 10
 
str base_url = "https://v.sogou.com"
 

Detailed Description

Sogou-Videos: A search engine for retrieving videos from Sogou.

Function Documentation

◆ request()

searx.engines.sogou_videos.request ( query,
params )

Definition at line 25 of file sogou_videos.py.

25def request(query, params):
26 query_params = {
27 "page": params["pageno"],
28 "pagesize": 10,
29 "query": query,
30 }
31
32 params["url"] = f"{base_url}/api/video/shortVideoV2?{urlencode(query_params)}"
33 return params
34
35

◆ response()

searx.engines.sogou_videos.response ( resp)

Definition at line 36 of file sogou_videos.py.

36def response(resp):
37 try:
38 data = resp.json()
39 except Exception as e:
40 raise SearxEngineAPIException(f"Invalid response: {e}") from e
41 results = []
42
43 if not data.get("data", {}).get("list"):
44 raise SearxEngineAPIException("Invalid response")
45
46 for entry in data["data"]["list"]:
47 if not entry.get("titleEsc") or not entry.get("url"):
48 continue
49
50 video_url = entry.get("url")
51 if video_url.startswith("/vc/np"):
52 video_url = f"{base_url}{video_url}"
53
54 published_date = None
55 if entry.get("date") and entry.get("duration"):
56 try:
57 published_date = datetime.strptime(entry['date'], "%Y-%m-%d")
58 except (ValueError, TypeError):
59 published_date = None
60
61 length = None
62 if entry.get("date") and entry.get("duration"):
63 try:
64 timediff = datetime.strptime(entry['duration'], "%M:%S")
65 length = timedelta(minutes=timediff.minute, seconds=timediff.second)
66 except (ValueError, TypeError):
67 length = None
68
69 results.append(
70 {
71 'url': video_url,
72 'title': entry["titleEsc"],
73 'content': entry['site'],
74 'length': length,
75 'template': 'videos.html',
76 'publishedDate': published_date,
77 'thumbnail': entry["picurl"],
78 }
79 )
80
81 return results

Variable Documentation

◆ about

dict searx.engines.sogou_videos.about
Initial value:
1= {
2 "website": "https://v.sogou.com/",
3 "use_official_api": False,
4 "require_api_key": False,
5 "results": "JSON",
6 "language": "zh",
7}

Definition at line 9 of file sogou_videos.py.

◆ base_url

str searx.engines.sogou_videos.base_url = "https://v.sogou.com"

Definition at line 22 of file sogou_videos.py.

◆ categories

list searx.engines.sogou_videos.categories = ["videos"]

Definition at line 17 of file sogou_videos.py.

◆ paging

bool searx.engines.sogou_videos.paging = True

Definition at line 18 of file sogou_videos.py.

◆ results_per_page

int searx.engines.sogou_videos.results_per_page = 10

Definition at line 19 of file sogou_videos.py.