DisTube fork of ytdl-core
. This fork is dedicated to fix bugs and add features that are not merged to the original repo as soon as possible.
npm install @distube/ytdl-core@latest
Or for Yarn users:
yarn add @distube/ytdl-core@latest
Make sure you're installing the latest version of @distube/ytdl-core
to keep up with the latest fixes.
All the usage is the same as the original repo, except for the installation part.
const fs = require("fs");
const ytdl = require("@distube/ytdl-core");
// TypeScript: import ytdl from '@distube/ytdl-core'; with --esModuleInterop
// TypeScript: import * as ytdl from '@distube/ytdl-core'; with --allowSyntheticDefaultImports
// TypeScript: import ytdl = require('@distube/ytdl-core'); with neither of the above
ytdl("http://www.youtube.com/watch?v=aqz-KE-bpKQ").pipe(fs.createWriteStream("video.mp4"));
You can find the API documentation in the original repo
ytdl cannot download videos that fall into the following
- Regionally restricted (requires a proxy)
- Private (if you have access, requires cookies)
- Rentals (if you have access, requires cookies)
- YouTube Premium content (if you have access, requires cookies)
- Only HLS Livestreams are currently supported. Other formats will get filtered out in ytdl.chooseFormats
Generated download links are valid for 6 hours, and may only be downloadable from the same IP address.
When doing to many requests YouTube might block. This will result in your requests getting denied with HTTP-StatusCode 429. The following Steps might help you:
- Update
@distube/ytdl-core
to the latest version - Use proxies (you can find an example here)
- Extend on the Proxy Idea by rotating (IPv6-)Addresses
- read this for more information about this
- Use cookies (you can find an example here)
- for this to take effect you have to FIRST wait for the current ratelimit to expire
- Wait it out (it usually goes away within a few days)
The issue of using an outdated version of ytdl-core became so prevalent, that ytdl-core now checks for updates at run time, and every 12 hours. If it finds an update, it will print a warning to the console advising you to update. Due to the nature of this library, it is important to always use the latest version as YouTube continues to update.
If you'd like to disable this update check, you can do so by providing the YTDL_NO_UPDATE
env variable.
env YTDL_NO_UPDATE=1 node myapp.js
- DisTube - A Discord.js module to simplify your music commands and play songs with audio filters on Discord without any API key.
- @distube/ytsr - DisTube fork of ytsr.
- @distube/ytpl - DisTube fork of ytpl.