youtube-s-dl

1.1.0-beta • Public • Published

YOUTUBE SEARCH & DOWNLOAD

ytvanced

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)
}

Package Sidebar

Install

npm i youtube-s-dl

Weekly Downloads

16

Version

1.1.0-beta

License

MIT

Unpacked Size

14.2 kB

Total Files

15

Last publish

Collaborators

  • hackmesenpai