Spotify 已限制免费账号使用 Web API,需自备 Premium 账号创建应用并通过 --app-key 提供 client-id:client-secret;使用 --u/--p 无头登录前必须先执行一次 --l 授权,且需把 127.0.0.1 some-random-host.com 加入 hosts;遇到 429 错误需用 --cof 提供 YouTube cookies 文件,puppeteer 下载 Chromium 失败时可设 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true。

spotify-dl
SwapnilSoni1999MIT活跃维护用 NodeJS 写的 Spotify 歌曲下载器,基于 youtube-dl 抓取音频,可替代 Python 版 spotdl 工具。
Spotify Downloader and alternative of Spotdl(python) tool made in NodeJS based on youtube-dl
npm install -g https://github.com/swapnilsoni1999/spotify-dl
spotifydl <spotify track/album/playlist link>README 未说明显存或 GPU 要求;需要本机安装 FFMPEG 与 Node.js 24,可在 Termux 安卓环境和 Docker 中运行。
用 NodeJS 写的 Spotify 下载器,从 YouTube 抓取音频,可替代 Python 版 spotdl
用 NodeJS 写的 Spotify 歌曲下载器,基于 youtube-dl 抓取音频,可替代 Python 版 spotdl 工具。
核心能力
- 支持下载单曲、专辑、播放列表、播客节目和单集
- 通过 youtube-dl 从 YouTube 匹配并抓取音频
- 可自定义 YouTube 搜索模板与输出文件名模板
- 支持下载已保存的歌曲、专辑、播放列表和节目
- 可开启歌词下载并输出下载失败报告
容易踩的坑
- 1.0.8spotify-dl version: 1.0.8最新正式版2022-05-05 · 2022-05-05 18:47 UTC
- Package updates
- minor fixes by @phyzical
Big chung thanks to @phyzical for keeping it alive
- 1.0.7spotify-dl version: 1.0.72022-01-26 · 2022-01-26 21:01 UTC
查看更新说明
- upgreaded deps
- 1.0.6spotify-dl version: 1.0.62021-11-06 · 2021-11-06 08:34 UTC
查看更新说明
- Deps updates
- Upgrades and fixes by @phyzical
- 1.0.5spotify-dl version: 1.0.52021-09-07 · 2021-09-07 16:05 UTC
查看更新说明
- Converted to module (Huge thanks to contributors)
- Docker improvements by @phyzical
- Major bug fixes by @phyzical
- Code DRY and refactoring by @phyzical
- Many more improvements and dep upgrades (check commits)
- 1.0.2Spotify-dl version: 1.0.22021-06-17 · 2021-06-17 10:51 UTC
查看更新说明
- added logic retry youtube links up to a max of 10 links if there is a failure for whatever reason
- added support for saved albums - requires auth, new flag is --sa
- added support for saved playlists - requires auth, new flag is --sp
- added support for saved tracks - requires auth, new flag is --st
- Added a new flag --oo which will force all downloaded songs into the output dir (-o flag), without the --oo songs will always save a track in - artist/album/song.mp3 irrelevant of what is being downloaded
- Added support for auth of a user to get saved albums, playlists and tracks, If you provide a username and password (--u and --p) we will attempt to autologin, otherwise a browser prompt will be served for users. when non tty an error will be thrown when attempting --sa,sp or st as we cannot serve a browser without user interaction
- There is now basic support for users to overwrite default flags in config.js
- added support for auto removal of sponsors and other irrelevant non music sections within songs
- bunch of DRY throughout the code so we end up with the same song data at the download step
Huge thanks to @phyzical for this update :tada:
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
NOTE: >Your application is blocked from accessing the Web API since you do not have a Spotify Premium subscription. Upgrade to Spotify Premium to access the Web API and unlock additional features for your app.
At this time Spotify have locked down free accounts further to use the spotify side of things until someone with a premium account can create an app to share, you will need to create your own and provide the appKey, with the redirect uri of https://some-random-host.com:7654/callback
NOTE: Atm youtube has also locked things down and still trying to find a flow that is now compatible for downloads
Spotify Downloader
Required
Get FFMPEG
git not windows or git for windows
Note: if you run into issues related to puppeteer chromium download please try PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install -g https://github.com/swapnilsoni1999/spotify-dl
spotifydl
A simple commandline utility that allows you to download Spotify Songs, Shows, Episodes, Playlists and Albums from Youtube.
PLEASE NOTE:
- The ability to find a video is dependent on the fact it is hosted on youtube, and even then there is a chance it is still incorrectly matched
- Some items may only be available to spotify premium users, please be sure to provide a username and password when this is the case
Installation
NPM
npm install -g https://github.com/swapnilsoni1999/spotify-dl
or You can do manually
git clone https://github.com/SwapnilSoni1999/spotify-dl
cd spotify-dl
npm install
npm link
Android (Termux)
PS: You may need to type termux-setup-storage first and allow storage permission
sh -c "$(curl -fsSL https://raw.githubusercontent.com/SwapnilSoni1999/spotify-dl/master/tools/termux.sh)"
Docker
docker run -it --user=$(id -u):$(id -g) -v $(pwd):/download --rm ghcr.io/swapnilsoni1999/spotify-dl <options-to-spotify-dl defaults to --help>
docker run -it --user=$(id -u):$(id -g) -v $(pwd):/download --rm ghcr.io/swapnilsoni1999/spotify-dl "https://open.spotify.com/...."
or Build docker image:
git clone https://github.com/SwapnilSoni1999/spotify-dl
cd spotify-dl
docker build -t spotify-dl .
docker run -it --user=$(id -u):$(id -g) -v $(pwd):/download --rm spotify-dl "https://open.spotify.com/...."
Usage
To download highest quality audio file
spotifydl <spotify track/album/playlist link> ...
Example
spotifydl https://open.spotify.com/track/xyz
Options
| Flag | Long Flag | Usage |
|---|---|---|
| --o | --output | takes valid output path argument |
| --es | --extra-search | takes extra search string/term to be used for youtube search |
| --oo | --output-only | enforces all downloaded songs in the output dir f |
| --sf | --search-format | provide template for youtube api, supports albumName, artistName,itemName |
| "something {itemName} - {albumName} anyrandomextrastring" | ||
| --of | --output-format | provide template for output of filenames, supports albumName, artistName,itemName |
| 3 x _ are used to signify directories | ||
| "something**{artistName}**{albumName}___{itemName}" | ||
| --ef | --exclusion-filters | comma separated string of exclusion filters |
| each filter will be checked against the description and title if found the link will be ignored | ||
| --st | --saved-tracks | download spotify saved tracks |
| --ss | --saved-songs | download spotify saved shows |
| --sp | --saved-playlists | download spotify saved playlists |
| --sa | --saved-albums | download spotify saved albums |
| --l | --login | Requests a login in an external window (non tty should use --u and --p) (Docker without -it is non tty) |
| --ak | --app-key | provide app credentials in format client-id:client-secret |
| --u | --username | spotify username for headless long (Note: you must use --login once to grant access) |
| --p | --password | spotify password |
| --cf | --cache-file | takes valid output file name path argument |
| --dr | --download-report | output a download report of what files failed |
| --cof | --cookie-file | takes valid file name path argument to a txt file for youtube cookies |
| --v | --version | returns current version |
| --h | --help | outputs help text |
| --dl | --download-lyrics | enables downloading of lyrics |
| --oft | --output-file-type | choose which type of file to be output as |
Notes
To use --u and --p (headless login) you must do a --l once first to grant required permissions (playlists, saved songs ect.)
- you now need to add
127.0.0.1 some-random-host.comto/etc/hostsif linux orC:\Windows\System32\Drivers\etc\hostsif windows
if you receive 'Got a spotify api error WebapiRegularError: An error occurred while communicating with Spotify's Web API
Details: non existing id' you may need to provide auth either use --l for manual login prompt or --u username --p password for headless login
If you receive a 429 error please provide a cookies file given the --cof flag, to generate a cookies file please refer to Chrome or Firefox
Acknowledgements
thanks to icons8 for icons in hero image and all the contributors for PR, suggestions and testing :love:
License
MIT © Swapnil Soni