mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 11:36:58 +03:00
Added neural block mock
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
"discordReportChannelWebhookURL": null, //URL from discord if you would like notifications when someone makes a report [optional]
|
"discordReportChannelWebhookURL": null, //URL from discord if you would like notifications when someone makes a report [optional]
|
||||||
"discordFirstTimeSubmissionsWebhookURL": null, //URL from discord if you would like notifications when someone makes a first time submission [optional]
|
"discordFirstTimeSubmissionsWebhookURL": null, //URL from discord if you would like notifications when someone makes a first time submission [optional]
|
||||||
"discordCompletelyIncorrectReportWebhookURL": null, //URL from discord if you would like notifications when someone reports a submission as completely incorrect [optional]
|
"discordCompletelyIncorrectReportWebhookURL": null, //URL from discord if you would like notifications when someone reports a submission as completely incorrect [optional]
|
||||||
|
"neuralBlockURL": "https://ai.neuralblock.app",
|
||||||
"behindProxy": "X-Forwarded-For", //Options: "X-Forwarded-For", "Cloudflare", "X-Real-IP", anything else will mean it is not behind a proxy. True defaults to "X-Forwarded-For"
|
"behindProxy": "X-Forwarded-For", //Options: "X-Forwarded-For", "Cloudflare", "X-Real-IP", anything else will mean it is not behind a proxy. True defaults to "X-Forwarded-For"
|
||||||
"db": "./databases/sponsorTimes.db",
|
"db": "./databases/sponsorTimes.db",
|
||||||
"privateDB": "./databases/private.db",
|
"privateDB": "./databases/private.db",
|
||||||
|
|||||||
@@ -116,10 +116,12 @@ async function autoModerateSubmission(videoID, segments) {
|
|||||||
return "One of your submitted segments is over 80% of the video.";
|
return "One of your submitted segments is over 80% of the video.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let neuralBlockURL = config.neuralBlockURL || "https://ai.neuralblock.app";
|
||||||
|
|
||||||
let overlap = false;
|
let overlap = false;
|
||||||
|
|
||||||
let response = await fetch("https://ai.neuralblock.app/api/getSponsorSegments?vid=" + videoID);
|
let response = await fetch(neuralBlockURL + "/api/getSponsorSegments?vid=" + videoID);
|
||||||
if (!response.ok) return false;
|
if (!response.ok) return false;
|
||||||
|
|
||||||
let nbPredictions = await response.json();
|
let nbPredictions = await response.json();
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
"youtubeAPIKey": "",
|
"youtubeAPIKey": "",
|
||||||
"discordReportChannelWebhookURL": "http://127.0.0.1:8081/ReportChannelWebhook",
|
"discordReportChannelWebhookURL": "http://127.0.0.1:8081/ReportChannelWebhook",
|
||||||
"discordFirstTimeSubmissionsWebhookURL": "http://127.0.0.1:8081/FirstTimeSubmissionsWebhook",
|
"discordFirstTimeSubmissionsWebhookURL": "http://127.0.0.1:8081/FirstTimeSubmissionsWebhook",
|
||||||
"discordCompletelyIncorrectReportWebhookURL": "http://127.0.0.1:8081/CompletelyIncorrectReportWebhook",
|
"discordCompletelyIncorrectReportWebhookURL": "http://127.0.0.1:8081/CompletelyIncorrectReportWebhook",
|
||||||
|
"neuralBlockURL": "http://127.0.0.1:8081/NeuralBlock",
|
||||||
"behindProxy": true,
|
"behindProxy": true,
|
||||||
"db": "./test/databases/sponsorTimes.db",
|
"db": "./test/databases/sponsorTimes.db",
|
||||||
"privateDB": "./test/databases/private.db",
|
"privateDB": "./test/databases/private.db",
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ describe('postSkipSegments', () => {
|
|||||||
else if (res.statusCode === 403) done(); // pass
|
else if (res.statusCode === 403) done(); // pass
|
||||||
else done("non 403 status code: " + res.statusCode + " ("+body+")");
|
else done("non 403 status code: " + res.statusCode + " ("+body+")");
|
||||||
});
|
});
|
||||||
}).timeout(5000);
|
});
|
||||||
|
|
||||||
it("Should be accepted if only off by 5s", (done) => {
|
it("Should be accepted if only off by 5s", (done) => {
|
||||||
request.get(utils.getbaseURL()
|
request.get(utils.getbaseURL()
|
||||||
@@ -118,7 +118,7 @@ describe('postSkipSegments', () => {
|
|||||||
else if (res.statusCode === 200) done(); // pass
|
else if (res.statusCode === 200) done(); // pass
|
||||||
else done("non 403 status code: " + res.statusCode + " ("+body+")");
|
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) => {
|
it("Should be accepted if there's at least 65% overlap with NB" , (done) => {
|
||||||
request.get(utils.getbaseURL()
|
request.get(utils.getbaseURL()
|
||||||
@@ -128,7 +128,7 @@ describe('postSkipSegments', () => {
|
|||||||
else if (res.statusCode === 200) done(); // pass
|
else if (res.statusCode === 200) done(); // pass
|
||||||
else done("non 200 status code: " + res.statusCode + " ("+body+")");
|
else done("non 200 status code: " + res.statusCode + " ("+body+")");
|
||||||
});
|
});
|
||||||
}).timeout(5000);
|
});
|
||||||
|
|
||||||
it('Should be allowed if youtube thinks duration is 0', (done) => {
|
it('Should be allowed if youtube thinks duration is 0', (done) => {
|
||||||
request.get(utils.getbaseURL()
|
request.get(utils.getbaseURL()
|
||||||
@@ -138,7 +138,7 @@ describe('postSkipSegments', () => {
|
|||||||
else if (res.statusCode === 200) done(); // pass
|
else if (res.statusCode === 200) done(); // pass
|
||||||
else done("non 200 status code: " + res.statusCode + " ("+body+")");
|
else done("non 200 status code: " + res.statusCode + " ("+body+")");
|
||||||
});
|
});
|
||||||
}).timeout(5000);
|
});
|
||||||
|
|
||||||
it('Should be rejected if not a valid videoID', (done) => {
|
it('Should be rejected if not a valid videoID', (done) => {
|
||||||
request.get(utils.getbaseURL()
|
request.get(utils.getbaseURL()
|
||||||
|
|||||||
@@ -15,6 +15,17 @@ app.post('/CompletelyIncorrectReportWebhook', (req, res) => {
|
|||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/NeuralBlock/api/getSponsorSegments', (req, res) => {
|
||||||
|
if (req.query.vid === "LevkAjUE6d4") {
|
||||||
|
res.json({
|
||||||
|
sponsorSegments: [[0.47,7.549],[264.023,317.293]]
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.sendStatus(500);
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = function createMockServer(callback) {
|
module.exports = function createMockServer(callback) {
|
||||||
return app.listen(config.mockPort, callback);
|
return app.listen(config.mockPort, callback);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user