@distube/ytdl-core

中文文档
5.2.1发布于 2026/11/04MITTypeScriptES Module构建来源已验证近 30 天下载 26.1万

YouTube video info and downloads for Node.js, with local player solving and resumable streams.

原始使用文档
文档目录5 节
  1. Features
  2. Install
  3. Usage
  4. Development
  5. License

@distube/ytdl-core

YouTube video info and downloads for Node.js. A DisTube fork of fent/node-ytdl-core.

Documentation · Getting started · API reference

Buy Me a Coffee at ko-fi.com

Features

  • Video details, chapters, storyboards, related videos and every format
  • Caption tracks as WebVTT, JSON or XML text
  • Video and playlist search, playlists and channel uploads with every page, related videos and search suggestions
  • Node Readable downloads with byte ranges or a start time, and one format read many times through open
  • Downloads that resume on their own when YouTube cuts a URL off
  • Live streams over HLS or DASH
  • SABR-only formats, which on some clients means everything above 360p
  • Signatures solved locally, no remote service
  • Age-restricted videos with a cookie
  • PO tokens minted in a worker thread with no setup, for the clients that need one
  • Proxies through any fetch

Install

npm install @distube/ytdl-core
bun add @distube/ytdl-core

Requires Node.js 22.22.2+ on 22.x, 24.15.0+ on 24.x, or 26+, or Bun.

Usage

import { createWriteStream } from "node:fs";
import { Quality, Ytdl } from "@distube/ytdl-core";

const yt = new Ytdl();

const info = await yt.getInfo("https://www.youtube.com/watch?v=aqz-KE-bpKQ");
console.log(info.videoDetails.title);

yt.download(info, { quality: Quality.HighestAudio, filter: { hasAudio: true, hasVideo: false } }).pipe(
  createWriteStream("audio.webm"),
);

const [first] = await yt.search("blender open movie", { limit: 5 });
const playlist = await yt.getPlaylist("https://www.youtube.com/playlist?list=PL2aBZuCeDwlRF14ds9UR1uVpLRjDQy7d5");
console.log(first?.title, playlist.videos.length);

Search, formats, live streams, clients, cookies, PO tokens, proxies and errors are covered in the documentation. Coming from 4.x? Read Migrating from v4.

Development

Run bun install, then bun run verify for the offline gates.

License

MIT.

版本与发布记录

@distube/ytdl-core 共发布 69 个版本,首次发布于 2021/08/10;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.2.1latest2026/11/048 天前
5.2.02026/10/3013 天前
5.1.32026/10/2815 天前
5.1.22026/10/2815 天前
5.1.12026/10/2815 天前
5.1.02026/10/2815 天前

关于 @distube/ytdl-core 的常见问题

@distube/ytdl-core 是什么?

YouTube video info and downloads for Node.js, with local player solving and resumable streams.

如何安装 @distube/ytdl-core?

在项目目录运行 npm install @distube/ytdl-core,或使用 pnpm add / yarn add / bun add。

@distube/ytdl-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@distube/ytdl-core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@distube/ytdl-core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.22.2 || ^24.15.0 || >=26.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@distube/ytdl-core 可以商用吗?

@distube/ytdl-core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@distube/ytdl-core 的下载量有多少?

根据 npm 官方下载统计,@distube/ytdl-core 在 2026/10/13 – 2026/11/11 这 30 天内被下载 261,021 次,日均约 8,701 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@distube/ytdl-core 还在维护吗?

最新版本 5.2.1 发布于 2026/11/04(8 天前);至今共发布 69 个版本,其中过去 12 个月发布了 9 个;首次发布于 2021/08/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。