Licence
MIT
Version
1.1.0
Deps
1
Size
53 kB
Vulns
0
Weekly
0
@distube/youtube
A DisTube extractor plugin for supporting YouTube.
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()],
});
Search
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])
YoutubePluginOptions.cookies: (Optional) YouTube cookies. See: How to get YouTube cookiesYoutubePluginOptions.ytdlOptions: (Optional)@distube/ytdl-coreoptions, such aslang,clientsorgetPoToken.cookiesreplaces itscookie.
YouTubePlugin#search(query, [options]): Promise<Song[]|SearchResultPlaylist[]>
query: Search query stringoptions: Search optionsoptions.type: Type of results (videoorplaylist)options.limit: Maximum number of results to returnoptions.safeSearch: Whether or not use safe search (YouTube restricted mode)
SearchResultPlaylist
id: Playlist IDname: Playlist nameurl: Playlist URLlength: Number of videos in the playlist,0when YouTube does not show ituploader: Playlist owneruploader.name: Playlist owner nameuploader.url: Playlist owner URL
