mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 08:26:59 +03:00
made youtube api cache have conatcnt part value
This commit is contained in:
@@ -50,7 +50,7 @@ function sendWebhooks(userID, videoID, UUID, segmentInfo) {
|
||||
if (config.youtubeAPIKey !== null) {
|
||||
let userSubmissionCountRow = db.prepare('get', "SELECT count(*) as submissionCount FROM sponsorTimes WHERE userID = ?", [userID]);
|
||||
|
||||
YouTubeAPI.listVideos(videoID, "snippet", (err, data) => {
|
||||
YouTubeAPI.listVideos(videoID, (err, data) => {
|
||||
if (err || data.items.length === 0) {
|
||||
err && logger.error(err);
|
||||
return;
|
||||
@@ -154,7 +154,7 @@ async function autoModerateSubmission(submission) {
|
||||
// Get the video information from the youtube API
|
||||
if (config.youtubeAPIKey !== null) {
|
||||
let {err, data} = await new Promise((resolve, reject) => {
|
||||
YouTubeAPI.listVideos(submission.videoID, "contentDetails,snippet", (err, data) => resolve({err, data}));
|
||||
YouTubeAPI.listVideos(submission.videoID, (err, data) => resolve({err, data}));
|
||||
});
|
||||
|
||||
if (err) {
|
||||
@@ -398,7 +398,7 @@ module.exports = async function postSkipSegments(req, res) {
|
||||
|
||||
if (config.youtubeAPIKey !== null) {
|
||||
let {err, data} = await new Promise((resolve, reject) => {
|
||||
YouTubeAPI.listVideos(videoID, "contentDetails,snippet", (err, data) => resolve({err, data}));
|
||||
YouTubeAPI.listVideos(videoID, (err, data) => resolve({err, data}));
|
||||
});
|
||||
|
||||
//get all segments for this video and user
|
||||
|
||||
@@ -49,7 +49,7 @@ function sendWebhooks(voteData) {
|
||||
}
|
||||
|
||||
if (config.youtubeAPIKey !== null) {
|
||||
YouTubeAPI.listVideos(submissionInfoRow.videoID, "snippet", (err, data) => {
|
||||
YouTubeAPI.listVideos(submissionInfoRow.videoID, (err, data) => {
|
||||
if (err || data.items.length === 0) {
|
||||
err && logger.error(err);
|
||||
return;
|
||||
|
||||
@@ -18,13 +18,14 @@ if (config.mode === "test") {
|
||||
exportObject = YouTubeAPI;
|
||||
|
||||
// YouTubeAPI.videos.list wrapper with cacheing
|
||||
exportObject.listVideos = (videoID, part, callback) => {
|
||||
exportObject.listVideos = (videoID, callback) => {
|
||||
let part = 'contentDetails,snippet';
|
||||
if (videoID.length !== 11 || videoID.includes(".")) {
|
||||
callback("Invalid video ID");
|
||||
return;
|
||||
}
|
||||
|
||||
let redisKey = "youtube.video." + videoID + "." + part;
|
||||
let redisKey = "youtube.video." + videoID;
|
||||
redis.get(redisKey, (getErr, result) => {
|
||||
if (getErr || !result) {
|
||||
logger.debug("redis: no cache for video information: " + videoID);
|
||||
|
||||
@@ -8,9 +8,8 @@ YouTubeAPI.videos.list({
|
||||
// https://developers.google.com/youtube/v3/docs/videos
|
||||
|
||||
const YouTubeAPI = {
|
||||
listVideos: (id, part, callback) => {
|
||||
listVideos: (id, callback) => {
|
||||
YouTubeAPI.videos.list({
|
||||
part: part,
|
||||
id: id
|
||||
}, callback);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user