Skip to content

Commit

Permalink
Merge pull request #37 from Kabuda-czh/fix-bilibili-undefined
Browse files Browse the repository at this point in the history
Fix bilibili undefined
  • Loading branch information
Kabuda-czh authored Jun 1, 2023
2 parents 271a86d + c49a162 commit 06b0b30
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion plugins/kbot/src/plugins/bilibili/dynamic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: Kabuda-czh
* @Date: 2023-01-29 14:43:47
* @LastEditors: Kabuda-czh
* @LastEditTime: 2023-04-25 11:18:00
* @LastEditTime: 2023-06-01 12:10:21
* @FilePath: \KBot-App\plugins\kbot\src\plugins\bilibili\dynamic\index.ts
* @Description:
*
Expand Down Expand Up @@ -135,6 +135,10 @@ async function request(
): Promise<BilibiliDynamicItem[]> {
try {
const res = await getDynamic(http, uid)

if (res.code !== 0)
throw new Error(res)

return (res.data.items as BilibiliDynamicItem[]).sort(
(a, b) => b.modules.module_author.pub_ts - a.modules.module_author.pub_ts,
)
Expand Down
6 changes: 3 additions & 3 deletions plugins/kbot/src/plugins/bilibili/dynamic/listen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: Kabuda-czh
* @Date: 2023-02-03 13:40:55
* @LastEditors: Kabuda-czh
* @LastEditTime: 2023-03-16 11:42:56
* @LastEditTime: 2023-06-01 09:46:22
* @FilePath: \KBot-App\plugins\kbot\src\plugins\bilibili\dynamic\listen.ts
* @Description:
*
Expand Down Expand Up @@ -42,12 +42,12 @@ export async function* listen(
notifications.forEach(
([, notification]) =>
(notification.lastUpdated
= items[0]?.modules.module_author.pub_ts
= items?.[0]?.modules?.module_author?.pub_ts
|| Math.ceil(+new Date() / 1000)),
)
continue
}
let neo = items.filter(
let neo = items?.filter(
item => item.modules.module_author.pub_ts > time,
)
if (!config.live)
Expand Down
4 changes: 2 additions & 2 deletions plugins/kbot/src/plugins/bilibili/dynamic/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: Kabuda-czh
* @Date: 2023-02-03 13:38:46
* @LastEditors: Kabuda-czh
* @LastEditTime: 2023-05-04 10:05:55
* @LastEditTime: 2023-06-01 12:09:06
* @FilePath: \KBot-App\plugins\kbot\src\plugins\bilibili\dynamic\render.ts
* @Description:
*
Expand Down Expand Up @@ -116,7 +116,7 @@ async function mobileRenderImage(

await page.goto(`https://m.bilibili.com/dynamic/${item.id_str}`, {
waitUntil: 'networkidle0',
timeout: 30000,
timeout: 120000,
})

if (page.url().includes('bilibili.com/404')) {
Expand Down

0 comments on commit 06b0b30

Please sign in to comment.