From 6cd672f9e636a907af637a4f0e14647ac11f6a24 Mon Sep 17 00:00:00 2001 From: Joe-Dowd Date: Fri, 24 Apr 2020 18:11:09 +0100 Subject: [PATCH] allow submissions when duration is parsed as 0 --- src/routes/postSkipSegments.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/routes/postSkipSegments.js b/src/routes/postSkipSegments.js index d8fe2a3..66cc4b0 100644 --- a/src/routes/postSkipSegments.js +++ b/src/routes/postSkipSegments.js @@ -105,9 +105,11 @@ async function autoModerateSubmission(submission, callback) { } 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 { return false;