diff options
| author | Mohammad Amoush <mohammad_amoush@brown.edu> | 2019-07-22 18:47:14 -0400 |
|---|---|---|
| committer | Mohammad Amoush <mohammad_amoush@brown.edu> | 2019-07-22 18:47:14 -0400 |
| commit | 4446a3a52c4cf4b03c201ab2d6a9179647686e40 (patch) | |
| tree | 960914ad762daf0f7a51f55154c2fadd48bc5d92 /src/server/youtubeApi | |
| parent | de7176884493c79ba11ecd871c3b444d36165367 (diff) | |
Pulled Duration and ViewCount details, Need to csss duration
Diffstat (limited to 'src/server/youtubeApi')
| -rw-r--r-- | src/server/youtubeApi/youtubeApiSample.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/server/youtubeApi/youtubeApiSample.js b/src/server/youtubeApi/youtubeApiSample.js index f875812d5..cf41a33e7 100644 --- a/src/server/youtubeApi/youtubeApiSample.js +++ b/src/server/youtubeApi/youtubeApiSample.js @@ -33,6 +33,10 @@ module.exports.authorizedGetVideos = (apiKey, userInput, callBack) => { authorize(JSON.parse(apiKey), getSampleVideos, { userInput: userInput, callBack: callBack }); } +module.exports.authorizedGetVideoDetails = (apiKey, videoIds, callBack) => { + authorize(JSON.parse(apiKey), getVideoDetails, { videoIds: videoIds, callBack: callBack }); +} + /** * Create an OAuth2 client with the given credentials, and then execute the @@ -156,4 +160,21 @@ function getSampleVideos(auth, args) { console.log('Videos found: ' + videos[0].id.videoId, " ", unescape(videos[0].snippet.title)); args.callBack(videos); }); +} + +function getVideoDetails(auth, args) { + let service = google.youtube('v3'); + service.videos.list({ + auth: auth, + part: 'contentDetails, statistics', + id: args.videoIds + }, function (err, response) { + if (err) { + console.log('The API returned an error: ' + err); + return; + } + let videoDetails = response.data.items; + console.log('Video Details founds: ', videoDetails); + args.callBack(videoDetails); + }); }
\ No newline at end of file |
