mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 08:26:59 +03:00
Removed unnecessary YT API call from NB Discord webhook
This commit is contained in:
@@ -98,8 +98,7 @@ function sendWebhooks(userID, videoID, UUID, segmentInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendWebhooksNB(userID, videoID, UUID, startTime, endTime, category, probability) {
|
function sendWebhooksNB(userID, videoID, UUID, startTime, endTime, category, probability, ytData) {
|
||||||
if (config.youtubeAPIKey !== null) {
|
|
||||||
//let submissionInfoRow = db.prepare('get', "SELECT s.videoID, s.userID, s.startTime, s.endTime, s.category, u.userName, " +
|
//let submissionInfoRow = db.prepare('get', "SELECT s.videoID, s.userID, s.startTime, s.endTime, s.category, u.userName, " +
|
||||||
// "(select count(1) from sponsorTimes where userID = s.userID) count, " +
|
// "(select count(1) from sponsorTimes where userID = s.userID) count, " +
|
||||||
// "(select count(1) from sponsorTimes where userID = s.userID and votes <= -2) disregarded " +
|
// "(select count(1) from sponsorTimes where userID = s.userID and votes <= -2) disregarded " +
|
||||||
@@ -108,15 +107,6 @@ function sendWebhooksNB(userID, videoID, UUID, startTime, endTime, category, pro
|
|||||||
let submissionCount = db.prepare('get', "SELECT COUNT(*) count FROM sponsorTimes WHERE userID=?", [userID]);
|
let submissionCount = db.prepare('get', "SELECT COUNT(*) count FROM sponsorTimes WHERE userID=?", [userID]);
|
||||||
let disregardedCount = db.prepare('get', "SELECT COUNT(*) disregarded FROM sponsorTimes WHERE userID=? and votes <= -2", [userID]);
|
let disregardedCount = db.prepare('get', "SELECT COUNT(*) disregarded FROM sponsorTimes WHERE userID=? and votes <= -2", [userID]);
|
||||||
//let uName = db.prepare('get', "SELECT userName FROM userNames WHERE userID=?", [userID]);
|
//let uName = db.prepare('get', "SELECT userName FROM userNames WHERE userID=?", [userID]);
|
||||||
YouTubeAPI.videos.list({
|
|
||||||
part: "snippet",
|
|
||||||
id: videoID
|
|
||||||
}, function (err, data) {
|
|
||||||
if (err || data.items.length === 0) {
|
|
||||||
err && logger.error(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//sendWebhookNotification(userID, videoID, UUID, submissionInfoRow.submissionCount, data, {submissionStart: startTime, submissionEnd: endTime}, segmentInfo);
|
|
||||||
let submittedBy = userID;//"";
|
let submittedBy = userID;//"";
|
||||||
// If there's no userName then just show the userID
|
// If there's no userName then just show the userID
|
||||||
// if (uName.userName == userID){
|
// if (uName.userName == userID){
|
||||||
@@ -130,7 +120,7 @@ function sendWebhooksNB(userID, videoID, UUID, startTime, endTime, category, pro
|
|||||||
request.post(config.discordNeuralBlockRejectWebhookURL, {
|
request.post(config.discordNeuralBlockRejectWebhookURL, {
|
||||||
json: {
|
json: {
|
||||||
"embeds": [{
|
"embeds": [{
|
||||||
"title": data.items[0].snippet.title,
|
"title": ytData.items[0].snippet.title,
|
||||||
"url": "https://www.youtube.com/watch?v=" + videoID + "&t=" + (startTime.toFixed(0) - 2),
|
"url": "https://www.youtube.com/watch?v=" + videoID + "&t=" + (startTime.toFixed(0) - 2),
|
||||||
"description": "**Submission ID:** " + UUID +
|
"description": "**Submission ID:** " + UUID +
|
||||||
"\n**Timestamp:** " + getFormattedTime(startTime) + " to " + getFormattedTime(endTime) +
|
"\n**Timestamp:** " + getFormattedTime(startTime) + " to " + getFormattedTime(endTime) +
|
||||||
@@ -140,11 +130,8 @@ function sendWebhooksNB(userID, videoID, UUID, startTime, endTime, category, pro
|
|||||||
"\n**Total User Submissions:** "+submissionCount.count +
|
"\n**Total User Submissions:** "+submissionCount.count +
|
||||||
"\n**Ignored User Submissions:** "+disregardedCount.disregarded,
|
"\n**Ignored User Submissions:** "+disregardedCount.disregarded,
|
||||||
"color": 10813440,
|
"color": 10813440,
|
||||||
"author": {
|
|
||||||
"name": userID
|
|
||||||
},
|
|
||||||
"thumbnail": {
|
"thumbnail": {
|
||||||
"url": data.items[0].snippet.thumbnails.maxres ? data.items[0].snippet.thumbnails.maxres.url : "",
|
"url": ytData.items[0].snippet.thumbnails.maxres ? ytData.items[0].snippet.thumbnails.maxres.url : "",
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
@@ -159,8 +146,6 @@ function sendWebhooksNB(userID, videoID, UUID, startTime, endTime, category, pro
|
|||||||
logger.error("\n");
|
logger.error("\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// callback: function(reject: "String containing reason the submission was rejected")
|
// callback: function(reject: "String containing reason the submission was rejected")
|
||||||
@@ -174,7 +159,7 @@ async function autoModerateSubmission(submission) {
|
|||||||
if (config.youtubeAPIKey !== null) {
|
if (config.youtubeAPIKey !== null) {
|
||||||
let {err, data} = await new Promise((resolve, reject) => {
|
let {err, data} = await new Promise((resolve, reject) => {
|
||||||
YouTubeAPI.videos.list({
|
YouTubeAPI.videos.list({
|
||||||
part: "contentDetails",
|
part: "contentDetails,snippet",
|
||||||
id: submission.videoID
|
id: submission.videoID
|
||||||
}, (err, data) => resolve({err, data}));
|
}, (err, data) => resolve({err, data}));
|
||||||
});
|
});
|
||||||
@@ -210,7 +195,7 @@ async function autoModerateSubmission(submission) {
|
|||||||
let UUID = getHash("v2-categories" + submission.videoID + submission.startTime +
|
let UUID = getHash("v2-categories" + submission.videoID + submission.startTime +
|
||||||
submission.endTime + submission.category + submission.userID, 1);
|
submission.endTime + submission.category + submission.userID, 1);
|
||||||
// Send to Discord
|
// Send to Discord
|
||||||
sendWebhooksNB(submission.userID, submission.videoID, UUID, submission.startTime, submission.endTime, submission.category, nbPredictions.probabilities[0]);
|
sendWebhooksNB(submission.userID, submission.videoID, UUID, submission.startTime, submission.endTime, submission.category, nbPredictions.probabilities[0], data);
|
||||||
return "NB disagreement.";
|
return "NB disagreement.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user