Skip to content

Instantly share code, notes, and snippets.

@ppmx
Forked from zfarbp/s.md
Created October 11, 2022 21:45
Show Gist options
  • Select an option

  • Save ppmx/5bc8a5993086b6b4d3b2651d2bc1c601 to your computer and use it in GitHub Desktop.

Select an option

Save ppmx/5bc8a5993086b6b4d3b2651d2bc1c601 to your computer and use it in GitHub Desktop.

Revisions

  1. @zfarbp zfarbp revised this gist Nov 21, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions s.md
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,7 @@ osascript -e 'tell application "Spotify" to name of current track' # The
    osascript -e 'tell application "Spotify" to artwork of current track' # The track s album cover.
    osascript -e 'tell application "Spotify" to album artist of current track' # That album artist of the track.
    osascript -e 'tell application "Spotify" to spotify url of current track' # The URL of the track.
    osascript -e 'tell application "Spotify" to player position' # Position of current track.

    # read/write
    osascript -e 'tell application "Spotify" to player position' # The player s position within the currently playing track in seconds.
  2. @zfarbp zfarbp revised this gist Nov 21, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion s.md
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@ osascript -e 'tell application "Spotify" to previous track'
    osascript -e 'tell application "Spotify" to playpause'
    osascript -e 'tell application "Spotify" to pause'
    osascript -e 'tell application "Spotify" to play'
    osascript -e 'tell application "Spotify" to play track "spotify:track:3941McqnrX9blUEelPxgot"'
    osascript -e 'tell application "Spotify" to play track "spotify:track:7IjFVDzHNxAAWoMwl2XRm5"'
    osascript -e 'tell application "Spotify" to play track "spotify:playlist:3pCz4zMeSm7yIU7fslKih1"'

    # read-only
  3. @zfarbp zfarbp renamed this gist Nov 21, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @zfarbp zfarbp created this gist Nov 21, 2019.
    51 changes: 51 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    # Trigger Spotify with osascript

    ```sh
    /Applications/Spotify.app/Contents/Resources/Spotify.sdef

    # read-only
    osascript -e 'tell application "Spotify" to player state' # stopped,playing,paused
    osascript -e 'tell application "Spotify" to current track' # The current playing track.
    osascript -e 'tell application "Spotify" to artwork of current track' # Image data in TIFF format.
    osascript -e 'tell application "Spotify" to artist of current track' # The artist of the track.
    osascript -e 'tell application "Spotify" to album of current track' # The album of the track.
    osascript -e 'tell application "Spotify" to disc number of current track' # The disc number of the track.
    osascript -e 'tell application "Spotify" to duration of current track' # The length of the track in seconds.
    osascript -e 'tell application "Spotify" to played count of current track' # The number of times this track has been played.
    osascript -e 'tell application "Spotify" to track number of current track' # The index of the track in its album.
    osascript -e 'tell application "Spotify" to starred of current track' # Is the track starred?
    osascript -e 'tell application "Spotify" to popularity of current track' # How popular is this track? 0-100
    osascript -e 'tell application "Spotify" to id of current track' # The ID of the item.
    osascript -e 'tell application "Spotify" to name of current track' # The name of the track.
    osascript -e 'tell application "Spotify" to artwork of current track' # The track s album cover.
    osascript -e 'tell application "Spotify" to album artist of current track' # That album artist of the track.
    osascript -e 'tell application "Spotify" to spotify url of current track' # The URL of the track.

    # read/write
    osascript -e 'tell application "Spotify" to player position' # The player s position within the currently playing track in seconds.
    osascript -e 'tell application "Spotify" to set player position to 20'
    osascript -e 'tell application "Spotify" to repeating enabled' # Is repeating enabled in the current playback context?
    osascript -e 'tell application "Spotify" to set repeating enabled to true'
    osascript -e 'tell application "Spotify" to repeating' # Is repeating on or off?
    osascript -e 'tell application "Spotify" to set repeating to true'
    osascript -e 'tell application "Spotify" to shuffling enabled' # Is shuffling enabled in the current playback context?
    osascript -e 'tell application "Spotify" to shuffling' # Is shuffling on or off?
    osascript -e 'tell application "Spotify" to sound volume' # The sound output volume (0 = minimum, 100 = maximum)
    osascript -e 'tell application "Spotify" to set sound volume to 50'

    # commands
    osascript -e 'tell application "Spotify" to next track'
    osascript -e 'tell application "Spotify" to previous track'
    osascript -e 'tell application "Spotify" to playpause'
    osascript -e 'tell application "Spotify" to pause'
    osascript -e 'tell application "Spotify" to play'
    osascript -e 'tell application "Spotify" to play track "spotify:track:3941McqnrX9blUEelPxgot"'
    osascript -e 'tell application "Spotify" to play track "spotify:playlist:3pCz4zMeSm7yIU7fslKih1"'

    # read-only
    osascript -e 'tell application "Spotify" to name' # The name of the application.
    osascript -e 'tell application "Spotify" to version' # The version of the application.


    osascript -e 'tell application "Spotify" to quit'
    ```