Skip to content

Commit

Permalink
optimize: get biliDynamic data
Browse files Browse the repository at this point in the history
  • Loading branch information
snowtafir committed Oct 22, 2024
1 parent 7903ab7 commit feeac33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions models/bilibili/bilibili.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,21 @@ export class BiliTask {
}

async hendleEventDynamicData(uid: string | number, count: number = 0): Promise<any> {
let { cookie } = await readSyncCookie();
const resp = await new BiliGetWebData().getBiliDynamicListDataByUid(uid);
const resjson = await resp.data;
let { cookie } = await readSyncCookie();
if (resjson.code === 0) {
return resjson;
} else if (resjson.code === -352) {

if (!resjson || resjson.code !== 0 || resjson.code === -352) {
await postGateway(cookie);
if (count < 3) {
await this.randomDelay(2000, 8000); // 随机延时2-8秒
await this.hendleEventDynamicData(uid, count + 1);
logger.error(`获取 ${uid} 动态,Gateway count:${String(count)}`);
} else {
count = 0;
return resjson;
}
} else if (resjson.code !== 0) {
return resjson;
}
return resjson;
}

async runTask() {
Expand Down Expand Up @@ -118,11 +115,11 @@ export class BiliTask {
continue;
} else if (resp.code !== 0) {
logger.error(`获取 ${subInfoOfup.uid} 动态失败,resCode:${resp.code}`);
return;
continue;
}
} else {
logger.error(`获取 ${subInfoOfup.uid} 动态失败,无响应数据,本次任务终止,待下次任务自动重试`);
return;
logger.error(`获取 ${subInfoOfup.uid} 动态失败,无响应数据,请待下次任务自动重试`);
continue;
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yuki-plugin",
"version": "2.0.5-5",
"version": "2.0.5-6",
"author": "snowtafir",
"description": "优纪插件,yunzai-V4 关于 微博推送、B站推送 等功能的拓展插件",
"main": "./index",
Expand Down

0 comments on commit feeac33

Please sign in to comment.