update: interval between 2 getVideoInfo, rate limit for this task
This commit is contained in:
parent
1838219f04
commit
ecb44b9cba
@ -253,8 +253,8 @@ class NetScheduler {
|
|||||||
const netScheduler = new NetScheduler();
|
const netScheduler = new NetScheduler();
|
||||||
const videoInfoRateLimiterConfig: RateLimiterConfig[] = [
|
const videoInfoRateLimiterConfig: RateLimiterConfig[] = [
|
||||||
{
|
{
|
||||||
window: new SlidingWindow(redis, 1),
|
window: new SlidingWindow(redis, 3),
|
||||||
max: 3,
|
max: 5,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
window: new SlidingWindow(redis, 30),
|
window: new SlidingWindow(redis, 30),
|
||||||
|
@ -35,7 +35,7 @@ export async function queueLatestVideos(
|
|||||||
});
|
});
|
||||||
videosFound.add(aid);
|
videosFound.add(aid);
|
||||||
allExists = false;
|
allExists = false;
|
||||||
delay += Math.random() * SECOND * 0.5;
|
delay += Math.random() * SECOND * 1.5;
|
||||||
}
|
}
|
||||||
i += aids.length;
|
i += aids.length;
|
||||||
logger.log(
|
logger.log(
|
||||||
|
@ -6,7 +6,6 @@ export async function getVideoInfo(aid: number): Promise<VideoDetailsData | null
|
|||||||
const url = `https://api.bilibili.com/x/web-interface/view/detail?aid=${aid}`;
|
const url = `https://api.bilibili.com/x/web-interface/view/detail?aid=${aid}`;
|
||||||
const data = await netScheduler.request<VideoDetailsResponse>(url, "getVideoInfo");
|
const data = await netScheduler.request<VideoDetailsResponse>(url, "getVideoInfo");
|
||||||
const errMessage = `Error fetching metadata for ${aid}:`;
|
const errMessage = `Error fetching metadata for ${aid}:`;
|
||||||
logger.log("Fetching metadata for " + aid, "net", "fn:getVideoInfo");
|
|
||||||
if (data.code !== 0) {
|
if (data.code !== 0) {
|
||||||
logger.error(errMessage + data.message, "net", "fn:getVideoInfo");
|
logger.error(errMessage + data.message, "net", "fn:getVideoInfo");
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user