mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 19:47:00 +03:00
allow submission if duration is 0
This commit is contained in:
@@ -101,11 +101,11 @@ async function autoModerateSubmission(submission, callback) {
|
|||||||
} else {
|
} else {
|
||||||
// Check to see if video exists
|
// Check to see if video exists
|
||||||
if (data.pageInfo.totalResults === 0) {
|
if (data.pageInfo.totalResults === 0) {
|
||||||
callback("No video exists with id " + submission.videoID);
|
return "No video exists with id " + submission.videoID;
|
||||||
} else {
|
} else {
|
||||||
let duration = data.items[0].contentDetails.duration;
|
let duration = data.items[0].contentDetails.duration;
|
||||||
duration = isoDurations.toSeconds(isoDurations.parse(duration));
|
duration = isoDurations.toSeconds(isoDurations.parse(duration));
|
||||||
if (duration === 0) {
|
if (duration == 0) {
|
||||||
// Allow submission if the duration is 0 (bug in youtube api)
|
// Allow submission if the duration is 0 (bug in youtube api)
|
||||||
return false;
|
return false;
|
||||||
} else if ((submission.endTime - submission.startTime) > (duration/100)*80) {
|
} else if ((submission.endTime - submission.startTime) > (duration/100)*80) {
|
||||||
|
|||||||
@@ -100,6 +100,16 @@ describe('postSkipSegments', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should be allowed if youtube thinks duration is 0', (done) => {
|
||||||
|
request.get(utils.getbaseURL()
|
||||||
|
+ "/api/postVideoSponsorTimes?videoID=noDuration&startTime=30&endTime=10000&userID=testing", null,
|
||||||
|
(err, res, body) => {
|
||||||
|
if (err) done("Couldn't call endpoint");
|
||||||
|
else if (res.statusCode === 200) done(); // pass
|
||||||
|
else done("non 200 status code: " + res.statusCode + " ("+body+")");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
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()
|
||||||
+ "/api/postVideoSponsorTimes?videoID=knownWrongID&startTime=30&endTime=1000000&userID=testing", null,
|
+ "/api/postVideoSponsorTimes?videoID=knownWrongID&startTime=30&endTime=1000000&userID=testing", null,
|
||||||
|
|||||||
@@ -10,13 +10,34 @@ YouTubeAPI.videos.list({
|
|||||||
const YouTubeAPI = {
|
const YouTubeAPI = {
|
||||||
videos: {
|
videos: {
|
||||||
list: (obj, callback) => {
|
list: (obj, callback) => {
|
||||||
if (obj.videoID === "knownWrongID") {
|
if (obj.id === "knownWrongID") {
|
||||||
callback(undefined, {
|
callback(undefined, {
|
||||||
pageInfo: {
|
pageInfo: {
|
||||||
totalResults: 0
|
totalResults: 0
|
||||||
},
|
},
|
||||||
items: []
|
items: []
|
||||||
});
|
});
|
||||||
|
} if (obj.id === "noDuration") {
|
||||||
|
callback(undefined, {
|
||||||
|
pageInfo: {
|
||||||
|
totalResults: 1
|
||||||
|
},
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
contentDetails: {
|
||||||
|
duration: "PT0S"
|
||||||
|
},
|
||||||
|
snippet: {
|
||||||
|
title: "Example Title",
|
||||||
|
thumbnails: {
|
||||||
|
maxres: {
|
||||||
|
url: "https://sponsor.ajay.app/LogoSponsorBlockSimple256px.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(undefined, {
|
callback(undefined, {
|
||||||
pageInfo: {
|
pageInfo: {
|
||||||
|
|||||||
Reference in New Issue
Block a user