Skip to main content

Python wrapper to control your Spotify client on MacOS

Project description

WASP

Wrapper around AppleScript of Spotify in Python.

This library provides a simple wrapper around the AppleScript API of the Spotify application on MacOS.

Developed and tested with Python 3.7

Install

pip install wasp-spotify-bindings

Test

python wasp/tests/test_wasp.py
python wasp/tests/test_applescript.py

Import

from wasp_spotify_bindings.core import Wasp
wasp = Wasp()

API

Get track metadata.

wasp.get_track()

returns

{
    'artist': 'Rick Astley',
    'album': 'Whenever You Need Somebody',
    'disc_number': 1,
    'duration': 213573,
    'played_count': 0,
    'track_number': 1,
    'popularity': 75,
    'id': 'spotify:track:4uLU6hMCjMI75M1A2tKUQC',
    'name': 'Never Gonna Give You Up',
    'album_artist':
    'Rick Astley',
    'artwork_url':
    'http://i.scdn.co/image/15ac2c9091d9b74e841b281ceb23ca8208321444',
    'spotify_url': 'spotify:track:4uLU6hMCjMI75M1A2tKUQC'
}

Get player state.

wasp.get_state()

returns

{
    "track_id": "spotify:track:4uLU6hMCjMI75M1A2tKUQC",
    "volume": 49,
    "position": 3,  # seconds
    "state": "playing"
}

Start Spotify application.

wasp.start_spotify()

Quit Spotify application.

wasp.quit_spotify()

Play next track.

wasp.next_track()

Play previous track.

wasp.previous_track()

Play current track.

wasp.play()

Toggle play/pause on current track.

wasp.play_pause()

Pause current track.

wasp.pause()

Set volume to [0-100]

wasp.set_volume(volume=10)

Play track referred to by spotify id.

wasp.play_track(spotify_uri='spotify:track:4uLU6hMCjMI75M1A2tKUQC')

Play track in context of an album/playlist.

wasp.play_track_in_context(
    spotify_uri='spotify:track:4uLU6hMCjMI75M1A2tKUQC',
    context='spotify:track:4uLU6hMCjMI75M1A2tKUQC'
)

Increase volume by 10.

wasp.volume_up()

Decrease volume by 10.

wasp.volume_down()

Jump to position in song (seconds).

wasp.jump_to(jump_to_second=5)

Check if repeat is enabled.

wasp.is_repeating()

Check if shuffle is enabled.

wasp.is_shuffling()

Set repeating to True or False.

wasp.set_repeating(set_repeating=True)

Set shuffling to True or False.

wasp.set_shuffling(set_shuffling=True)

Toggle repeat on/off.

wasp.toggle_repeating()

Toggle shuffle on/off.

wasp.toggle_shuffling()

Mute player.

wasp.mute()

Unmute player.

wasp.unmute()

Project details


Release history Release notifications

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
wasp_spotify_bindings-0.0.1-py3-none-any.whl (7.0 kB) Copy SHA256 hash SHA256 Wheel py3
wasp_spotify_bindings-0.0.1.tar.gz (4.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page