Convert Figma logo to code with AI

hnarayanan logoshpotify

A command-line interface to Spotify.

2,005
153
2,005
45

Top Related Projects

A lightweight yet powerful audio-to-MIDI converter with pitch bend detection

:sound: A Client for the Spotify Web API, written in C#/.NET

Open Source Spotify client library

Spotify for the terminal written in Rust 🚀

A spotify daemon

Quick Overview

Shpotify is a command-line interface for Spotify on macOS, allowing users to control their Spotify client from the terminal. It provides a simple and efficient way to manage playback, search for tracks, and control various Spotify functions without leaving the command line environment.

Pros

  • Lightweight and easy to use
  • Integrates well with other command-line tools and scripts
  • Provides quick access to Spotify functions without GUI interaction
  • Open-source and customizable

Cons

  • Limited to macOS only
  • Requires Spotify desktop client to be installed
  • May require occasional updates to maintain compatibility with Spotify API changes
  • Limited functionality compared to the full Spotify application

Code Examples

As Shpotify is a command-line tool and not a code library, there are no code examples to provide. Instead, here are some example command-line usage scenarios:

# Play a specific track
spotify play track "Bohemian Rhapsody"

# Pause the current playback
spotify pause

# Skip to the next track
spotify next

Getting Started

To get started with Shpotify, follow these steps:

  1. Ensure you have Homebrew installed on your macOS system.
  2. Install Shpotify using Homebrew:
brew install shpotify
  1. Once installed, you can start using Shpotify commands in your terminal. For example:
spotify play
spotify pause
spotify vol up

For a full list of available commands, refer to the project's documentation on GitHub.

Competitor Comparisons

A lightweight yet powerful audio-to-MIDI converter with pitch bend detection

Pros of basic-pitch

  • Developed and maintained by Spotify, likely ensuring high-quality and up-to-date functionality
  • Focuses on audio analysis and pitch detection, offering more advanced music-related features
  • Provides a Python library for easy integration into other projects

Cons of basic-pitch

  • More complex to set up and use, requiring Python knowledge and dependencies
  • Limited to audio analysis tasks, not providing direct Spotify playback control
  • May have a steeper learning curve for users unfamiliar with audio processing

Code Comparison

basic-pitch:

from basic_pitch.inference import predict
from basic_pitch import ICASSP_2022_MODEL_PATH

model_output, midi_data, note_events = predict(audio_path)

shpotify:

spotify play uri spotify:track:3AhXZa8sUQht0UEdBJgpGc
spotify vol up
spotify status

Summary

basic-pitch is a specialized tool for audio analysis and pitch detection, developed by Spotify. It offers advanced features for music-related tasks but requires more technical knowledge to use. shpotify, on the other hand, is a simple command-line interface for controlling Spotify playback on macOS, making it more accessible for general users but with limited functionality compared to basic-pitch's audio analysis capabilities.

:sound: A Client for the Spotify Web API, written in C#/.NET

Pros of SpotifyAPI-NET

  • More comprehensive API coverage, allowing for a wider range of Spotify functionality
  • Better suited for larger, more complex applications due to its robust feature set
  • Actively maintained with regular updates and improvements

Cons of SpotifyAPI-NET

  • Steeper learning curve due to its more extensive API
  • Potentially overkill for simple Spotify integrations or command-line tools
  • Requires more setup and configuration compared to shpotify

Code Comparison

shpotify (Shell):

#!/bin/bash
SPOTIFY_COMMAND="tell application \"Spotify\" to $1"
osascript -e "$SPOTIFY_COMMAND"

