fix: potential shifting for obtained window offset in last commit

This commit is contained in:
alikia2x (寒寒) 2025-03-27 02:09:48 +08:00
parent d5c278ae06
commit d6dd4d9334
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6
3 changed files with 20 additions and 1 deletions

View File

@ -207,7 +207,7 @@ export async function adjustSnapshotTime(
let initialOffset = 0; let initialOffset = 0;
if (lastAvailableWindow && lastAvailableWindow.count < allowedCounts) { if (lastAvailableWindow && lastAvailableWindow.count < allowedCounts) {
initialOffset = lastAvailableWindow.offset; initialOffset = Math.max(lastAvailableWindow.offset - 2, 0);
} }
let timePerIteration = 0; let timePerIteration = 0;

View File

@ -160,6 +160,7 @@ export const regularSnapshotsWorker = async (_job: Job) => {
const startedAt = Date.now(); const startedAt = Date.now();
if (await lockManager.isLocked("dispatchRegularSnapshots")) { if (await lockManager.isLocked("dispatchRegularSnapshots")) {
logger.log("dispatchRegularSnapshots is already running", "mq"); logger.log("dispatchRegularSnapshots is already running", "mq");
client.release();
return; return;
} }
await lockManager.acquireLock("dispatchRegularSnapshots", 30 * 60); await lockManager.acquireLock("dispatchRegularSnapshots", 30 * 60);

18
lib/net/bilibili.d.ts vendored
View File

@ -9,6 +9,24 @@ export type VideoListResponse = BaseResponse<VideoListData>;
export type VideoDetailsResponse = BaseResponse<VideoDetailsData>; export type VideoDetailsResponse = BaseResponse<VideoDetailsData>;
export type VideoTagsResponse = BaseResponse<VideoTagsData>; export type VideoTagsResponse = BaseResponse<VideoTagsData>;
export type VideoInfoResponse = BaseResponse<VideoInfoData>; export type VideoInfoResponse = BaseResponse<VideoInfoData>;
export type MediaListInfoResponse = BaseResponse<MediaListInfoData>;
type MediaListInfoData = MediaListInfoItem[];
interface MediaListInfoItem {
bvid: string;
id: number;
cnt_info: {
coin: number;
collect: number;
danmaku: number;
play: number;
reply: number;
share: number;
thumb_up: number;
}
}
interface VideoInfoData { interface VideoInfoData {
bvid: string; bvid: string;