update: interval between 2 getVideoInfo, rate limit for this task

This commit is contained in:
alikia2x (寒寒) 2025-03-02 02:45:48 +08:00
parent 1838219f04
commit ecb44b9cba
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6
3 changed files with 3 additions and 4 deletions

View File

@ -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),

View File

@ -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(

View File

@ -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;