Spotify Module Reference
New in version 0.1.0.
Control Spotify using JXA-like syntax.
Classes:
|
A class for managing and interacting with Spotify.app. |
|
A Spotify track. |
- class PyXA.apps.Spotify.XASpotifyApplication(properties)[source]
Bases:
XASBApplication
A class for managing and interacting with Spotify.app.
New in version 0.1.0.
Classes:
PlayerState
(value)States of the Spotify track player.
Attributes:
The currently playing track.
Whether Spotify is the active application.
The name of the application.
The player's position within the currently playing track in seconds.
Is Spotify stopped, paused, or playing?
Whether repeating is on or off.
Whether repeating is enabled in the current playback context.
Whether shuffling is on or off.
Whether shuffling is enabled in the current playback context.
The sound output volume (0 = minimum, 100 = maximum).
The version of Spotify.app.
Methods:
Skips to the next track.
pause
()Pauses playback.
play
()Resumes playback.
play_track
(track_uri[, context_uri])Starts playback of a track in the given context.
Toggles play/pause.
Skips to the previous track.
search
([search_string, track, start_year, ...])Opens the search tab and searches for content matching given parameters.
- class PlayerState(value)[source]
Bases:
Enum
States of the Spotify track player.
Attributes:
- PAUSED = 1800426352
- PLAYING = 1800426320
- STOPPED = 1800426323
- property current_track: XASpotifyTrack
The currently playing track.
- property frontmost: bool
Whether Spotify is the active application.
- property name: str
The name of the application.
- next_track()[source]
Skips to the next track.
- Example:
>>> import PyXA >>> app = PyXA.Application("Spotify") >>> app.next_track()
New in version 0.1.0.
- pause()[source]
Pauses playback.
- Example:
>>> import PyXA >>> app = PyXA.Application("Spotify") >>> app.pause()
New in version 0.1.0.
- play()[source]
Resumes playback.
- Example:
>>> import PyXA >>> app = PyXA.Application("Spotify") >>> app.play()
New in version 0.1.0.
- play_track(track_uri: str, context_uri: str | None = None)[source]
Starts playback of a track in the given context.
- Parameters:
track_uri (str) – The URI of the track to play
context_uri (Union[str, None], optional) – The URI of the context to play in, defaults to None
- Example:
>>> import PyXA >>> app = PyXA.Application("Spotify") >>> app.play_track("spotify:track:4LRPiXqCikLlN15c3yImP7")
New in version 0.1.0.
- property player_position: float
The player’s position within the currently playing track in seconds.
- property player_state: PlayerState
Is Spotify stopped, paused, or playing?
- playpause()[source]
Toggles play/pause.
- Example:
>>> import PyXA >>> app = PyXA.Application("Spotify") >>> app.playpause()
New in version 0.1.0.
- previous_track()[source]
Skips to the previous track.
- Example:
>>> import PyXA >>> app = PyXA.Application("Spotify") >>> app.previous_track()
New in version 0.1.0.
- property repeating: bool
Whether repeating is on or off.
- property repeating_enabled: bool
Whether repeating is enabled in the current playback context.
- search(search_string: str = '', track: str = '', start_year: int = -1, end_year: int = -1, genre: str = '', artist: str = '', album: str = '', label: str = '', mood: str = '')[source]
Opens the search tab and searches for content matching given parameters.
New in version 0.1.0.
- property shuffling: bool
Whether shuffling is on or off.
- property shuffling_enabled: bool
Whether shuffling is enabled in the current playback context.
- property sound_volume: int
The sound output volume (0 = minimum, 100 = maximum).
- property version: str
The version of Spotify.app.
- class PyXA.apps.Spotify.XASpotifyTrack(properties)[source]
Bases:
XAObject
A Spotify track.
New in version 0.1.0.
Attributes:
The album of the track.
The album artist of the track.
The artist of the track.
The album artwork image.
The URL of the track's album cover.
The disc number of the track.
The length of the track in milliseconds.
The ID of the track.
The name of the track.
The number of times this track has been played.
The popularity of this track, 0-100.
The URL of the track.
Whether the track is starred.
The index of the track in its album.
- property album: str
The album of the track.
- property album_artist: str
The album artist of the track.
- property artist: str
The artist of the track.
- property disc_number: int
The disc number of the track.
- property duration: int
The length of the track in milliseconds.
- property id: str
The ID of the track.
- property name: str
The name of the track.
- property played_count: int
The number of times this track has been played.
- property popularity: int
The popularity of this track, 0-100.
- property spotify_url: type
The URL of the track.
- property starred: bool
Whether the track is starred.
- property track_number: int
The index of the track in its album.