1.1.8 • Published 5 years ago
yutub v1.1.8
const { YouTube } = require('yutub');
// or using ES6 Modules
import { YouTube } from 'yutub';
const youtube = new YouTube();
youtube.searchVideos('RADAL')
.then(videos => {
videos.forEach(video => console.log(video.title));
}).catch(console.error);
Table of contents
Instalation
$ npm i yutub
# or using yarn
$ yarn add yutub
Classes
YouTube
Get a YouTube video with ID or URL.
<YouTube>.getVideo(idOrURL: string): Promise<YouTubeVideo>
Example
<YouTube>.getVideo('N_8PCKLjJJ4')
.then(video => console.log(video.likes))
.catch(console.error);
// or usign YouTube video URL
<YouTube>.getVideo('https://www.youtube.com/watch?v=YQQ4B0nERgk')
.then(video => console.log(video.likes))
.catch(console.error);
Get a YouTube playlist with ID or URL.
<YouTube>.getPlaylist(idOrURL: string): Promise<YouTubePlaylist>
Example
<YouTube>.getPlaylist('PLQkoKTppclIub0WqgTq8Ereq-AlHgwdmI')
.then(console.log)
.catch(console.error);
// or usign YouTube playlist URL
<YouTube>.getPlaylist('https://www.youtube.com/playlist?list=PLvyTxJxuNWd5rIWuMJzotDqf-Z3dIrmHk')
.then(console.log)
.catch(console.error);
Search for videos on YouTube.
<YouTube>.searchVideos(value: string, searchLimit?: number): Promise<Array<YouTubeVideoSearch>>
Example
<YouTube>.searchVideos('PewDiePie')
.then(videos => {
videos.forEach(video => console.log(video.title));
}).catch(console.error);
ToDo
Issues
If you found a bug or want to make a suggestion, open an issue.