diff options
author | Mohammad Amoush <mohammad_amoush@brown.edu> | 2019-06-26 19:15:50 -0400 |
---|---|---|
committer | Mohammad Amoush <mohammad_amoush@brown.edu> | 2019-06-26 19:15:50 -0400 |
commit | 21bc14319013e4757ca24f56a685b7d75eaa259a (patch) | |
tree | 9c21ee1dc68273a06386b1cde73d998195f03826 /src/server/youtubeApi/youtubeApiSample.js | |
parent | 530f38e60d6289a221a463ba36af2ed22c15d8d2 (diff) |
Searching through document for a youtube video done
Diffstat (limited to 'src/server/youtubeApi/youtubeApiSample.js')
-rw-r--r-- | src/server/youtubeApi/youtubeApiSample.js | 12 |
1 files changed, 6 insertions, 6 deletions
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) { |