ytdlp-nodejs
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

YTDLP-NODEJS

A youtube video downloader library for nodejs based on ytdlp


Description

ytdlp-nodejs is a Node.js library that provides functionality to download videos from YouTube, get video streams and thumbnails. It is based on the popular Python library, ytdlp, and has strong TypeScript type support. has strong TypeScript type support.

Installation

npm i ytdlp-nodejs

Get Started

const ytdlp = require('ytdlp-nodejs')
const {createWriteStream} = require('fs')
const url = "https://www.youtube.com/watch?v=Qzc_aX8c8g4";

const file = createWriteStream("test.mp4");
// get stream
const stream = ytdlp
    .stream(url, {
        filter: "videoonly",
        quality: "2160p",
    })
    .on("error", (err) => {
        console.log(err);
    })
    .pipe(file);

// download video
ytdlp
    .download(url, {
        filter: "mergevideo",
        quality: "1080p",
        output: {
          fileName: "hello.mp4",
          outDir: "test",
        },
    })
    .on("progress", (data) => {
        console.log(data);
    });

API

$ ytdlp.download(url: string, options?: DownloadOptions)

$ ytdlp.stream(url: string, options?: StreamOptions):stream

$ ytdlp.thumbnail(url: string, options?:ThumbnailsOptions): string

DownloadOptions

filter: "videoonly" | "audioonly" | "audioandvideo" | "mergevideo"

  • filter: "videoonly"

    • quality: "2160p" | "1440p" | "1080p" | "720p" | "480p" | "360p" | "240p" | "144p" | "highest" | "lowest" (default: 'highest')
    • format: "mp4" | "webm" (default:'mp4')
  • filter: "audioonly"

    • quality: "highest" | "lowest" (default:'highest')
  • filter: "audioandvideo"

    • quality: "highest" | "lowest" (default:'highest')
    • format: "mp4" | "webm" (default:'mp4')
  • filter: "audioonly"

    • quality: 0 to 10 (default:5)
    • format: "aac" | "flac" | "mp3" | "m4a" | "opus" | "vorbis" | "wav" | "alac" (default:'mp3')
  • filter: "mergevideo"

    • quality: "2160p" | "1440p" | "1080p" | "720p" | "480p" | "360p" | "240p" | "144p" | "highest" | "lowest" (default: 'highest')
    • format: "mkv" | "mp4" | "ogg" | "webm" | "flv" (default:'mp4')
    • embedSubs: boolean (default:false)
    • embedThumbnail: boolean (default:false)

output: "string" | "object"

  • string : Path string
  • object : { outDir: string, fileName: string | 'default' }

StreamOptions

filter: "videoonly" | "audioonly" | "audioandvideo"

  • filter: "videoonly"

    • quality: "2160p" | "1440p" | "1080p" | "720p" | "480p" | "360p" | "240p" | "144p" | "highest" | "lowest" (default: 'highest')
  • filter: "audioonly"

    • quality: "highest" | "lowest" (default:'highest')
  • filter: "audioandvideo"

    • quality: "highest" | "lowest" (default:'highest')
  • filter: "extractaudio"

    • quality: 0 to 10 (default:5)
    • format: "aac" | "flac" | "mp3" | "m4a" | "opus" | "vorbis" | "wav" | "alac" (default:'mp3')
  • filter: "mergevideo"

    • quality: "2160p" | "1440p" | "1080p" | "720p" | "480p" | "360p" | "240p" | "144p" | "highest" | "lowest" (default: 'highest')
    • format: "mkv" | "mp4" | "ogg" | "webm" | "flv" (default:'mp4')
    • embedSubs: boolean (default:false)
    • embedThumbnail: boolean (default:false)
    • defaultQuality: "highest" | "lowest" | "none" (default:'highest')

ThumbnailsOptions

  • quality: "max" | "hq" | "mq" | "sd" | "default" (default: 'default')
  • type: "jpg" | "webp" (default: 'jpg')

Contribution

If you want to contribute or report any bug, you welcome
Don't forget to give a star 😍

Package Sidebar

Install

npm i ytdlp-nodejs

Weekly Downloads

19

Version

0.1.4

License

MIT

Unpacked Size

59.9 kB

Total Files

36

Last publish

Collaborators

  • rashed_iqbal