ytdl-core is a pure JavaScript library designed for downloading YouTube videos directly within Node.js environments, offering a streaming interface for efficient processing. Its current stable version is 4.11.5, with releases typically occurring as needed to address breaking changes from YouTube's API or to introduce minor features and bug fixes. The project shows an active maintenance cycle, frequently releasing patches (e.g., 4.11.2 to 4.11.5 in a few months) to adapt to YouTube's evolving infrastructure, particularly around video parsing and signature deciphering. A key differentiator is its focus on a lean, Node.js-friendly streaming API, allowing developers to pipe video streams directly to file systems or other processing utilities without intermediate storage. It ships with TypeScript types, facilitating its use in modern TypeScript projects.
npm install ytdl-coreVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to download a YouTube video using `ytdl-core` and pipe it directly to a file. It also shows a commented-out example of how to retrieve video metadata using `getInfo`.
Regularly update `ytdl-core` to the latest version. If using a wrapper library, ensure it has updated its `ytdl-core` dependency.
For precise segment downloads, consider manually seeking or processing the full download with a tool like FFmpeg, or using the `range` option if applicable.
Utilize `ytdl.getInfo()` to get available formats, select separate audio-only and video-only streams, download them, and then use a library (e.g., `fluent-ffmpeg`) to merge them. See the `example/ffmpeg.js` in the official repository.
For active development and guaranteed fixes, consider migrating to a actively maintained fork like `@distube/ytdl-core` if you encounter persistent issues or require new features.
Ensure `ytdl-core` is the latest version. Check if the video is genuinely available and not restricted. For geo-restricted or private videos you have access to, consider using proxy or cookie options.
Update `ytdl-core` to the latest version to get the newest parsing fixes. If the problem persists, check for existing issues on the GitHub repository or create a new one, providing the video URL.
Ensure `ytdl-core` is updated. Implement IPv6 rotation via the `IPv6Block` option or use a proxy to circumvent throttling. Adjust `dlChunkSize` if large files are being throttled.
In `tsconfig.json`, set `"esModuleInterop": true` or `"allowSyntheticDefaultImports": true`. Then use `import ytdl from 'ytdl-core';`. Alternatively, use `import * as ytdl from 'ytdl-core';`.