added checks using the youtube api on segment submission

This commit is contained in:
Joe-Dowd
2020-04-04 21:37:17 +01:00
parent 98d754f605
commit e5cd72657e
7 changed files with 161 additions and 48 deletions

View File

@@ -2,8 +2,18 @@ var config = require('../config.js');
// YouTube API
const YouTubeAPI = require("youtube-api");
YouTubeAPI.authenticate({
type: "key",
key: config.youtubeAPIKey
});
module.exports = YouTubeAPI;
var exportObject;
// If in test mode, return a mocked youtube object
// otherwise return an authenticated youtube api
if (config.mode === "test") {
exportObject = require("../../test/youtubeMock.js");
} else {
YouTubeAPI.authenticate({
type: "key",
key: config.youtubeAPIKey
});
exportObject = YouTubeAPI;
}
module.exports = exportObject;