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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
bool paging = True
 
bool time_range_support = True
 
list categories = ["videos"]
 
dict time_range_dict = {'day': '1', 'week': '2', 'month': '3'}
 
str base_url = "https://mesh.if.iqiyi.com"
 

Detailed Description

iQiyi: A search engine for retrieving videos from iQiyi.

Function Documentation

◆ request()

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

Definition at line 27 of file iqiyi.py.

27def request(query, params):
28 query_params = {"key": query, "pageNum": params["pageno"], "pageSize": 25}
29
30 if time_range_dict.get(params['time_range']):
31 query_params["sitePublishDate"] = time_range_dict[params['time_range']]
32
33 params["url"] = f"{base_url}/portal/lw/search/homePageV3?{urlencode(query_params)}"
34 return params
35
36

◆ response()

searx.engines.iqiyi.response ( resp)

Definition at line 37 of file iqiyi.py.

37def response(resp):
38 try:
39 data = resp.json()
40 except Exception as e:
41 raise SearxEngineAPIException(f"Invalid response: {e}") from e
42 results = []
43
44 if "data" not in data or "templates" not in data["data"]:
45 raise SearxEngineAPIException("Invalid response")
46
47 for entry in data["data"]["templates"]:
48 album_info = entry.get("albumInfo", {})
49
50 published_date = None
51 release_time = album_info.get("releaseTime", {}).get("value")
52 if release_time:
53 try:
54 published_date = datetime.strptime(release_time, "%Y-%m-%d")
55 except (ValueError, TypeError):
56 pass
57
58 length = None
59 subscript_content = album_info.get("subscriptContent")
60 if subscript_content:
61 try:
62 time_parts = subscript_content.split(":")
63 if len(time_parts) == 2:
64 minutes, seconds = map(int, time_parts)
65 length = timedelta(minutes=minutes, seconds=seconds)
66 elif len(time_parts) == 3:
67 hours, minutes, seconds = map(int, time_parts)
68 length = timedelta(hours=hours, minutes=minutes, seconds=seconds)
69 except (ValueError, TypeError):
70 pass
71
72 results.append(
73 {
74 'url': album_info.get("pageUrl", "").replace("http://", "https://"),
75 'title': album_info.get("title", ""),
76 'content': album_info.get("brief", {}).get("value", ""),
77 'template': 'videos.html',
78 'length': length,
79 'publishedDate': published_date,
80 'thumbnail': album_info.get("img", ""),
81 }
82 )
83
84 return results

Variable Documentation

◆ about

dict searx.engines.iqiyi.about
Initial value:
1= {
2 "website": "https://www.iqiyi.com/",
3 "wikidata_id": "Q15913890",
4 "use_official_api": False,
5 "require_api_key": False,
6 "results": "JSON",
7 "language": "zh",
8}

Definition at line 9 of file iqiyi.py.

◆ base_url

str searx.engines.iqiyi.base_url = "https://mesh.if.iqiyi.com"

Definition at line 24 of file iqiyi.py.

◆ categories

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

Definition at line 20 of file iqiyi.py.

◆ paging

bool searx.engines.iqiyi.paging = True

Definition at line 18 of file iqiyi.py.

◆ time_range_dict

dict searx.engines.iqiyi.time_range_dict = {'day': '1', 'week': '2', 'month': '3'}

Definition at line 22 of file iqiyi.py.

◆ time_range_support

bool searx.engines.iqiyi.time_range_support = True

Definition at line 19 of file iqiyi.py.