mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
Added new NB overlapping code
This commit is contained in:
parent
abee010291
commit
8290c9e1f4
2 changed files with 19 additions and 9 deletions
|
@ -118,15 +118,15 @@ async function autoModerateSubmission(submission, callback) {
|
|||
|
||||
let nbPredictions = await response.json();
|
||||
for (const nbSegment of nbPredictions.sponsorSegments) {
|
||||
// The submission needs to be a subset of the widened NB prediction
|
||||
// and at least 65% of NB's prediction.
|
||||
if (nbSegment[0] - 2 <= submission.startTime && submission.endTime <= nbSegment[1] + 2){
|
||||
if ((submission.endTime - submission.startTime) / (nbSegment[1]-nbSegment[0]) >= 0.65){
|
||||
overlap = true;
|
||||
break;
|
||||
}
|
||||
// The submission needs to be similar to the NB prediction by 65% or off by less than 7 seconds
|
||||
// This calculated how off it is
|
||||
let offAmount = Math.abs(nbSegment[0] - submission.startTime) + Math.abs(nbSegment[1] - submission.endTime);
|
||||
if (offAmount / (nbSegment[1] - nbSegment[0]) <= 0.45 || offAmount <= 7) {
|
||||
overlap = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (overlap) {
|
||||
return false;
|
||||
} 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()
|
||||
+ "/api/postVideoSponsorTimes?videoID=LevkAjUE6d4&startTime=40&endTime=60&userID=testing", null,
|
||||
(err, res, body) => {
|
||||
|
@ -110,7 +110,17 @@ describe('postSkipSegments', () => {
|
|||
});
|
||||
}).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()
|
||||
+ "/api/postVideoSponsorTimes?videoID=LevkAjUE6d4&startTime=0&endTime=6&userID=testing", null,
|
||||
(err, res, body) => {
|
||||
|
|
Loading…
Reference in a new issue