youtube-s-dl
v1.1.0-beta
Published
A YouTube Video/Audio downloader.
Downloads
17
Maintainers
Readme
YOUTUBE SEARCH & DOWNLOAD
A YouTube Video downloader.
HOW TO INSTALL?
npm i youtube-s-dl
Require to export function
//CommonJS
const {download, search, getStreamFormats, getVideoInfo} = require("youtube-s-dl");
SIMPLE USAGE
search and download videos
const {download, search, getVideoInfo} = require("youtube-s-dl");
let result = await search("Senpai (feat. Hentai Dude)")
console.log(result)
let info = getVideoInfo(result[0].videoId)
console.log(info)
try{
//download have 2 params. first is videoId required
//2nd Format object is optional param.
format = {
mimeType: 'video',
qualityLabel: '480p',
fps: 30
//etc.
}
stream = await download(result[0].videoId, format)
path = "./tmp/videoplayback.mp4"
file = fs.createWriteStream(path)
stream.pipe(file).on('finish',()=>{
console.log("Video Downloaded")
}).on('close',()=>{
console.log("Request Finished")
}).on('error',()=>{
console.log("Seems there's an error happened while writing the file.")
})
}
catch(e){
console.log(e)
}