Skip to main content

control the spotify app with a cli or with a package

Project description

Spotzero

spotzero is a command line interface as well as a package to control Spotify on linux

Installing

spotzero uses dbus-python, and this package requires a some packages. I can't be bothered to find every package for every distribution, so just try to pip install dbus-python as see what package says its missing.

From pipy

[!warn] This isn't done yet

pip install spotzero

From source

If you want to install from source you'll need some packages beacuse dbus-python requires it. There are 2 methods from source:

  1. Using the --editable flatg
  2. Building it with python -m build and then installing it pip install dist/spotzero-<latest_version>-py3-none-any.whl

1. Installing dependencies for Distros

Every distro

For some reason meson sometimes installs a previous version.

pip install meson --upgrade

Ubuntu

apt install pip, git, meson, pkg-config, libdbus-1-dev, libglib2.0-dev

add sudo as needed here.

2. Cloning the repo

git clone https://github.com/masakk1/spotzero.git
cd spotzero

3.A Installing for regular use (RECOMMENDED)

Install this way if you're only interested in using the program and not editing the source code.

pip install build # Make sure build is installed
python -m build . # Compile
pip install dist/spotzero-<LATEST_VERSION>-py3-none-any.whl

3.B Installing to edit the source code

Only do this if you want to contribute or edit the source code. Once you move the foler, spotzero will not work anymore. The reason why I use --editable is because in many distros pip install . doesn't work.

# You should probably make a venv first.
python -m venv . # or make a venv with your IDE of choice (RECOMMENDED).
                 # you might need to install python3.10-venv whatever your distro
                 # complains with
pip install --editable .

Usage

From the terminal - CLI

spotzero # This will show the possible commands

# Lets play a song
spotzero play_uri "spotify:track:6vWZUOcDySwffRBcxlIFNr"

# I'm tired of it, pause it
spotzero toggle-play

That's it. It will show all the possible commands

As a pyton library

import spotzero.cli as spotzero

spotzero.pause()
spotzero.play_uri("spotify:track:4iV5W9uYEdYUVa79Axb7Rh")

Or you could also import the spotzero.linux module - in case there happens to be a function not available in the CLI in the future.

Contributing

If you want more of this, make sure to open a pull request with your changes! - I did this project in 3 days so it's pretty easy

Want to add more functions?

This project relies on dbus-python, dbus_handler.py is the one in charge of interacting with the dbus shenanigans. If you want to use another method: check out https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html - you can also change properties - dbus_handler is somewhat documented so check that too.

Want to add another platform?

There is a linux.py module right now. You could try adding a windows.py module but I don't have a proper way to change it. Shouldn't be too hard, look at the original project I forked from.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spotzero-0.1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spotzero-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file spotzero-0.1.1.tar.gz.

File metadata

  • Download URL: spotzero-0.1.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for spotzero-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0db54cff6da5ec22dd7e6eb2f919841df84ac699189cb65a27161cbc200a1445
MD5 a506dfaf044eb7aab71cb25846d0b354
BLAKE2b-256 3233568b4371fa46c5f4dbc5ca96cc62a9c47d2a94a4d08b23bab111cf1c736b

See more details on using hashes here.

File details

Details for the file spotzero-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: spotzero-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for spotzero-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 674f7badac7a5674d82ecfdd1a7ca234aad8cfa932626ca952ebe7491061e2e9
MD5 bb9a023ceeaa0cf3e4caeed28fb898d3
BLAKE2b-256 c217d8222fc13eb2c79eb7f1aa7ecba2e0ab688bc136bd644a1594ef40394d65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page