Don't fail when the YouTube API errors

This commit is contained in:
Ajay Ramachandran
2020-10-18 01:08:52 -04:00
parent 809b09a1c2
commit 4f6ff4d177

View File

@@ -411,6 +411,9 @@ module.exports = async function postSkipSegments(req, res) {
YouTubeAPI.listVideos(videoID, (err, data) => resolve({err, data})); YouTubeAPI.listVideos(videoID, (err, data) => resolve({err, data}));
}); });
if (err) {
logger.error("Error while submitting when connecting to YouTube API: " + err);
} else {
//get all segments for this video and user //get all segments for this video and user
let allSubmittedByUser = db.prepare('all', "SELECT startTime, endTime FROM sponsorTimes WHERE userID = ? and videoID = ? and votes > -1", [userID, videoID]); let allSubmittedByUser = db.prepare('all', "SELECT startTime, endTime FROM sponsorTimes WHERE userID = ? and videoID = ? and votes > -1", [userID, videoID]);
let allSegmentTimes = []; let allSegmentTimes = [];
@@ -444,6 +447,7 @@ module.exports = async function postSkipSegments(req, res) {
} }
} }
} }
}
for (const segmentInfo of segments) { for (const segmentInfo of segments) {
//this can just be a hash of the data //this can just be a hash of the data