# @distube/ytpl 中文文档

规范地址：https://npmcn.com/package/%40distube/ytpl/

版本：1\.2\.4
npm 元数据更新时间：2026-10-22T07:54:22.284Z
中文译文更新时间：2026-11-12T11:39:37.990Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40distube/ytpl
原文对照：https://npmcn.com/package/%40distube/ytpl/?lang=original
项目主页：https://github.com/distubejs/ytpl#readme
源码仓库：https://github.com/distubejs/ytpl

弃用说明：Unmaintained\. Use Ytdl\#getPlaylist from @distube/ytdl-core 5: https://github\.com/distubejs/ytdl-core/blob/main/docs/guides/playlists\.md

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：25.2 kB，7 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=18
- 运行依赖：1 个
- 首次发布：2020-11-12T22:32:34.114Z
- 最新版本发布：2025-12-21T10:04:01.356Z
- 近 30 天下载量：8206（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：24（近 12 个月 1 个）

## 中文简介

匿名YouTube播放列表解析器. 为 distube.js.org 制作

## 安装

```sh
npm install @distube/ytpl
```

也可以使用：`pnpm add @distube/ytpl`、`yarn add @distube/ytpl`、`bun add @distube/ytpl`

## README

# @distube/ytpl (英语)

轻量级 ytpl [磁盘Tube](https://distube.js.org/)原样 [ytpl 语录](https://www.npmjs.com/package/ytpl)。 。 。 . 简单的js只解决YouTube播放列表的软件包. 不需要任何登录或Google-API-Key.

# 安装

```bash
npm install @distube/ytpl
```

# 使用量

```js
const ytpl = require("@distube/ytpl");

const playlist = await ytpl("https://www.youtube.com/playlist?list=PLRBp0Fe2GpglkzuspoGv-mu7B2ce9_0Fn");
```

# API 密码

### ytpl( id, \[选项\])

试图解析指定的播放列表 id

-   `id`
    
    -   yt 播放列表中的 id
    -   或播放列表url
    -   或用户 url( 解决上传播放列表)
    -   或频道 url( 解析上传播放列表)
-   `options`
    
    -   有选项的对象
    -   可能的设置 :
    -   gl \[结 --\] 一个国家的2-数字代码,默认为 `US` - 允许将请求本地化
    -   hl\[标\]-\]. 语言的2-数字代码,默认为 `en` - 允许将请求本地化
    -   utcOffsetminutes \[数量\] - > 从协调世界时算起,默认为 `-300` - 允许将请求本地化
    -   限制 \[数\] - > 限制所拉项目, 默认值为 100, 设置到无限值以获取整个播放列表 - 数字 < 1 导致使用默认值
    -   备选\[标 −> 所有附加参数都会传递给undici的 [请求选项](https://github.com/nodejs/undici#undicirequesturl-options-promise),用于执行 https 请求
-   返回承诺
    
-   [示例响应](https://github.com/distubejs/ytpl/blob/master/example/example_output)
    

### ytpl.validateID( 字符串)

如果能够解析( 正式) 有效的播放列表 ID , 返回真 .

### ytpl.getPlaylistID(字符串)

从YouTube URL返回播放列表ID. 可以直接使用播放列表ID调用,在这种情况下可以解决.

返回一个承诺.

# 相关/与

-   [磁盘Tube](https://github.com/skick1234/DisTube) - 一个Discord.js模块,用于简化您的音乐命令,并在Discord上播放没有API密钥的有音频过滤器的歌曲.
-   [@distube/ytdl-核心](https://github.com/distubejs/ytdl-core) - 盘管叉 [ytdl (英语)](https://github.com/fent/node-ytdl-core)。 。 。 .
-   [@distube/ytsr (英语)](https://github.com/distubejs/ytsr) - 盘管叉 [ytsr (英语)](https://github.com/TimeForANinja/node-ytsr)。 。 。 .

## 常见问题

### @distube/ytpl 是什么？

匿名YouTube播放列表解析器\. 为 distube\.js\.org 制作注意：该包已被作者标记为弃用——Unmaintained\. Use Ytdl\#getPlaylist from @distube/ytdl-core 5: https://github\.com/distubejs/ytdl-core/blob/main/docs/guides/playlists\.md

### 如何安装 @distube/ytpl？

在项目目录运行 npm install @distube/ytpl，或使用 pnpm add / yarn add / bun add。

### @distube/ytpl 支持 TypeScript 吗？

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

### @distube/ytpl 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @distube/ytpl 需要什么版本的 Node\.js？

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

### @distube/ytpl 可以商用吗？

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

### @distube/ytpl 的下载量有多少？

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

### @distube/ytpl 还在维护吗？

最新版本 1\.2\.4 发布于 2025/12/21（10 个月前）；至今共发布 24 个版本，其中过去 12 个月发布了 1 个；首次发布于 2020/11/13。作者已将其标记为弃用，新项目建议寻找替代方案。

