Skip to main content

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()

Release files for wasp-spotify-bindings 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wasp-spotify-bindings 0.0.1
File Size Uploaded
wasp_spotify_bindings-0.0.1.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wasp-spotify-bindings 0.0.1
File Interpreter ABI Platform
wasp_spotify_bindings-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size:11.5 kB

Release files / wasp_spotify_bindings-0.0.1.tar.gz

Download URL wasp_spotify_bindings-0.0.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
93d79468cfcd9fec33f4d6263ec708e45a68a1b63afa6f7915742587c85d0ad8
BLAKE2b-256 checksum
How to use checksums
8ed60e92aa8437a577b3c063f18c0f93aa37ca53f889d99ee97f2d3d834c6e8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.1rc1

Release files / wasp_spotify_bindings-0.0.1-py3-none-any.whl

Download URL wasp_spotify_bindings-0.0.1-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7eec6f208a26243049706bbb904c1b15559c110c6b0fb9630379c6575201faad
BLAKE2b-256 checksum
How to use checksums
8e2ca5b78b481ff9bac2832e7f8b0c95fe862b70612599cb0be12de90c38e44c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.1rc1

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page