Skip to content

Commit

Permalink
bilibili: adapt to new response format & support personalization
Browse files Browse the repository at this point in the history
fixes #39

Signed-off-by: Zach Zhu <[email protected]>
  • Loading branch information
zqzten committed Feb 13, 2024
1 parent 0ce9b28 commit 931cf78
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/bilibili.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

$wf = new Workflow;

$response = request('https://s.search.bilibili.com/main/suggest?term='.urlencode($query));
$json = json_decode($response, true);
$response = request('https://s.search.bilibili.com/main/suggest?term='.urlencode($query).'&userid='.getenv('bilibili_uid'));
$json = json_decode($response);
$results = $json->result->tag;

foreach ($json as $key => $value) {
$data = $value['value'];
foreach ($results as $sugg) {
$data = $sugg->value;
$wf->result()
->title($data)
->subtitle('Search 哔哩哔哩 for '.$data)
Expand Down
21 changes: 21 additions & 0 deletions src/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,27 @@ For detailed introductions and screenshots / reporting a bug / making contributi
<key>variable</key>
<string>proxy</string>
</dict>
<dict>
<key>config</key>
<dict>
<key>default</key>
<string></string>
<key>placeholder</key>
<string></string>
<key>required</key>
<false/>
<key>trim</key>
<true/>
</dict>
<key>description</key>
<string>Your bilibili UID for personalized search suggestions of bilibili. You can find your UID at the personal information section in your personal homepage of bilibili. Leave it blank to disable personalization.</string>
<key>label</key>
<string>bilibili UID</string>
<key>type</key>
<string>textfield</string>
<key>variable</key>
<string>bilibili_uid</string>
</dict>
</array>
<key>version</key>
<string>1.20</string>
Expand Down

0 comments on commit 931cf78

Please sign in to comment.