1.2.2 • Published 12 months ago

yt-dlp-wrapper v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

YT-DLP Wrapper

A small wrapper for usage of the yt-dlp command-line utility project with JavaScript/TypeScript.

NOTE: This package is still in development and may not work as expected. Additional features such as download options will be added in the very near future.

Features

  • Download videos (single or playlist)
  • Progress events for downloads
  • Concurrent downloads with a configurable limit
  • Video metadata (single or playlist)
  • Video count for playlists

Installation

npm install --save yt-dlp-wrapper

Getting Started

The package can be imported with both CommonJS and ES6.

// ES6
import { DownloadCommand, MetadataCommand, VideoCountCommand } from 'yt-dlp-wrapper';

// CommonJS
const { DownloadCommand, MetadataCommand, VideoCountCommand } = require('yt-dlp-wrapper');

Usage

Download

import { DownloadCommand, DownloadProgress } from 'yt-dlp-wrapper';

// The absolute path to the store the downloaded files
const command = new DownloadCommand('C:\\Users\\User\\Downloads', {});

// Get the current download progress
command.on('progress', (progress: DownloadProgress): void => {
  console.log(progress);
});

// Get the download error if one occurs
command.on('error', (error: Error): void => {
  console.error(error);
});

// Get the download completion event
command.on('complete', (): void => {
  console.log('Download finished!');
});

// Add URL to download
command.add('https://www.youtube.com/watch?v=dQw4w9WgXcQ');

// Start the download
command.start();

Metadata

import { MetadataCommand, VideoDetails } from 'yt-dlp-wrapper';

const command = new MetadataCommand({});

// Get the execution error if one occurs
command.on('error', (error: Error): void => {
  console.error(error);
});

// Get the metadata extraction completion event
command.on('complete', (metadata: VideoDetails[]): void => {
  console.log('Metadata extracted!');
});

// Start the metadata extraction
command.get('https://www.youtube.com/watch?v=dQw4w9WgXcQ');

or

import { MetadataCommand, VideoDetails } from 'yt-dlp-wrapper';

const command = new MetadataCommand({});

try {
  // Perform the metadata extraction
  const metadata: VideoDetails[] = await command.getSync('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
} catch (err) {
  // Handle the error
}

Video Count

import { VideoCountCommand } from 'yt-dlp-wrapper';

const command = new VideoCountCommand({});

// Get the execution error if one occurs
command.on('error', (error: Error): void => {
  console.error(error);
});

// Get the video count completion event
command.on('complete', (count: number): void => {
  console.log('Video count retrieved!');
});

// Start the video count extraction
command.get('https://www.youtube.com/watch?v=dQw4w9WgXcQ');

or

import { VideoCountCommand } from 'yt-dlp-wrapper';

const command = new VideoCountCommand({});

try {
  // Perform the video count extraction
  const count = await command.getSync('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
} catch (err) {
  // Handle the error
}

Warning

  • This package/software is not affiliated with the yt-dlp project.
  • This package/software is intended for personal use only.
  • Breaking DRM protection would imply piracy, so any functionality to do so will not be included.
  • Use of this package/software is at your own risk. Some third-party video platforms prohibit the downloading of their content. I am NOT responsible if your account gets banned/suspended.

License

This project is licensed under the MIT License - see the LICENSE file for details.