From 21bc14319013e4757ca24f56a685b7d75eaa259a Mon Sep 17 00:00:00 2001 From: Mohammad Amoush Date: Wed, 26 Jun 2019 19:15:50 -0400 Subject: Searching through document for a youtube video done --- src/server/youtubeApi/youtubeApiSample.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/server/youtubeApi') diff --git a/src/server/youtubeApi/youtubeApiSample.js b/src/server/youtubeApi/youtubeApiSample.js index 35d74c62f..cd2e89cae 100644 --- a/src/server/youtubeApi/youtubeApiSample.js +++ b/src/server/youtubeApi/youtubeApiSample.js @@ -29,8 +29,8 @@ module.exports.authorizedGetChannel = (apiKey) => { authorize(JSON.parse(apiKey), getChannel); } -module.exports.authorizedGetVideos = (apiKey) => { - authorize(JSON.parse(apiKey), getSampleVideos); +module.exports.authorizedGetVideos = (apiKey, userInput) => { + authorize(JSON.parse(apiKey), getSampleVideos, { userInput: userInput }); } @@ -41,7 +41,7 @@ module.exports.authorizedGetVideos = (apiKey) => { * @param {Object} credentials The authorization client credentials. * @param {function} callback The callback to call with the authorized client. */ -function authorize(credentials, callback) { +function authorize(credentials, callback, args = {}) { let clientSecret = credentials.installed.client_secret; let clientId = credentials.installed.client_id; let redirectUrl = credentials.installed.redirect_uris[0]; @@ -53,7 +53,7 @@ function authorize(credentials, callback) { getNewToken(oauth2Client, callback); } else { oauth2Client.credentials = JSON.parse(token); - callback(oauth2Client); + callback(oauth2Client, args); } }); } @@ -139,13 +139,13 @@ function getChannel(auth) { }); } -function getSampleVideos(auth) { +function getSampleVideos(auth, args) { let service = google.youtube('v3'); service.search.list({ auth: auth, part: 'id, snippet', type: 'video', - q: 'istanbul', + q: args.userInput, maxResults: 3 }, function (err, response) { if (err) { -- cgit v1.2.3-70-g09d2