SpotifyAPI-NET (C#):

var spotify = new SpotifyClient(config);
var track = await spotify.Tracks.Get("trackId");
await spotify.Player.AddToQueue(new PlayerAddToQueueRequest(track.Uri));

The code snippets demonstrate the difference in complexity and functionality between the two libraries. shpotify uses simple shell commands for basic Spotify control, while SpotifyAPI-NET offers more advanced features and integration with the Spotify Web API.

Open Source Spotify client library

Pros of librespot

  • Full-featured Spotify client library written in Rust
  • Supports audio playback and device control
  • Can be used to build custom Spotify clients or integrate Spotify into other applications

Cons of librespot

  • More complex to set up and use
  • Requires Rust knowledge and compilation
  • May have higher resource usage due to full client implementation

Code comparison

librespot:

let session = Session::connect(config, credentials).await?;
let (player, _) = Player::new(config, session.clone(), None, move || {
    Box::new(audio_backend::find(None).unwrap())
});
player.load(SpotifyId::from_base62("spotify:track:..."), true, 0);
player.play();

shpotify:

osascript -e 'tell application "Spotify" to play track "spotify:track:..."'

Summary

librespot is a comprehensive Spotify client library offering more features and flexibility, but requires more setup and Rust knowledge. shpotify is a simpler shell script for basic Spotify control on macOS, easier to use but with limited functionality. Choose based on your needs and technical expertise.

Spotify for the terminal written in Rust 🚀

Pros of spotify-tui

  • Full-featured terminal user interface with a modern, visually appealing design
  • Cross-platform compatibility (Windows, macOS, Linux)
  • More extensive functionality, including playlist management and search capabilities

Cons of spotify-tui

  • Requires Rust installation and compilation
  • More complex setup process compared to shpotify's simple shell script
  • Larger resource footprint due to its comprehensive feature set

Code Comparison

spotify-tui (Rust):

let spotify = Spotify::default()
    .client_credentials_manager(client_credentials_manager)
    .build();
let tracks = spotify.playlist_tracks(playlist_id, None, None).await?;

shpotify (Shell):

osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_TRACK_URI\""

spotify-tui offers a more robust API interaction, while shpotify relies on AppleScript for macOS-specific control.

A spotify daemon

Pros of Spotifyd

  • Runs as a daemon, providing a lightweight Spotify client
  • Supports multiple output devices and formats
  • Can be controlled remotely via the official Spotify app

Cons of Spotifyd

  • Requires Rust programming environment for compilation
  • More complex setup process compared to shpotify
  • Limited to Spotify Premium accounts

Code Comparison

Spotifyd (Rust):

let (player, _) = Player::new(
    Box::new(audio_backend),
    Box::new(mixer),
    Box::new(cache),
    config.clone(),
    credentials,
    handle.clone(),
    player_event_channel,
    api_key_manager,
)?;

shpotify (Shell):

osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_TRACK_URI\""

Summary

Spotifyd is a more feature-rich Spotify client that runs as a daemon, offering better integration with the Spotify ecosystem. However, it has a steeper learning curve and is limited to Premium accounts. shpotify, on the other hand, is a simpler shell script that provides basic control over the Spotify desktop application, making it easier to use but with fewer features.

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

shpotify

shpotify is a simple Bash/Apple script to control Spotify from the command line on a Mac.

If you find this interesting, you should follow me on Twitter to learn about the other things I do.

Installation

Download and install the Spotify desktop application if you haven’t already.

With Homebrew

The easiest way to install shpotify is by using the Homebrew package manager:

brew install shpotify

Manual installation

If you don’t use Homebrew, you can install the script manually by following a few simple steps:

  1. Fetch a copy of this repository, either with git or download the zip archive.

  2. Navigate to the folder where you fetched the repository (unzip if needed) and make sure the file called spotify is executable:

    cd shpotify
    chmod +x spotify
    
  3. Copy the file spotify to a convenient location in your PATH, or set your PATH to include the folder where the file is located.

Connecting to Spotify’s API

shpotify needs to connect to Spotify’s API in order to find music by name. It is very likely you want this feature!

To get this to work, you first need to sign up (or into) Spotify’s developer site and create an Application. Once you’ve done so, you can find its Client ID and Client Secret values and enter them into your shpotify config file at ${HOME}/.shpotify.cfg.

Be sure to quote your values and don’t add any extra spaces. When done, it should look like the following (but with your own values):

CLIENT_ID="abc01de2fghijk345lmnop"
CLIENT_SECRET="qr6stu789vwxyz"

Usage

With shpotify you can control Spotify with the following commands:

spotify play                       Resumes playback where Spotify last left off.
spotify play <song name>           Finds a song by name and plays it.
spotify play album <album name>    Finds an album by name and plays it.
spotify play artist <artist name>  Finds an artist by name and plays it.
spotify play list <playlist name>  Finds a playlist by name and plays it.
spotify play uri <uri>             Play songs from specific uri.

spotify next                       Skips to the next song in a playlist.
spotify prev                       Returns to the previous song in a playlist.
spotify replay                     Replays the current track from the beginning.
spotify pos <time>                 Jump to a specific time (in seconds) in the current song.
spotify pause                      Pauses (or resumes) Spotify playback.
spotify stop                       Stops playback.
spotify quit                       Stops playback and quits Spotify.

spotify vol up                     Increases the volume by 10%.
spotify vol down                   Decreases the volume by 10%.
spotify vol <amount>               Sets the volume to an amount between 0 and 100.
spotify vol [show]                 Shows the current volume.

spotify status                     Shows the play status, including the current song details.
spotify status artist              Shows the currently playing artist.
spotify status album               Shows the currently playing album.
spotify status track               Shows the currently playing track.

spotify share                      Displays the current song's Spotify URL and URI.
spotify share url                  Displays the current song's Spotify URL and copies it to the clipboard.
spotify share uri                  Displays the current song's Spotify URI and copies it to the clipboard.

spotify toggle shuffle             Toggles shuffle playback mode.
spotify toggle repeat              Toggles repeat playback mode.

Authors and contributing

shpotify is primarily written and maintained by Harish Narayanan.

Since it’s an open source project, it contains numerous contributions from many helpful people, including:

  • Jorge Colindres
  • Thomas Pritchard
  • iLan Epstein
  • Gabriele Bonetti
  • Sean Heller
  • Eric Martin
  • Peter Fonseca

If you’re interested in contributing too, please consider addressing some of the issues people have previously reported and submitting a pull request. Thank you!

Copyright and license

Copyright (c) 2012–2024 Harish Narayanan.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.