playlist.js
861 Bytes
var {google} =require('googleapis');
var service = google.youtube('v3');
const oauth2Service = require('./oauth2');
function getPlaylistData(oauth2Client, channelId) {
service.playlists.list({
auth: oauth2Client,
part: 'id, snippet',
fields: 'items(id, snippet(title, description, thumbnails(default(url))))',
channelId: channelId
}, function(err, response) {
if(err) {
console.log('The API returned an error: ' + err);
return;
}
var channels = response.data.items;
if (channels.length == 0){
console.log('No channel found.')
} else {
console.log(JSON.stringify(channels, null, 4));
}
});
}
oauth2Service.refreshClient()
.then((client) => {
getPlaylistData(client, 'UCx6jsZ02B4K3SECUrkgPyzg');
})
.catch(console.error);