Merge branch 'testing' of https://github.com/ajayyy/SponsorBlockServer into nb-mod-fetch

# Conflicts:
#	src/routes/postSkipSegments.js
#	test/cases/postSkipSegments.js
This commit is contained in:
Ajay Ramachandran
2020-04-30 18:44:49 -04:00
9 changed files with 66 additions and 22 deletions

View File

@@ -102,13 +102,16 @@ async function autoModerateSubmission(submission, callback) {
} else {
// Check to see if video exists
if (data.pageInfo.totalResults === 0) {
callback("No video exists with id " + submission.videoID);
return "No video exists with id " + submission.videoID;
} else {
let duration = data.items[0].contentDetails.duration;
duration = isoDurations.toSeconds(isoDurations.parse(duration));
// Reject submission if over 80% of the video
if ((submission.endTime - submission.startTime) > (duration/100) * 80) {
if (duration == 0) {
// Allow submission if the duration is 0 (bug in youtube api)
return false;
} else if ((submission.endTime - submission.startTime) > (duration / 100) * 80) {
// Reject submission if over 80% of the video
return "Sponsor segment is over 80% of the video.";
} else {
let overlap = false;