Convert Figma logo to code with AI

Spotifyd logospotifyd

A spotify daemon

9,785
447
9,785
88

Top Related Projects

Open Source Spotify client library

Spotify for the terminal written in Rust 🚀

4,927

Cross-platform ncurses Spotify client written in Rust, inspired by ncmpc and the likes.

Adblocker for Spotify

Quick Overview

Spotifyd is an open-source Spotify client running as a UNIX daemon. It implements the Spotify Connect protocol, allowing you to control music playback on your device using the official Spotify apps on other devices. This lightweight alternative to the official Spotify client is particularly useful for headless systems or devices with limited resources.

Pros

  • Lightweight and resource-efficient compared to the official Spotify client
  • Runs as a daemon, making it ideal for headless systems or servers
  • Supports various audio backends (ALSA, PulseAudio, PortAudio)
  • Can be controlled remotely using Spotify Connect from other devices

Cons

  • Requires a Spotify Premium account to function
  • Limited functionality compared to the official Spotify client (e.g., no UI, no offline mode)
  • May require manual compilation on some systems
  • Occasional stability issues reported by some users

Getting Started

To get started with Spotifyd, follow these steps:

  1. Install Rust and Cargo (Spotifyd's build system)
  2. Clone the repository:
    git clone https://github.com/Spotifyd/spotifyd.git
    cd spotifyd
    
  3. Build Spotifyd:
    cargo build --release
    
  4. Create a configuration file ~/.config/spotifyd/spotifyd.conf:
    [global]
    username = "your_spotify_username"
    password = "your_spotify_password"
    backend = "alsa"
    device_name = "spotifyd"
    bitrate = 320
    
  5. Run Spotifyd:
    ./target/release/spotifyd --no-daemon
    

Now you can control Spotifyd using the Spotify app on another device by selecting the device name you specified in the configuration file.

Competitor Comparisons

Open Source Spotify client library

Pros of librespot

  • Written in Rust, offering better performance and memory safety
  • More actively maintained with frequent updates
  • Supports a wider range of Spotify features, including Connect API

Cons of librespot

  • More complex to set up and configure
  • Larger resource footprint, potentially less suitable for low-power devices
  • Less focus on being a standalone daemon, often used as a library

Code Comparison

spotifyd:

let (mut spotify, credentials) = get_spotify_object(args.clone()).await?;
let (player_event_channel, player_event_sender) = channel::<PlayerEvent>();
let player_event_program = args.onevent.as_ref().map(|path| path.to_owned());

librespot:

let session = Session::connect(config, credentials, cache, handle).await?;
let (player, mut player_events) = Player::new(config, session, audio_setup, move |_| {});
tokio::spawn(async move {
    while let Some(event) = player_events.next().await {
        // Handle player events
    }
});

Both projects use Rust and implement Spotify playback, but librespot offers more flexibility as a library, while spotifyd is designed as a standalone daemon. librespot's codebase is generally more extensive, reflecting its broader feature set and active development.

Spotify for the terminal written in Rust 🚀

Pros of spotify-tui

  • Provides a feature-rich, interactive terminal user interface for Spotify
  • Offers extensive playback control and playlist management capabilities
  • Supports searching and browsing Spotify's library directly from the terminal

Cons of spotify-tui

  • Requires a separate Spotify client (like Spotifyd) to handle audio playback
  • May have a steeper learning curve due to its more complex interface
  • Depends on the Spotify Web API, which may have rate limits and require authentication

Code Comparison

spotify-tui (Rust):

pub fn run() -> Result<()> {
    let mut app = App::new()?;
    let mut terminal = Terminal::new(CrosstermBackend::new(io::stdout()))?;
    terminal.clear()?;
    loop {
        terminal.draw(|f| ui::draw(f, &mut app))?;
        if let Event::Key(key) = event::read()? {
            if !app.handle_key(key) {
                break;
            }
        }
    }
    Ok(())
}

Spotifyd (Rust):

fn main() {
    let config = Config::load_or_default();
    let (ctrl_c_tx, ctrl_c_rx) = mpsc::channel();
    let (shutdown_tx, shutdown_rx) = mpsc::channel();
    ctrlc::set_handler(move || {
        ctrl_c_tx.send(()).unwrap();
    }).expect("Error setting Ctrl-C handler");
    run(config, shutdown_rx);
}

Both projects are written in Rust, but spotify-tui focuses on providing a user interface, while Spotifyd handles the core functionality of playing audio and interacting with the Spotify service.

4,927

Cross-platform ncurses Spotify client written in Rust, inspired by ncmpc and the likes.

Pros of ncspot

  • Full-featured TUI client with playlist management and search functionality
  • Written in Rust, offering better performance and memory safety
  • Supports offline mode and local cache for faster playback

Cons of ncspot

  • Requires more system resources due to its full-featured nature
  • May have a steeper learning curve for users unfamiliar with TUI interfaces
  • Limited to terminal environments, lacking GUI support

Code Comparison

ncspot (Rust):

pub fn play(&mut self, track_id: &str) -> Result<(), Box<dyn Error>> {
    self.player.load(track_id, true, 0)?;
    self.player.play()?;
    Ok(())
}

spotifyd (Rust):

pub fn play(&mut self) -> Result<()> {
    self.player.play()?;
    self.update_state(PlaybackState::Playing);
    Ok(())
}

Key Differences

  • ncspot is a full Spotify client with a rich TUI interface, while spotifyd is a lightweight daemon that acts as a Spotify Connect target
  • ncspot offers more features and control within the application, whereas spotifyd relies on external Spotify clients for control
  • spotifyd is designed to run in the background, while ncspot is an interactive application meant for active use
  • ncspot provides a more comprehensive Spotify experience, but spotifyd is more resource-efficient and better suited for headless setups

Adblocker for Spotify

Pros of spotify-adblock

  • Focuses specifically on blocking ads in the Spotify desktop application
  • Lightweight solution that doesn't require running a separate daemon
  • Can be used alongside the official Spotify client

Cons of spotify-adblock

  • Limited to ad-blocking functionality only
  • Requires manual installation and potential recompilation for updates
  • May break with Spotify client updates, requiring frequent maintenance

Code Comparison

spotify-adblock:

static const char *whitelist[] = {
    "https://spclient.wg.spotify.com/color-lyrics/v2/track/",
    "https://api-partner.spotify.com/pathfinder/v1/query",
    "https://spclient.wg.spotify.com/metadata/4/track/",
    "https://spclient.wg.spotify.com/audio/",
};

spotifyd:

pub struct SpotifyId(pub [u8; 16]);

impl SpotifyId {
    pub fn from_raw(raw: &[u8]) -> SpotifyId {
        SpotifyId(raw.try_into().unwrap())
    }
}

The spotify-adblock code shows a whitelist of URLs allowed to pass through the ad-blocking filter, while the spotifyd code demonstrates the implementation of a Spotify ID structure. This highlights the different focus areas of the two projects: ad-blocking versus full client functionality.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Spotifyd

Matrix GitHub Workflow Status Github Actions - CI

An open source Spotify client running as a UNIX daemon.

Project Website

Spotifyd streams music just like the official client, but is more lightweight and supports more platforms. Spotifyd also supports the Spotify Connect protocol, which makes it show up as a device that can be controlled from the official clients.

Note: Spotifyd requires a Spotify Premium account.

To read about how to install and configure Spotifyd, take a look at our wiki!

Common issues

  • Spotifyd will not work without Spotify Premium
  • The device name cannot contain spaces

Contributing

We always appreciate help during the development of spotifyd! If you are new to programming, open source or Rust in general, take a look at issues tagged with good first issue. These normally are easy to resolve and don't take much time to implement.

Credits

This project would not have been possible without the amazing reverse engineering work done in librespot, mostly by plietar.