|
@@ -452,6 +452,31 @@ export default {
|
|
|
});
|
|
|
}),
|
|
|
|
|
|
+ /**
|
|
|
+ * Get YouTube videos for channel ids
|
|
|
+ * @param {object} session - the session object automatically added by the websocket
|
|
|
+ * @param {string} channelIds - the channel ids
|
|
|
+ * @param {Function} cb - gets called with the result
|
|
|
+ * @returns {{status: string, data: object}}
|
|
|
+ */
|
|
|
+ getVideosForChannelIds: useHasPermission("youtube.getChannel", function getVideo(session, channelIds, cb) {
|
|
|
+ return YouTubeModule.runJob("GET_VIDEOS_FOR_CHANNEL_IDS", { channelIds }, this)
|
|
|
+ .then(res => {
|
|
|
+ this.log("SUCCESS", "YOUTUBE_GET_VIDEOS_FOR_CHANNEL_IDS", `Fetching videos was successful.`);
|
|
|
+
|
|
|
+ return cb({
|
|
|
+ status: "success",
|
|
|
+ message: "Successfully fetched YouTube videos",
|
|
|
+ data: res.videos
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(async err => {
|
|
|
+ err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
|
|
|
+ this.log("ERROR", "YOUTUBE_GET_VIDEOS_FOR_CHANNEL_IDS", `Fetching videos failed. "${err}"`);
|
|
|
+ return cb({ status: "error", message: err });
|
|
|
+ });
|
|
|
+ }),
|
|
|
+
|
|
|
/**
|
|
|
* Get a YouTube channel from ID
|
|
|
* @param {object} session - the session object automatically added by the websocket
|
|
@@ -481,6 +506,35 @@ export default {
|
|
|
});
|
|
|
}),
|
|
|
|
|
|
+ /**
|
|
|
+ * Get a YouTube channels from ID
|
|
|
+ * @param {object} session - the session object automatically added by the websocket
|
|
|
+ * @param {string} channelIds - the YouTube channel ids to get
|
|
|
+ * @param {Function} cb - gets called with the result
|
|
|
+ * @returns {{status: string, data: object}}
|
|
|
+ */
|
|
|
+ getChannelsById: useHasPermission("youtube.getChannel", function getChannel(session, channelIds, cb) {
|
|
|
+ return YouTubeModule.runJob("GET_CHANNELS_FROM_IDS", { channelIds }, this)
|
|
|
+ .then(res => {
|
|
|
+ if (res.channels.length === 0) {
|
|
|
+ this.log("ERROR", "YOUTUBE_GET_CHANNELS_FROM_IDS", `Fetching channel failed.`);
|
|
|
+ return cb({ status: "error", message: "Failed to get channel" });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.log("SUCCESS", "YOUTUBE_GET_CHANNELS_FROM_IDS", `Fetching channels was successful.`);
|
|
|
+ return cb({
|
|
|
+ status: "success",
|
|
|
+ message: "Successfully fetched YouTube channels",
|
|
|
+ data: res.channels
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(async err => {
|
|
|
+ err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
|
|
|
+ this.log("ERROR", "YOUTUBE_GET_CHANNELS_FROM_IDS", `Fetching channels failed. "${err}"`);
|
|
|
+ return cb({ status: "error", message: err });
|
|
|
+ });
|
|
|
+ }),
|
|
|
+
|
|
|
/**
|
|
|
* Remove YouTube videos
|
|
|
* @param {object} session - the session object automatically added by the websocket
|