DOCUMENTS
Get File
File Path
/Shortcuts/example.txt

File
COMMENT
refresh_token
⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️
TEXT
51a5f1796fcd49639789bb829b1aa984

Text
VARIABLES
Set variable
clientId
to
Text
TEXT
019798096abc4ef0ac6b1c30d31173ec

Text
VARIABLES
Set variable
clientSecret
to
Text
SCRIPTING
If
File
does not have any value
DOCUMENTS
TEXT
ugc-image-upload
user-read-playback-state
playlist-read-collaborative
user-modify-playback-state
user-read-private
playlist-modify-public
user-library-modify
user-top-read
playlist-read-private
user-follow-read
user-read-recently-played
playlist-modify-private
user-follow-modify
user-library-read

Text
DOCUMENTS
Replace
\n
with
%20
in
Text

Updated Text
URL
https://tecuts.com/spotify-authorization/

URL
SCRIPTING
URL
Encode
URL

URL Encoded Text
SCRIPTING
Show alert
Informational Message
URL
https://accounts.spotify.com/authorize?client_id=
clientId
&response_type=code&redirect_uri=
URL Encoded Text
&scope=
Updated Text

URL
SAFARI
SHARING
Get clipboard

Clipboard
URL
https://accounts.spotify.com/api/token

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
SCRIPTING
Get dictionary from
Contents of URL

Dictionary
SCRIPTING
Get
Value
for
refresh_token
in
Dictionary

Dictionary Value
SCRIPTING
If
Dictionary Value
has any value
DOCUMENTS
Save
Dictionary Value
Destination Path
/Shortcuts/Spotify/key.txtOverwrite If File Exists

Saved File
SCRIPTING
Otherwise
SCRIPTING
Show alert
Generation failed
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
SCRIPTING
End If

If Result
DOCUMENTS

File
DOCUMENTS
Get text from
File

Text
VARIABLES
Set variable
refresh token
to
Text
COMMENT
Get access token
URL
https://accounts.spotify.com/api/token

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
SCRIPTING
Get
Value
for
access_token
in
Contents of URL

Dictionary Value
VARIABLES
Set variable
access_token
to
Dictionary Value
COMMENT
Enter your the spotify URL below. If leave blank, it will play your recent played tracks.
URL
apple.com

URL
SCRIPTING
If
URL
has any value
TEXT
Match
https:\/\/open\.spotify\.com\/(playlist|album|artist)\/([a-zA-Z0-9]+)(.*)$
in
URL

Matches
TEXT
Get
Group At Index
1
in
Matches

Text
TEXT
Get
Group At Index
2
in
Matches

Text
URL
spotify:
Text
:
Text

URL
VARIABLES
Set variable
URI
to
URL
SCRIPTING
Otherwise
COMMENT
Get last played Object
URL
https://api.spotify.com/v1/me/player/recently-played?limit=1

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
SCRIPTING
Get dictionary from
Contents of URL

Dictionary
SCRIPTING
Get
Value
for
items
in
Dictionary

Dictionary Value
SCRIPTING
Get
Value
for
context
in
Dictionary Value

Dictionary Value
SCRIPTING
If
Dictionary Value
contains
spotify
SCRIPTING
Get
Value
for
uri
in
Dictionary Value

Dictionary Value
COMMENT
Workaround for current WebAPI bug
The WebAPI will return a Playlist_v2 URI but the play endpoint can only handle v1 URIs
SCRIPTING
If
Dictionary Value
contains
playlist
SCRIPTING
Get
Value
for
href
in
Dictionary Value

Dictionary Value
NETWORK
Get contents of
Dictionary Value
Options Under Construction

Contents of URL
SCRIPTING
Get dictionary from
Contents of URL

Dictionary
SCRIPTING
Get
Value
for
uri
in
Dictionary

Dictionary Value
SCRIPTING
Otherwise
SCRIPTING
End If

If Result
VARIABLES
Set variable
URI
to
If Result
SCRIPTING
Otherwise
SCRIPTING
Get
Value
for
uri
in
Dictionary Value

Dictionary Value
VARIABLES
Set variable
URI
to
Dictionary Value
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
COMMENT
Enter your prefered device ID below
TEXT
Text

Text
SCRIPTING
If
Text
has any value
VARIABLES
Set variable
deviceID
to
Text
SCRIPTING
Otherwise
COMMENT
Get device id
URL
https://api.spotify.com/v1/me/player/devices

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
SCRIPTING
Get dictionary from
Contents of URL

Dictionary
SCRIPTING
Get
Value
for
devices
in
Dictionary

Dictionary Value
SCRIPTING
Count
Items
in
Dictionary Value

Count
SCRIPTING
If
Count
is less than
1
SCRIPTING
Show alert
Informational Message
SCRIPTING
Otherwise
SCRIPTING
If
Count
is
1
SCRIPTING
Get
Value
for
id
in
Dictionary Value

Dictionary Value
SCRIPTING
Otherwise
SCRIPTING
Repeat with each item in
Dictionary Value

Repeat Results
SCRIPTING
Get
Value
for
name
in
Repeat Item

Dictionary Value
SCRIPTING
Get
Value
for
id
in
Repeat Item

Dictionary Value
SCRIPTING
Set name of
Dictionary Value
to
Dictionary Value

Renamed Item
SCRIPTING
End Repeat

Repeat Results
SCRIPTING
Choose from
Repeat Results

Chosen Item
SCRIPTING
End If

If Result
VARIABLES
Set variable
deviceID
to
If Result
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
COMMENT
Play playlist
URL
https://api.spotify.com/v1/me/player/play?device_id=
deviceID

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL