mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
more logs
This commit is contained in:
parent
35d3627760
commit
d038279d79
1 changed files with 22 additions and 2 deletions
|
@ -340,9 +340,14 @@ async function checkByAutoModerator(videoID: any, userID: any, segments: Array<a
|
|||
return CHECK_PASS;
|
||||
}
|
||||
|
||||
async function updateDataIfVideoDurationChange(videoID: VideoID, service: Service, videoDuration: VideoDuration, videoDurationParam: VideoDuration) {
|
||||
async function updateDataIfVideoDurationChange(videoID: VideoID, service: Service, videoDuration: VideoDuration, videoDurationParam: VideoDuration, logData: any) {
|
||||
let lockedCategoryList = await db.prepare("all", 'SELECT category, "actionType", reason from "lockCategories" where "videoID" = ? AND "service" = ?', [videoID, service]);
|
||||
|
||||
if (logData.extraLogging) {
|
||||
Logger.error(`got locked categories: ${Date.now() - logData.lastTime}, ${Date.now() - logData.startTime}`);
|
||||
logData.lastTime = Date.now();
|
||||
}
|
||||
|
||||
const previousSubmissions = await db.prepare("all",
|
||||
`SELECT "videoDuration", "UUID"
|
||||
FROM "sponsorTimes"
|
||||
|
@ -353,6 +358,11 @@ async function updateDataIfVideoDurationChange(videoID: VideoID, service: Servic
|
|||
[videoID, service]
|
||||
) as {videoDuration: VideoDuration, UUID: SegmentUUID}[];
|
||||
|
||||
if (logData.extraLogging) {
|
||||
Logger.error(`got previous submissions: ${Date.now() - logData.lastTime}, ${Date.now() - logData.startTime}`);
|
||||
logData.lastTime = Date.now();
|
||||
}
|
||||
|
||||
// If the video's duration is changed, then the video should be unlocked and old submissions should be hidden
|
||||
const videoDurationChanged = (videoDuration: number) => videoDuration != 0
|
||||
&& previousSubmissions.length > 0 && !previousSubmissions.some((e) => Math.abs(videoDuration - e.videoDuration) < 2);
|
||||
|
@ -368,6 +378,11 @@ async function updateDataIfVideoDurationChange(videoID: VideoID, service: Servic
|
|||
videoDuration = apiVideoDuration || 0 as VideoDuration;
|
||||
}
|
||||
|
||||
if (logData.extraLogging) {
|
||||
Logger.error(`got api response: ${Date.now() - logData.lastTime}, ${Date.now() - logData.startTime}`);
|
||||
logData.lastTime = Date.now();
|
||||
}
|
||||
|
||||
// Only treat as difference if both the api duration and submitted duration have changed
|
||||
if (videoDurationChanged(videoDuration) && (!videoDurationParam || videoDurationChanged(videoDurationParam))) {
|
||||
// Hide all previous submissions
|
||||
|
@ -378,6 +393,11 @@ async function updateDataIfVideoDurationChange(videoID: VideoID, service: Servic
|
|||
deleteLockCategories(videoID, null, null, service);
|
||||
}
|
||||
|
||||
if (logData.extraLogging) {
|
||||
Logger.error(`updated old submissions: ${Date.now() - logData.lastTime}, ${Date.now() - logData.startTime}`);
|
||||
logData.lastTime = Date.now();
|
||||
}
|
||||
|
||||
return {
|
||||
videoDuration,
|
||||
apiVideoInfo,
|
||||
|
@ -522,7 +542,7 @@ export async function postSkipSegments(req: Request, res: Response): Promise<Res
|
|||
const isTempVIP = await isUserTempVIP(userID, videoID);
|
||||
const rawIP = getIP(req);
|
||||
|
||||
const newData = await updateDataIfVideoDurationChange(videoID, service, videoDuration, videoDurationParam);
|
||||
const newData = await updateDataIfVideoDurationChange(videoID, service, videoDuration, videoDurationParam, logData);
|
||||
videoDuration = newData.videoDuration;
|
||||
const { lockedCategoryList, apiVideoInfo } = newData;
|
||||
|
||||
|
|
Loading…
Reference in a new issue