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 🙏

© 2025 – Pkg Stats / Ryan Hefner

discord-player-ytdlp

v1.0.4

Published

Discord Player extractor that utilizing yt-dlp

Readme

discord-player-ytdlp

A discord-player extractor that utilizing yt-dlp for streaming audio from various sites.

Features

  • YouTube Search: Uses youtubei.js for fast and reliable YouTube search
  • Multi-site Support: Stream audio from any site yt-dlp can handle
  • Playlist Support: Handles YouTube playlists including Mix playlists
  • Autoplay: Provides related tracks for autoplay functionality
  • Cookie Support: Supports Youtube cookies for video with restrictions

Installation

npm install discord-player-ytdlp

Requirements

  • Node.js 16 or higher
  • discord-player v7.0.0 or higher
  • yt-dlp binary (you need to provide the path to the binary)

Usage

const { Player } = require('discord-player');
const { YtDlpExtractor } = require('discord-player-ytdlp');

const player = new Player(client);

// Register the extractor
await player.extractors.register(YtDlpExtractor, {
    ytdlpPath: './bin/yt-dlp.exe', // Path to your yt-dlp binary
    priority: 100,
    enableYouTubeSearch: true,
    enableDirectUrls: true,
    preferYtdlpMetadata: true, // Use yt-dlp for YouTube metadata (default: true)
    streamQuality: 'bestaudio[ext=m4a]/bestaudio[ext=webm]/bestaudio',
    youtubeiOptions: {
        cookies: process.env.YOUTUBE_COOKIES, // Optional: YouTube cookies
        client: 'WEB' // Optional: YouTube client
    }
});

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | ytdlpPath | string | Required | Path to the yt-dlp binary | | priority | number | 100 | Priority of this extractor | | enableYouTubeSearch | boolean | true | Enable YouTube search functionality | | enableDirectUrls | boolean | true | Enable direct URL extraction | | preferYtdlpMetadata | boolean | true | Prefer yt-dlp for YouTube metadata over youtubei.js | | streamQuality | string | 'bestaudio[ext=m4a]/bestaudio[ext=webm]/bestaudio' | Stream quality format for yt-dlp | | youtubeiOptions.cookies | string\|object | null | YouTube cookies for authentication | | youtubeiOptions.client | string | null | YouTube client configuration |

Supported Sites

Check here for a list of supported sites

Metadata Strategy

The extractor supports two metadata sources for YouTube videos:

  • yt-dlp (default): More consistent with streaming, better for reliability
  • youtubei.js: Faster, better for duration parsing, uses YouTube's internal API

You can control this with the preferYtdlpMetadata option:

// Use yt-dlp for metadata (default - more consistent)
preferYtdlpMetadata: true

// Use youtubei.js for metadata (faster, better duration handling)
preferYtdlpMetadata: false

Both options include automatic fallback to the other method if the preferred one fails.

YouTube Cookies

To access private YouTube content or improve reliability, you can provide YouTube cookies:

  1. Export cookies from your browser in Netscape format
  2. Set the cookies in the configuration:
youtubeiOptions: {
    cookies: 'your_cookies_string_here'
}

Examples

Basic Usage

// Search for a song
const searchResult = await player.search('Never Gonna Give You Up', {
    requestedBy: interaction.user
});

// Play a YouTube URL
await player.play(voiceChannel, 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', {
    requestedBy: interaction.user
});

// Play a YouTube playlist
await player.play(voiceChannel, 'https://www.youtube.com/playlist?list=PLrAXtmRdnEQy6nuLMt9xaJGA6H_VjBf9L', {
    requestedBy: interaction.user
});

With Custom Options

await player.extractors.register(YtDlpExtractor, {
    ytdlpPath: './bin/yt-dlp.exe',
    priority: 150, // Higher priority
    preferYtdlpMetadata: false, // Prefer youtubei.js for metadata
    streamQuality: 'bestaudio[ext=webm]/bestaudio', // Prefer WebM
    youtubeiOptions: {
        cookies: process.env.YOUTUBE_COOKIES,
        client: 'ANDROID' // Use Android client
    }
});

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Supporting

Star and pull request to the repo!