Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@qodestack/dl-yt-playlist

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qodestack/dl-yt-playlist

Download all videos (or audio only) from a YouTube playlist!

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
94
increased by4600%
Maintainers
1
Weekly downloads
 
Created
Source

Download YouTube Playlist

Download all YouTube videos (or audio only) from every video in a playlist!

Prerequisites

You'll need a few things to use this project:

  • This project uses Bun! Get that installed or feel free to edit the source code to use Node instead (it'll only be a few adjustments).
  • You'll need a YouTube Data API key. Set that to the API_KEY env variable.
  • The yt-dlp command line tool needs to be present on your system. You can easily install it with a tool like Brew.

Usage

Say you have this code in a file named download.ts:

import {downloadYoutubePlaylist} from 'dl-yt-playlist'

const {playlistId, apiKey} = process.env

const resultsMetadata = await downloadYoutubePlaylist({
  // Required:
  playlistId: <string>, // The YouTube playlist id
  apiKey: <string>, // Your YouTube Data api key

  // Optional:
  audioOnly: <boolean>, // `true` for audio MP3, `false` for video MP4
  getFullData: <boolean>, // `false` will only get the 1st 50 videos
  jsonOnly: <boolean>, // Skips download video files, generates JSON files only
  maxLengthInSeconds: <number>, // Videos longer than this will be skipped
})

Now you can use Bun to run the file:

bun run download.ts

Folder Structure

Downloads will be organized into the following folder structure:

data
  /<playlist name>
    /video
    /audio
    responses.json
    videoMetadata.json
/videoThis folder will contain all the mp4 video files
/audioThis folder will contain all the mp3 audio files
responses.jsonThis file will contain all the responses from the YouTube api. This is useful for understanding the shape of the data.
videoMetadata.jsonThis file will contain an array metadata on each video. See shape below

Video Metadata Shape

Each video will have metadata stored in the videoMetadata.json with the following shape:

{
  id: string
  title: string
  channel: string
  publishedAt: string
  dateAddedToPlaylist: string
  url: string
  lengthInSeconds: number
}

Keywords

FAQs

Package last updated on 05 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc