npm.io
1.1.0 • Published 5d ago

@distube/youtube

Licence
MIT
Version
1.1.0
Deps
1
Size
53 kB
Vulns
0
Weekly
0

npm peer dependency version npm GitHub Repo stars Discord

Buy Me a Coffee at ko-fi.com

@distube/youtube

A DisTube extractor plugin for supporting YouTube.

What is an extractor plugin?

Feature

  • Scraping YouTube data without using API key
  • Support YouTube video playlists and channel uploads
  • Search on YouTube
  • Play video directly from YouTube

Requirements

Node.js ^22.22.2 || ^24.15.0 || >=26.0.0, the range @distube/ytdl-core 5 supports.

Usage

Plugin
import { DisTube } from "distube";
import { YouTubePlugin } from "@distube/youtube";

const distube = new DisTube(client, {
  plugins: [new YouTubePlugin()],
});
import { DisTube } from "distube";
import { YouTubePlugin } from "@distube/youtube";

const youtubePlugin = new YouTubePlugin({
  cookies: [
    // ...
  ],
});

const distube = new DisTube(client, {
  plugins: [youtubePlugin],
});

const results = await distube.search("test", { type: "video", limit: 10 });
console.log(results);

Documentation

YouTubePlugin
YouTubePlugin([YouTubePluginOptions])
YouTubePlugin#search(query, [options]): Promise<Song[]|SearchResultPlaylist[]>
  • query: Search query string
  • options: Search options
  • options.type: Type of results (video or playlist)
  • options.limit: Maximum number of results to return
  • options.safeSearch: Whether or not use safe search (YouTube restricted mode)
SearchResultPlaylist
  • id: Playlist ID
  • name: Playlist name
  • url: Playlist URL
  • length: Number of videos in the playlist, 0 when YouTube does not show it
  • uploader: Playlist owner
  • uploader.name: Playlist owner name
  • uploader.url: Playlist owner URL

Keywords