1.0.8 • Published 3 years ago
@deebah/youtube v1.0.8
YouTube is a simple YouTube api that allows you to get information from a YouTube video.
- getVideoFromId -- Gets video information from a YouTube video ID.
- getVideoFromUrl -- Gets video information from a YouTube video URL.
- getPlaylistVideos -- Gets playlist videos from a YouTube playlist URL.
Example Usage
const YouTube = require('@deebah/youtube');
const yt = new YouTube('YOUR YOUTUBE API KEY');
const id = 'BxV14h0kFs0'; // Just an example video.
const url = 'https://youtube.com/watch?v=BxV14h0kFs0'; // Just an example url.
const playlistUrl = 'https://www.youtube.com/playlist?list=PLOzDu-MXXLliO9fBNZOQTBDddoA3FzZUo'
yt.getVideoFromId(id, function(data) {
console.log(data);
/*{
kind: 'youtube#videoListResponse',
etag: 'tDSt5ROvi-AgdlorJ0aM910TuMI',
items: [
{
kind: 'youtube#video',
etag: 'm9Ii_n5FgJAt-b3pBttFa2w6J4w',
id: 'BxV14h0kFs0',
snippet: [Object]
}
],
pageInfo: { totalResults: 1, resultsPerPage: 1 }
}*/
});
yt.getVideoFromUrl(url, function (data) {
console.log(data);
/*{
kind: 'youtube#videoListResponse',
etag: 'tDSt5ROvi-AgdlorJ0aM910TuMI',
items: [
{
kind: 'youtube#video',
etag: 'm9Ii_n5FgJAt-b3pBttFa2w6J4w',
id: 'BxV14h0kFs0',
snippet: [Object]
}
],
pageInfo: { totalResults: 1, resultsPerPage: 1 }
}*/
});
yt.getPlaylistVideos(playlistUrl, data => {
console.log(data);
/*[
{
url: 'https://www.youtube.com/watch?v=WTsmIbNku5g',
title: 'Kina - get you the moon (ft. Snow)'
},
{
url: 'https://www.youtube.com/watch?v=qz7tCZE_3wA',
title: 'Kina - Can We Kiss Forever? (ft. Adriana Proenza)'
},
48 more items...
]*/
});