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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
bool paging = True
 
int results_per_page = 20
 
list categories = ["videos"]
 
str base_url = "https://api.bilibili.com/x/web-interface/search/type"
 
dict cookie
 

Detailed Description

Bilibili is a Chinese video sharing website.

.. _Bilibili: https://www.bilibili.com

Function Documentation

◆ request()

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

Definition at line 43 of file bilibili.py.

43def request(query, params):
44 query_params = {
45 "__refresh__": "true",
46 "page": params["pageno"],
47 "page_size": results_per_page,
48 "single_column": "0",
49 "keyword": query,
50 "search_type": "video",
51 }
52
53 params["url"] = f"{base_url}?{urlencode(query_params)}"
54 params["cookies"] = cookie
55
56 return params
57
58

◆ response()

searx.engines.bilibili.response ( resp)

Definition at line 59 of file bilibili.py.

59def response(resp):
60 search_res = resp.json()
61
62 results = []
63
64 for item in search_res.get("data", {}).get("result", []):
65 title = utils.html_to_text(item["title"])
66 url = item["arcurl"]
67 thumbnail = item["pic"]
68 description = item["description"]
69 author = item["author"]
70 video_id = item["aid"]
71 unix_date = item["pubdate"]
72
73 formatted_date = datetime.fromtimestamp(unix_date)
74
75 # the duration only seems to be valid if the video is less than 60 mins
76 duration = utils.parse_duration_string(item["duration"])
77 if duration and duration > timedelta(minutes=60):
78 duration = None
79
80 iframe_url = f"https://player.bilibili.com/player.html?aid={video_id}&high_quality=1&autoplay=false&danmaku=0"
81
82 results.append(
83 {
84 "title": title,
85 "url": url,
86 "content": description,
87 "author": author,
88 "publishedDate": formatted_date,
89 "length": duration,
90 "thumbnail": thumbnail,
91 "iframe_src": iframe_url,
92 "template": "videos.html",
93 }
94 )
95
96 return results

Variable Documentation

◆ about

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

Definition at line 15 of file bilibili.py.

◆ base_url

str searx.engines.bilibili.base_url = "https://api.bilibili.com/x/web-interface/search/type"

Definition at line 30 of file bilibili.py.

◆ categories

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

Definition at line 27 of file bilibili.py.

◆ cookie

dict searx.engines.bilibili.cookie
Initial value:
1= {
2 "innersign": "0",
3 "buvid3": "".join(random.choice(string.hexdigits) for _ in range(16)) + "infoc",
4 "i-wanna-go-back": "-1",
5 "b_ut": "7",
6 "FEED_LIVE_VERSION": "V8",
7 "header_theme_version": "undefined",
8 "home_feed_column": "4",
9}

Definition at line 32 of file bilibili.py.

◆ paging

bool searx.engines.bilibili.paging = True

Definition at line 25 of file bilibili.py.

◆ results_per_page

int searx.engines.bilibili.results_per_page = 20

Definition at line 26 of file bilibili.py.