npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dada78641/ytdlpdata

v0.0.1

Published

Helper library for running yt-dlp to fetch JSON info

Downloads

30

Readme

TypeScript MIT license npm version

@dada78641/ytdlpdata

This is a very basic library designed for personal purposes. Feel free to use it, but don't necessarily expect updates or support.

A basic library for fetching video metadata using yt-dlp. This library is designed to retrieve structured and typed information from video URLs but does not support video downloads. It runs yt-dlp with the --dump-json flag (among various other options) and returns the output as typed objects.

The yt-dlp output data is somewhat unpredictable due to feature differences between video hosting sites, and the fact that individual videos can differ in numerous ways. As a result of that, the TypeScript types are not entirely correct.

Usage

To start making calls, instantiate a YtDlpData class:

import {YtDlpData, type YtDlpVideoResult} from '../src/index.ts'

// Instantiate a new yt-dlp instance. This will not spawn a process just yet.
// Here you can pass the path to yt-dlp and set default arguments.
const ytDlp = new YtDlpData()

// Get a private video that my logged in user has access to.
const privateVideo = await ytDlp.getVideoData('https://www.youtube.com/watch?v=GsBeCEQwEEI', ['--cookies-from-browser', 'firefox'])

// Get the 10 latest videos for a particular channel, with a short delay to avoid rate limiting.
const latestVideos = await ytDlp.getPlaylistData('https://www.youtube.com/@CoachPupilLeague/videos', ['--playlist-items', '1-10', '--sleep-requests', '5'])

// Get only basic info about the 10 latest items. This completes much faster since it only needs to process a single HTML page.
const latestVideosFlat = await ytDlp.getPlaylistData('https://www.youtube.com/@CoachPupilLeague/videos', ['--playlist-items', '1-10', '--flat-playlist'])

// Retrieve only channel data, without any video info.
const channelInfo = await ytDlp.getChannelData('https://www.youtube.com/@CoachPupilLeague')

// Request yt-dlp to self-update. This returns an update information object.
const updateInfo = await ytDlp.updateYtDlp()

// Call --dump-json and emit payloads as they come in.
function getSeveralVideos() {
  const payloads: YtDlpVideoResult[] = []
  return new Promise(async (resolve, reject) => {
    const call = await ytDlp.createVideoEmitter('https://ch.sooplive.co.kr/scv6256/vods/review')
    call.on('log', (message: string) => {
      // If --verbose is set, messages will be logged here.
      console.log('log', message)
    })
    call.on('payload', (payload: YtDlpVideoResult) => {
      // The payload is a single video (or a single part of a video, if it is really a playlist item).
      // Process your payload here, or save them up in an array to resolve later, as we're doing here.
      payloads.push(payload)
      // If you have sufficient video results, you can exit the process and resolve.
      call.abort()
      resolve(payloads)
    })
    call.on('close', (code: number | null, signal: NodeJS.Signals | null) => {
      // Called on process close.
      console.log('close', code, signal)
      resolve(payloads)
    })
    call.on('error', (err: Error) => {
      reject(err)
    })
  })
}

Note that some calls will take a very long time to complete. Make sure to set sensible limits.

License

MIT licensed.