mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-13 15:06:59 +03:00
Added new NB overlapping code
This commit is contained in:
@@ -118,15 +118,15 @@ async function autoModerateSubmission(submission, callback) {
|
|||||||
|
|
||||||
let nbPredictions = await response.json();
|
let nbPredictions = await response.json();
|
||||||
for (const nbSegment of nbPredictions.sponsorSegments) {
|
for (const nbSegment of nbPredictions.sponsorSegments) {
|
||||||
// The submission needs to be a subset of the widened NB prediction
|
// The submission needs to be similar to the NB prediction by 65% or off by less than 7 seconds
|
||||||
// and at least 65% of NB's prediction.
|
// This calculated how off it is
|
||||||
if (nbSegment[0] - 2 <= submission.startTime && submission.endTime <= nbSegment[1] + 2){
|
let offAmount = Math.abs(nbSegment[0] - submission.startTime) + Math.abs(nbSegment[1] - submission.endTime);
|
||||||
if ((submission.endTime - submission.startTime) / (nbSegment[1]-nbSegment[0]) >= 0.65){
|
if (offAmount / (nbSegment[1] - nbSegment[0]) <= 0.45 || offAmount <= 7) {
|
||||||
overlap = true;
|
overlap = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (overlap) {
|
if (overlap) {
|
||||||
return false;
|
return false;
|
||||||
} else{
|
} else{
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ describe('postSkipSegments', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should be *rejected* if there\'s not at least 65% overlap with NB' , (done) => {
|
it("Should be rejected if there's not at least 65% overlap with NB", (done) => {
|
||||||
request.get(utils.getbaseURL()
|
request.get(utils.getbaseURL()
|
||||||
+ "/api/postVideoSponsorTimes?videoID=LevkAjUE6d4&startTime=40&endTime=60&userID=testing", null,
|
+ "/api/postVideoSponsorTimes?videoID=LevkAjUE6d4&startTime=40&endTime=60&userID=testing", null,
|
||||||
(err, res, body) => {
|
(err, res, body) => {
|
||||||
@@ -110,7 +110,17 @@ describe('postSkipSegments', () => {
|
|||||||
});
|
});
|
||||||
}).timeout(5000);
|
}).timeout(5000);
|
||||||
|
|
||||||
it('Should be *accepted* if there\'s at least 65% overlap with NB' , (done) => {
|
it("Should be accepted if only off by 5s", (done) => {
|
||||||
|
request.get(utils.getbaseURL()
|
||||||
|
+ "/api/postVideoSponsorTimes?videoID=LevkAjUE6d4&startTime=0&endTime=12&userID=testing", null,
|
||||||
|
(err, res, body) => {
|
||||||
|
if (err) done("Couldn't call endpoint");
|
||||||
|
else if (res.statusCode === 200) done(); // pass
|
||||||
|
else done("non 403 status code: " + res.statusCode + " ("+body+")");
|
||||||
|
});
|
||||||
|
}).timeout(5000);
|
||||||
|
|
||||||
|
it("Should be accepted if there's at least 65% overlap with NB" , (done) => {
|
||||||
request.get(utils.getbaseURL()
|
request.get(utils.getbaseURL()
|
||||||
+ "/api/postVideoSponsorTimes?videoID=LevkAjUE6d4&startTime=0&endTime=6&userID=testing", null,
|
+ "/api/postVideoSponsorTimes?videoID=LevkAjUE6d4&startTime=0&endTime=6&userID=testing", null,
|
||||||
(err, res, body) => {
|
(err, res, body) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user