video_lists.js 579 Bytes
var {google} =require('googleapis');

var service = google.youtube('v3');
service.videos.list({
    key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518',
    part: 'snippet',
    id: 'p5iu1V30myk', // 동영상 Id
    fields: 'items(snippet(title))'
}, function(err, response) {
    if (err) {
        console.log('The API returned an error: ',err);
        return;
    }

    var video =response.data.items;
    if(video.length ==0){
        console.log('검색된 동영상이 없습니다.');
    } else {
        console.log(JSON.stringify(response.data.items[0],null,4));
    }
})