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

Functions

 request (query, params)
 
 format_duration (duration)
 
 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

◆ format_duration()

searx.engines.bilibili.format_duration ( duration)

Definition at line 60 of file bilibili.py.

60def format_duration(duration):
61 if not ":" in duration:
62 return None
63 minutes, seconds = map(int, duration.split(":"))
64 total_seconds = minutes * 60 + seconds
65
66 formatted_duration = str(timedelta(seconds=total_seconds))[2:] if 0 <= total_seconds < 3600 else ""
67
68 return formatted_duration
69
70

Referenced by searx.engines.bilibili.response().

+ Here is the caller graph for this function:

◆ 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
59# Format the video duration

◆ response()

searx.engines.bilibili.response ( resp)

Definition at line 71 of file bilibili.py.

71def response(resp):
72 search_res = resp.json()
73
74 results = []
75
76 for item in search_res.get("data", {}).get("result", []):
77 title = utils.html_to_text(item["title"])
78 url = item["arcurl"]
79 thumbnail = item["pic"]
80 description = item["description"]
81 author = item["author"]
82 video_id = item["aid"]
83 unix_date = item["pubdate"]
84
85 formatted_date = datetime.utcfromtimestamp(unix_date)
86 formatted_duration = format_duration(item["duration"])
87 iframe_url = f"https://player.bilibili.com/player.html?aid={video_id}&high_quality=1&autoplay=false&danmaku=0"
88
89 results.append(
90 {
91 "title": title,
92 "url": url,
93 "content": description,
94 "author": author,
95 "publishedDate": formatted_date,
96 "length": formatted_duration,
97 "thumbnail": thumbnail,
98 "iframe_src": iframe_url,
99 "template": "videos.html",
100 }
101 )
102
103 return results

References searx.engines.bilibili.format_duration().

+ Here is the call graph for this function:

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.