youtube-dl-progress-improved

1.1.2 • Public • Published

An Improved Node.js Wrapper for YoutubeDL

youtube-dl conventionally makes it very hard to get progress information on the status of a download. This module implements a new function download which returns a ProgressPromise. This promise allows you to get the status of the download, but also implements a progress method for you to be informed of the file's size and download progress.

Arguments

See youtube-dl-exec for a listing of the arguments which can be passed to youtube-dl.

Options

We also accept an options object which only has a single option at the moment:

  • timeout: How many ms after which we should abort the download. Set to false to never timeout.

Example

const { download } = require('youtube-dl-progress-improved')

const promise = download("https://www.youtube.com/watch?v=dQw4w9WgXcQ", {
  // youtube-dl options go here:
  format: 'bestvideo[height <=? 480]+bestaudio/best[height <=? 480]',
}, {
  // our options go here, currently that's only:
  timeout: 60 * 1000,
})

promise.progress((value) => {
  console.log(value.percentage, value.totalSizeBytes, value.timeRemainingSeconds, value.rateBytesPerSecond)
})

promise.then(() => {
  console.log("Download completed")
}, (err) => {
  console.error("Error downloading", err)
})

// You can also cancel a download:
promise.cancel()

// A cancelled download will reject, but `promise.cancelled` will be true

/youtube-dl-progress-improved/

    Package Sidebar

    Install

    npm i youtube-dl-progress-improved

    Weekly Downloads

    2

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    5.11 kB

    Total Files

    3

    Last publish

    Collaborators

    • zackbloom