spotify-player

aome510MIT活跃维护

用 Rust 写的终端 Spotify 播放器,支持播放控制、搜索、媒体库管理等完整功能,适合习惯命令行和 Vim 键位的用户。

A Spotify player in the terminal with full feature parity

v0.25.2发布于 2026-11-05 14:33 UTC7,312star +6 / 7 天402fork同步于 2026-11-10 17:33 UTC

怎么上手

由 README 提炼,执行前请确认
cargo install spotify_player --locked
硬件要求按 README 说明

README 未说明显存或 GPU 要求;需 Spotify Premium 账号。Linux 需安装 openssl、alsa-lib(streaming 特性)、libdbus(media-control 特性)。

支持 Apple Silicon有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

终端里的 Spotify 播放器,支持完整功能与流媒体播放

用 Rust 写的终端 Spotify 播放器,支持播放控制、搜索、媒体库管理等完整功能,适合习惯命令行和 Vim 键位的用户。

核心能力

  • 与官方 Spotify 应用功能对等
  • 支持 Spotify Connect 远程控制
  • 支持终端内直接流媒体播放歌曲
  • 支持同步歌词、图片渲染与桌面通知
  • 提供丰富 CLI 命令并可后台守护进程运行

容易踩的坑

必须使用 Spotify Premium 账号;首次启动默认会打开两次授权页面(Web API token 与 librespot 会话各一次);默认共用 ncspot 的 client ID,配额易被耗尽,建议注册自己的 client ID;Docker 镜像中流媒体功能被禁用

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.25.2
  1. v0.25.2最新正式版2026-11-05 · 2026-11-05 14:33 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/aome510/spotify-player/compare/v0.25.1...v0.25.2

  2. v0.25.12026-09-09 · 2026-09-09 01:52 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/aome510/spotify-player/compare/v0.25.0...v0.25.1

  3. v0.25.02026-09-07 · 2026-09-07 22:56 UTC
    查看更新说明

    Highlights

    v0.25.0 focuses on more reliable Spotify Web API access. Custom client IDs are now supported with automatic fallback to the bundled ncspot client when Spotify rejects restricted requests, alongside improved rate-limit handling.

    Breaking change: https://github.com/aome510/spotify-player/pull/1077 updated how cache token for Web API is stored so users will be prompted for re-authentication when running the new release. Because of the recent rate-limit issue, it's recommended for users to setup a custom client ID to avoid rate-limit issues with the default shared ncspot client

    What's Changed

    New Contributors

    Full Changelog: https://github.com/aome510/spotify-player/compare/v0.24.1...v0.25.0

  4. v0.24.12026-07-20 · 2026-07-20 15:00 UTC
    查看更新说明

    This release includes a patch to fix an issue resulted from a new policy change from Spotify - https://developer.spotify.com/blog/2026-06-18-refresh-token-expiration. As a result, users will be asked to re-authenticate when they launch the app with the release (to update the corrupted cached token stored in user_client_token.json)

    What's Changed

    Full Changelog: https://github.com/aome510/spotify-player/compare/v0.24.0...v0.24.1

  5. v0.24.02026-06-30 · 2026-06-30 23:46 UTC
    查看更新说明

    Highlights

    The main theme of this release is improving robustness and reliability. Several long-standing pain points around image rendering, authentication, and app stopped working after running for a while have been reworked:

    • More reliable album art — migrated from viuer to ratatui-image (#969).
    • Hardened authentication — a more robust OAuth flow, an enforced Web API client, and improved docs make logging in far less fragile (#1013).
    • Smarter reconnection — reworked auto-reconnect logic so the app recovers more gracefully from dropped connections (#1016).

    What's Changed

    New Contributors

    Special thanks to @sakashimaa who contributed many PRs in this release

    Full Changelog: https://github.com/aome510/spotify-player/compare/v0.23.0...v0.24.0

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    spotify_player

    Table of Contents

    Introduction

    spotify_player is a fast, easy to use, and configurable terminal music player.

    Features

    Examples

    A demo of spotify_player v0.5.0-pre-release on youtube or on asciicast:

    Checkout examples/README.md for more examples.

    Installation

    By default, the application's installed binary is spotify_player.

    Requirements

    A Spotify Premium account is required.

    Dependencies
    Windows and MacOS
    Linux
    • Rust and cargo as the build dependencies
    • install openssl, alsa-lib (streaming feature), libdbus (media-control feature).
      • For example, on Debian based systems, run the below command to install application's dependencies:

        sudo apt install libssl-dev libasound2-dev libdbus-1-dev
        
      • On RHEL/Fedora based systems, run the below command to install application's dependencies :

        sudo dnf install openssl-devel alsa-lib-devel dbus-devel
        

        or if you're using yum:

        sudo yum install openssl-devel alsa-lib-devel dbus-devel
        
    Termux (Android)
    • Two default components require a JVM context that Termux processes don't have: the default TLS backend (rustls-platform-verifier, panics during the auth token exchange) and the rodio audio backend (cpal's AAudio host, panics when streaming starts). Build with the native-tls feature and the pulseaudio backend instead:

      pkg install rust openssl pulseaudio
      cargo install spotify_player --no-default-features --features pulseaudio-backend,media-control,native-tls
      

      This makes authentication, the Web API, and remote device control work. Integrated streaming additionally requires patching librespot's compile-time OS identity (librespot-core's config::OS) to "linux" via [patch.crates-io], because librespot built for target_os = "android" presents the Android-app identity, which Spotify rejects for keymaster-minted credentials.

    Binaries

    Application's prebuilt binaries can be found in the Releases Page.

    Note: to run the application, Linux systems need to install additional dependencies as specified in the Dependencies section.

    Homebrew

    Run brew install spotify_player to install the application.

    Scoop

    Run scoop install spotify-player to install the application.

    Cargo

    Install via Cargo:

    cargo install spotify_player --locked
    

    Arch Linux

    Install via Arch Linux:

    pacman -S spotify-player
    

    Note: Defaults to PulseAudio/Pipewire. For a different backend, modify the official PKGBUILD and rebuild manually. See Audio Backends.

    Void Linux

    Install via Void Linux:

    xbps-install -S spotify-player
    

    FreeBSD

    Install via FreeBSD:

    pkg install spotify-player
    

    NetBSD

    Install via NetBSD:

    pkgin install spotify-player
    

    Build from source on NetBSD:

    cd /usr/pkgsrc/audio/spotify-player
    make install
    

    NixOS

    spotify-player is available as a Nix package. Install via:

    nix-shell -p spotify-player
    

    To build from source locally, run nix-shell in the root of the source checkout. The provided shell.nix will install prerequisites.

    Docker

    Note: The streaming feature is disabled in the Docker image.

    Download the latest Docker image:

    docker pull aome510/spotify_player:latest
    

    Run the Docker container:

    docker run --rm -it aome510/spotify_player:latest
    

    To use your local config and cache folders:

    docker run --rm \
    -v $APP_CONFIG_FOLDER:/app/config/ \
    -v $APP_CACHE_FOLDER:/app/cache/ \
    -it aome510/spotify_player:latest
    

    Authentication

    spotify_player requires a Spotify Premium account and authenticates against the Spotify Web API using the OAuth 2.0 authorization code flow with PKCE. No client secret is stored or required.

    The simplest way to authenticate is to just run the application — on first use it prompts for whichever credentials are not yet cached. Each prompt opens the Spotify authorization page in your browser; after you approve access, Spotify redirects to a local loopback address (login_redirect_uri, default http://127.0.0.1:8989/login) where spotify_player captures the authorization code and exchanges it for an access token. Credentials are cached in the application's cache folder, so this is a one-time step per machine.

    Alternatively, run the spotify_player authenticate CLI command to authenticate all required credentials up front — useful for setting things up ahead of a daemon or headless launch. Unlike a normal launch, authenticate always forces fresh interactive logins, ignoring cached credentials, so it can also be used to re-authenticate from scratch.

    How authentication works

    Two kinds of credentials are involved:

    • One or two Web API tokens, used for REST calls (playback control, library, search, playlists, etc.). The default setup uses ncspot's client ID. When a custom client_id is configured, its token is used first and a separate ncspot token provides fallback access.
    • A librespot session, used for the streaming feature (direct playback and Spotify Connect device registration).

    They authenticate through your Spotify account; the client ID presented to Spotify differs between credentials (see below).

    Why you may be asked to authenticate multiple times

    With the streaming feature enabled (the default), the first launch normally opens the Spotify authorization page twice, in this order:

    1. The Web API token, presented under the configured client_id (ncspot's by default). This is cached as <client_id>_token.json.
    2. The librespot session credentials, presented under Spotify's official client ID. These are cached as credentials.json.

    These are two independent OAuth flows with two different client IDs, so Spotify requires a separate approval for each, and each credential is cached separately in the cache folder. This is a one-time step per machine — subsequent launches reuse and silently refresh them unless a cache is cleared or a credential is revoked.

    When a custom client_id is configured, an ncspot fallback Web API token is also requested and cached as <ncspot_client_id>_token.json. Its OAuth callback always uses http://127.0.0.1:8989/login; login_redirect_uri applies only to the custom client. A custom setup with streaming enabled can therefore require three approvals on first launch. Web API token cache filenames include their client IDs, so changing client_id requires a new approval instead of reusing a token issued to another client.

    A fallback ncspot client is integrated since the custom client might not be registered with extended quota mode and could therefore doesn't have access to certain endpoints.

    The spotify_player authenticate command runs every required flow in one go, forcing a fresh login for each. Without streaming, the librespot flow is omitted, leaving one Web API approval for the default setup or two for a custom-client setup.

    Client ID and rate limits

    Every request to the Spotify Web API is attributed to a Spotify application, identified by a client ID. The client ID — not your account — determines the API quota you are subject to.

    By default, spotify_player uses ncspot's client ID. This client ID is shared by many users, so its API quota can be exhausted by aggregate usage and cause 429 Too Many Requests responses. Registering and configuring your own client ID is strongly recommended so routine requests use a quota dedicated to your Spotify application.

    The ncspot client ID remains available as a fallback because it is registered in extended quota mode and predates Spotify's November 2024 Web API changes. It can access endpoints (browse, personalized content, generated playlists, …) that newly-registered applications can no longer use.

    When a custom client_id is configured, spotify-player sends most Web API requests through that client first. If Spotify rejects custom-client request with any 4xx response, the request is attempted once through ncspot. Successful requests and failures outside the 4xx range do not trigger fallback.

    The custom client uses no request middleware. The ncspot client stores Retry-After durations and retries rate-limited GET requests up to two times by default; mutation requests are never delayed or retried by the middleware. Configure the ncspot retry count with api_rate_limit_retries; see the configuration documentation for details.

    Using a custom client ID

    Use a custom client ID to avoid competing for the shared ncspot client's rate limit. Most requests will be attributed to your own Spotify application instead. Newly registered applications use restricted default quota mode, so endpoints unavailable to the custom client transparently fall back to ncspot.

    To configure one, register an application on the Spotify developer dashboard, add your login_redirect_uri (default http://127.0.0.1:8989/login) to the app's allowed redirect URIs, then set client_id (or client_id_command) in app.toml. See the Client id command section of the configuration docs for details.

    After changing the client ID, re-run spotify_player authenticate to refresh the custom and fallback tokens.

    Features

    Spotify Connect

    Control Spotify remotely with Spotify Connect. Press D to list devices, then enter to connect.

    Streaming

    Stream music directly from the terminal. The streaming feature is enabled by default and uses the rodio-backend audio backend unless otherwise specified.

    The app uses librespot to create an integrated Spotify client, registering a spotify-player device accessible via Spotify Connect.

    Audio backend

    Default audio backend is rodio. Available backends:

    • alsa-backend
    • pulseaudio-backend
    • rodio-backend
    • portaudio-backend
    • jackaudio-backend
    • rodiojack-backend
    • sdl-backend
    • gstreamer-backend

    To use a different audio backend, specify the --features option when building. For example:

    cargo install spotify_player --no-default-features --features pulseaudio-backend
    

    Notes:

    • Use --no-default-features to disable the default rodio-backend.
    • Additional dependencies may be required for some backends. See Librespot documentation.

    To disable streaming, build with:

    cargo install spotify_player --no-default-features
    

    Audio Visualization

    Real-time audio visualization is displayed in the playback window as a frequency-band bar chart (64 log-scale bands from bass (left) to treble (right)) while music is streamed locally via the integrated librespot player. The visualization area is hidden when playback is on an external Spotify Connect device or when the playback is not playing.

    Set enable_audio_visualization to true in your config to enable this feature. The bars are colored by amplitude using the active theme's visualization component style (low/mid/high colors); see config docs.

    Audio Visualization

    Media Control

    Media control is enabled by default. Set enable_media_control to true in your config to use it. See config docs.

    Media control uses MPRIS DBus on Linux and OS window events on Windows and macOS.

    Image

    To enable image rendering, build with the image feature (disabled by default):

    cargo install spotify_player --features image
    

    Image rendering is powered by ratatui-image, which auto-detects the terminal's graphics protocol (Kitty, iTerm2, Sixel) on startup. Terminals without any graphics protocol support fall back to block characters.

    Notes:

    • Protocol detection queries the terminal via stdio. In nested terminals (e.g. Neovim's floating terminal), the query does not reach the outer terminal emulator, so the protocol falls back to block characters.

    Image rendering examples:

    • iTerm2:

    iTerm2

    • Kitty:

    kitty

    • Sixel (foot terminal):

    sixel

    • Others:

    others

    Pixelate

    For a pixelated look, enable the pixelate feature (also enables image):

    cargo install spotify_player --features pixelate
    

    Adjust the pixelation with the cover_img_pixels config option.

    cover_img_pixels8163264
    example

    To temporarily disable pixelation, set cover_img_pixels to a high value (e.g., 512).

    Notify

    To enable desktop notifications, build with the notify feature (disabled by default):

    cargo install spotify_player --features notify
    

    Note: Notification support is limited on macOS and Windows compared to Linux.

    Mouse support

    Mouse support: You can seek to a position in the playback by left-clicking the progress bar.

    Daemon

    To enable daemon mode, build with the daemon feature (disabled by default):

    cargo install spotify_player --features daemon
    

    Run as a daemon with -d or --daemon: spotify_player -d.

    Notes:

    • Daemon mode is not supported on Windows.

    • Daemon mode requires streaming and an audio backend.

    • On macOS, daemon mode does not work with media control (enabled by default). To use daemon mode on macOS, disable media control:

      cargo install spotify_player --no-default-features --features daemon,rodio-backend
      

    Fuzzy search

    To enable fuzzy search, build with the fzf feature (disabled by default).

    CLI Commands

    spotify_player provides several CLI commands for interacting with Spotify:

    • get: Get Spotify data (playlist/album/artist data, user's data, etc)
    • playback: Interact with the playback (start a playback, play-pause, next, etc)
    • search: Search spotify
    • connect: Connect to a Spotify device
    • like: Like currently playing track
    • authenticate: Authenticate the application
    • playlist: Playlist editing (new, delete, import, fork, etc)

    For more details, run spotify_player -h or spotify_player {command} -h.

    Notes

    • On first use, run spotify_player authenticate to authenticate the app.
    • CLI commands communicate with a client socket on port client_port (default: 8080). If no instance is running, a new client is started, which may increase latency.
    Scripting

    The command-line interface is script-friendly. Use the search subcommand to retrieve Spotify data in JSON format, which can be processed with tools like jq.

    Example: Start playback for the first track from a search query:

    read -p "Search spotify: " query
    spotify_player playback start track --id $(spotify_player search "$query" | jq '.tracks.[0].id' | xargs)
    

    Commands

    Press ? or C-h to open the shortcut help page (default for OpenCommandHelp).

    Tips:

    • Use the Search command to search in the shortcut help page and other pages.
    • RefreshPlayback manually updates playback status.
    • RestartIntegratedClient is useful for switching audio devices without restarting the app.

    List of supported commands:

    CommandDescriptionDefault shortcuts
    NextTracknext trackn
    PreviousTrackprevious trackp
    ResumePauseresume/pause based on the current playbackspace
    PlayRandomplay a random track in the current context.
    Repeatcycle the repeat modeC-r
    Shuffletoggle the shuffle modeC-s
    VolumeChangechange playback volume by an offset (default shortcuts use 5%)+, -
    Mutetoggle playback volume between 0% and previous level_
    SeekStartseek start of current track^
    SeekForwardseek forward by a duration in seconds (defaults to seek_duration_secs, supports vim-style count)>
    SeekBackwardseek backward by a duration in seconds (defaults to seek_duration_secs, supports vim-style count)<
    Quitquit the applicationC-c, q
    ClosePopupclose a popupesc
    SelectNextOrScrollDownselect the next item in a list/table or scroll down (supports vim-style count: 5j)j, C-n, down
    SelectPreviousOrScrollUpselect the previous item in a list/table or scroll up (supports vim-style count: 10k)k, C-p, up
    PageSelectNextOrScrollDownselect the next page item in a list/table or scroll a page down (supports vim-style count: 3C-f)page_down, C-f
    PageSelectPreviousOrScrollUpselect the previous page item in a list/table or scroll a page up (supports vim-style count: 2C-b)page_up, C-b
    SelectFirstOrScrollToTopselect the first item in a list/table or scroll to the topg g, home
    SelectLastOrScrollToBottomselect the last item in a list/table or scroll to the bottomG, end
    ChooseSelectedchoose the selected itementer
    RefreshPlaybackmanually refresh the current playbackr
    RestartIntegratedClientrestart the integrated client (streaming feature only)R
    ShowActionsOnSelectedItemopen a popup showing actions on a selected itemg a, C-space
    ShowActionsOnCurrentTrackopen a popup showing actions on the current tracka
    ShowActionsOnCurrentContextopen a popup showing actions on the current contextA
    AddSelectedItemToQueueadd the selected item to queueZ, C-z
    FocusNextWindowfocus the next focusable window (if any)tab
    FocusPreviousWindowfocus the previous focusable window (if any)backtab
    SwitchThemeopen a popup for switching themeT
    SwitchDeviceopen a popup for switching deviceD
    Searchopen a popup for searching in the current page/
    BrowseUserPlaylistsopen a popup for browsing user's playlistsu p
    BrowseUserFollowedArtistsopen a popup for browsing user's followed artistsu a
    BrowseUserSavedAlbumsopen a popup for browsing user's saved albumsu A
    CurrentlyPlayingContextPagego to the currently playing context pageg space
    TopTrackPagego to the user top track pageg t
    RecentlyPlayedTrackPagego to the user recently played track pageg r
    LikedTrackPagego to the user liked track pageg y
    LyricsPagego to the lyrics page of the current trackg L, l
    LibraryPagego to the user library pageg l
    SearchPagego to the search pageg s
    BrowsePagego to the browse pageg b
    Queuego to the queue pagez
    OpenCommandHelpgo to the command help page?, C-h
    PreviousPagego to the previous pagebackspace, C-q
    OpenLogsgo the the application logs pageg o
    OpenSpotifyLinkFromClipboardopen a Spotify link from clipboardO
    SortTrackByTitlesort the track table (if any) by track's titles t
    SortTrackByArtistssort the track table (if any) by track's artistss a
    SortTrackByAlbumsort the track table (if any) by track's albums A
    SortTrackByAddedDatesort the track table (if any) by track's added dates D
    SortTrackByDurationsort the track table (if any) by track's durations d
    SortLibraryAlphabeticallysort the library alphabeticallys l a
    SortLibraryByRecentsort the library (playlists and albums) by recently added itemss l r
    ReverseOrderreverse the order of the track table (if any)s r
    MovePlaylistItemUpmove playlist item up one positionC-k
    MovePlaylistItemDownmove playlist item down one positionC-j
    CreatePlaylistcreate a new playlistN
    JumpToCurrentTrackInContextjump to the current track in the contextg c
    JumpToHighlightTrackInContextjump to the currently highlighted search result in the contextC-g

    To add or modify shortcuts, see the keymaps section.

    Actions

    Not all actions are available for every Spotify item. To see available actions, use ShowActionsOnCurrentTrack or ShowActionsOnSelectedItem, then press enter to trigger the action. Some actions may not appear in the popup but can be bound to shortcuts.

    List of available actions:

    • GoToArtist
    • GoToAlbum
    • GoToRadio
    • AddToLibrary
    • AddToPlaylist
    • AddToQueue
    • AddToLiked
    • DeleteFromLiked
    • DeleteFromLibrary
    • DeleteFromPlaylist
    • ShowActionsOnAlbum
    • ShowActionsOnArtist
    • ShowActionsOnShow
    • ToggleLiked
    • CopyLink
    • Follow
    • Unfollow

    Actions can also be bound to shortcuts. To add new shortcuts, see the actions section.

    Search Page

    When entering the search page, focus is on the search input. Enter text, use backspace to delete, and enter to search.

    To move focus from the search input to other windows (track results, album results, etc.), use FocusNextWindow or FocusPreviousWindow.

    Configurations

    By default, configuration files are located in $HOME/.config/spotify-player. Change this with -c <FOLDER_PATH> or --config-folder <FOLDER_PATH>.

    If no configuration file is found, one will be created with default values.

    See configuration documentation for details on available options.

    Caches

    By default, cache files are stored in $HOME/.cache/spotify-player (logs, credentials, audio cache, etc.). Change this with -C <FOLDER_PATH> or --cache-folder <FOLDER_PATH>.

    Logging

    Logs are stored in $APP_CACHE_FOLDER/spotify-player-*.log. For debugging or issues, check the backtrace file in $APP_CACHE_FOLDER/spotify-player-*.backtrace.

    Set the RUST_LOG environment variable to control logging level. Default is spotify_player=INFO.

    Acknowledgement

    spotify_player is written in Rust and built on top of libraries like ratatui, rspotify, librespot, and more. It is inspired by spotify-tui and ncspot.