mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 21:17:15 +03:00
Prevent failing on api errors
This commit is contained in:
@@ -212,7 +212,7 @@ async function autoModerateSubmission(apiVideoInfo: APIVideoInfo,
|
|||||||
return a[0] - b[0] || a[1] - b[1];
|
return a[0] - b[0] || a[1] - b[1];
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const videoDuration = data.lengthSeconds;
|
const videoDuration = data?.lengthSeconds;
|
||||||
if (videoDuration != 0) {
|
if (videoDuration != 0) {
|
||||||
let allSegmentDuration = 0;
|
let allSegmentDuration = 0;
|
||||||
//sum all segment times together
|
//sum all segment times together
|
||||||
|
|||||||
@@ -59,11 +59,8 @@ async function sendWebhooks(voteData: VoteData) {
|
|||||||
|
|
||||||
if (config.newLeafURL !== null) {
|
if (config.newLeafURL !== null) {
|
||||||
const { err, data } = await YouTubeAPI.listVideos(submissionInfoRow.videoID);
|
const { err, data } = await YouTubeAPI.listVideos(submissionInfoRow.videoID);
|
||||||
|
if (err) return;
|
||||||
if (err) {
|
|
||||||
Logger.error(err.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const isUpvote = voteData.incrementAmount > 0;
|
const isUpvote = voteData.incrementAmount > 0;
|
||||||
// Send custom webhooks
|
// Send custom webhooks
|
||||||
dispatchEvent(isUpvote ? "vote.up" : "vote.down", {
|
dispatchEvent(isUpvote ? "vote.up" : "vote.down", {
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ export class YouTubeAPI {
|
|||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
const data = await result.json();
|
const data = await result.json();
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
return { err: data.err, data: null };
|
Logger.warn("CloudTube API Error: " + data.error)
|
||||||
|
return { err: data.error, data: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
redis.setAsync(redisKey, JSON.stringify(data)).then((result) => {
|
redis.setAsync(redisKey, JSON.stringify(data)).then((result) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user