Skip to content

Commit ee9ed6a

Browse files
committed
Add server-side ads check for dearrow submissions
1 parent ec1e6d6 commit ee9ed6a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/routes/postBranding.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ interface ExistingVote {
3636
}
3737

3838
export async function postBranding(req: Request, res: Response) {
39-
const { videoID, userID, title, thumbnail, autoLock, downvote } = req.body as BrandingSubmission;
39+
const { videoID, userID, title, thumbnail, autoLock, downvote, videoDuration } = req.body as BrandingSubmission;
4040
const service = getService(req.body.service);
4141

4242
if (!videoID || !userID || userID.length < 30 || !service
@@ -55,6 +55,10 @@ export async function postBranding(req: Request, res: Response) {
5555
const hashedIP = await getHashCache(getIP(req) + config.globalSalt as IPAddress);
5656
const isBanned = await checkBanStatus(hashedUserID, hashedIP);
5757

58+
if (videoDuration && await checkForWrongVideoDuration(videoID, videoDuration)) {
59+
res.status(403).send("YouTube is currently testing a new anti-adblock technique called server-side ad-injection. This causes skips and submissions to be offset by the duration of the ad. It seems that you are affected by this A/B test, so until a fix is developed, we cannot accept submissions from your device due to them potentially being inaccurate.");
60+
}
61+
5862
const lock = await acquireLock(`postBranding:${videoID}.${hashedUserID}`);
5963
if (!lock.status) {
6064
res.status(429).send("Vote already in progress");
@@ -325,4 +329,11 @@ async function sendWebhooks(videoID: VideoID, UUID: BrandingUUID) {
325329
});
326330
}
327331
}
332+
}
333+
334+
async function checkForWrongVideoDuration(videoID: VideoID, duration: number): Promise<boolean> {
335+
const apiVideoDetails = await getVideoDetails(videoID, true);
336+
const apiDuration = apiVideoDetails?.duration;
337+
338+
return apiDuration && apiDuration > 2 && duration && duration > 2 && Math.abs(apiDuration - duration) > 3;
328339
}

0 commit comments

Comments
 (0)