Skip to content

Commit

Permalink
youtube done
Browse files Browse the repository at this point in the history
need to pay attention to authentication!
  • Loading branch information
longshuicy authored Apr 19, 2017
1 parent c225331 commit 31b8ce9
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions API/youtubeAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var oauth2Client = new OAuth2(

oauth2Client.setCredentials({
access_token: config.youtube.access_token,
refresh_token: config.youtube.refresh_token
});

var youtube = google.youtube({
Expand All @@ -22,6 +23,7 @@ function youtubeAPI(resolveName, id, args){

switch(resolveName){
case 'search':
console.log(args)
youtube.search.list({
part: 'id,snippet',
key: config.youtube.api_key,
Expand Down Expand Up @@ -59,19 +61,71 @@ function youtubeAPI(resolveName, id, args){

case 'channel':
youtube.channels.list({
part: 'auditDetails, brandingSettings,contentDetails, contentOwnerDetails,id,invideoPromotion,snippet,statistics,status,topicDetails',
part: 'invideoPromotion,brandingSettings,contentDetails,contentOwnerDetails,id,snippet,statistics,status,topicDetails',
id: id
}, function (err, data) {
if (err){
console.log(err);
reject(err);
}else{
//console.log(data.items);
resolve(data.items);
}
});
break;

case 'video':
youtube.videos.list({
part: `contentDetails,id,liveStreamingDetails,player,
recordingDetails,snippet,statistics,status,topicDetails`,
id: id
}, function (err, data) {
if (err){
console.log(err);
reject(err);
}else{
//console.log(data.items);
resolve(data.items);
}
});
break;

case 'videoCommentthread':
//console.log(args);
youtube.commentThreads.list({
part:'id,snippet',
videoId: id,
maxResults: args['maxResults'],
searchTerms:args['searchTerms']
}, function(err,data){
if (err){
console.log(err);
reject(err);
}else{
//console.log(data.items);
resolve(data.items);
}
});
break;

case 'channelCommentthread':
console.log(args);
youtube.commentThreads.list({
part:'id,snippet',
channelId: id,
maxResults: args['maxResults'],
searchTerms:args['searchTerms']
}, function(err,data){
if (err){
console.log(err);
reject(err);
}else{
console.log(data.items);
resolve(data.items);
}
});
break;
}
}
})
}

Expand Down

0 comments on commit 31b8ce9

Please sign in to comment.