# @distube/spotify 中文文档

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

版本：2\.0\.2
npm 元数据更新时间：2024-06-13T23:37:19.129Z
中文译文更新时间：2026-11-12T12:21:18.941Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：64.7 kB，8 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：4 个
- peer 依赖：distube 5
- 首次发布：2021-04-28T18:30:21.718Z
- 最新版本发布：2024-06-13T23:37:16.969Z
- 近 30 天下载量：3814（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：34（近 12 个月 0 个）

## 中文简介

用于支持 Spotify 的 DisTube 提取器插件 .

## 安装

```sh
npm install @distube/spotify
```

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

## README

[![](https://nodei.co/npm/@distube/spotify.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/@distube/spotify)

[![npm peer dependency version](https://img.shields.io/npm/dependency-version/@distube/spotify/peer/distube?style=flat-square)](https://nodei.co/npm/@distube/spotify) [![npm](https://img.shields.io/npm/dt/@distube/spotify?logo=npm&style=flat-square)](https://nodei.co/npm/@distube/spotify) ![GitHub Repo stars](https://img.shields.io/github/stars/distubejs/extractor-plugins?logo=github&logoColor=white&style=flat-square) [![Discord](https://img.shields.io/discord/732254550689316914?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/feaDd9h)

[![Buy Me a Coffee at ko-fi.com](https://storage.ko-fi.com/cdn/kofi3.png)](https://ko-fi.com/skick)

# @ distube/ spotify (英语)

一个支持Spotify的DisTube信息提取器插件.

[_什么是信息提取器插件?_](https://github.com/skick1234/DisTube/wiki/Projects-Hub#plugins)

## 使用量

```js
const Discord = require("discord.js");
const client = new Discord.Client();

const { DisTube } = require("distube");
const { SpotifyPlugin } = require("@distube/spotify");
const distube = new DisTube(client, {
  plugins: [new SpotifyPlugin()],
});
```

## 文档

### Spotify Plugin (\[Spotify Plugin options\]) (\[ Potify Plugin options\] ) (英语)

-   `SpotifyPluginOptions.api`: (可选) Spotify API证书.
    -   `SpotifyPluginOptions.api.clientId`: 您 Spotify 应用程序的客户端标识( 可选 - 当插件无法自动获得证书时使用)
    -   `SpotifyPluginOptions.api.clientSecret`: 您 Spotify 应用程序的客户端秘密( 选项 - 当插件无法自动获取证书时使用)
    -   `SpotifyPluginOptions.api.topTracksCountry`:顶级艺人音轨的国家代码(ISO 3166-1α-2国家代码). 默认是 `US`。 。 。 .

#### 示例

```js
new SpotifyPlugin({
  api: {
    clientId: "SpotifyAppClientID",
    clientSecret: "SpotifyAppClientSecret",
    topTracksCountry: "VN",
  },
});
```

## 常见问题

### @distube/spotify 是什么？

用于支持 Spotify 的 DisTube 提取器插件 \.

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

在项目目录运行 npm install @distube/spotify，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：distube（5）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

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

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

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

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

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

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

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

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

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

最新版本 2\.0\.2 发布于 2024/06/14（2 年前）；至今共发布 34 个版本，其中过去 12 个月发布了 0 个；首次发布于 2021/04/29。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

