Accepts
Safari Web Pages and URLs
COMMENT
Edited by Cody Chrunos
My website: chrunos.com
Watch tutorial videos in my YouTube channel: https://www.youtube.com/channel/UCtj4sKppQr_Xd9TjxSw4JwQ
COMMENT
Get the playlist URL
- If no playlist is shared with the shortcut, ask the user for it, offering the clipboard as default
WEB
Get URLs from
Shortcut Input

URLs
SCRIPTING
If
Direcciones URL
does not have any value
WEB
Get URLs from
Clipboard

URLs
SCRIPTING
Get
First Item
from
Direcciones URL

Item from List
SCRIPTING
Ask
URL of Spotify playlist?
Default Answer
[{'class': 'magic', 'value': 'Ítem de la lista', 'glyph': '', 'UUID': 'C0FE6FA7-F5A6-4E85-9309-740A18BD46CD'}]

Provided Input
SCRIPTING
Otherwise
SCRIPTING
Get
First Item
from
Direcciones URL

Item from List
URL
Item from List

URL
SCRIPTING
End If

If Result
VARIABLES
Set variable
Spotify Playlist URL
to
Resultado de la acción Si
COMMENT
Get the playlist title
- Colons are replaced by hyphens
NETWORK
Get contents of
Spotify Playlist URL
Options Under Construction

Contents of URL
SCRIPTING
Set name of
Contenido de URL
to
html.txt

Renamed Item
TEXT
Match
(?<="twitter:title" content=")[^"]+
in
Ítem renombrado

Matches
DOCUMENTS
Replace
\s?:\s?
with
-
in
Coincidencias

Updated Text
VARIABLES
Set variable
Spotify Playlist Title
to
Texto actualizado
TEXT
Match
(https:\/\/open.spotify.com)\/playlist\/(.*)
in
Spotify Playlist URL

Matches
TEXT
Match
(\/)(\d|\w){22}
in
Matches

Matches
DOCUMENTS
Replace
/
with
World
in
Matches

Updated Text
COMMENT
Get the playlist tracks
- Also retrievable from the HTML source above, but this is easier
URL
https://www.spotifydl.xyz/api/playlist?id=
Spotify Playlist URL

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
COMMENT
Proceed only if there is a playlist
SCRIPTING
If
Contenido de URL
is not
{"failed":"no such playlist"}
COMMENT
Use Toolbox Pro "Quick Menu" action to assemble a menu with the playlist tracks
- This can be done with the free version of the app
- It could also be done without the app, but this is much easier
DOCUMENTS
Replace
’
with
'
in
Contenido de URL

Updated Text
SCRIPTING
Repeat with each item in
Texto actualizado

Repeat Results
SCRIPTING
Get dictionary from
Repeat Item

Dictionary
TEXT
artist
-
name

Text
SCRIPTING
End Repeat

Repeat Results
SCRIPTING
Choose from
Repeat Results

Chosen Item
COMMENT
Ask the user which tracks to transfer
- First, allow the user to pre-select all the tracks
SCRIPTING
Count
Items
in
Chosen Item

Count
SCRIPTING
If
Contar
is greater than
0
SCRIPTING
Repeat with each item in
Chosen Item

Repeat Results
DOCUMENTS
Replace
-
with
in
Repeat Item

Updated Text
TEXT
Split
Updated Text
by
Spaces

Split Text
TEXT
Combine
Split Text
with
Custom
+

Combined Text
VARIABLES
Set variable
Search term
to
Combined Text
VARIABLES
Get
Search term
ITUNES STORE
Search iTunes Store for
Search term

iTunes Products
SCRIPTING
Wait
3 seconds
SCRIPTING
End Repeat

Repeat Results
SCRIPTING
Otherwise
SCRIPTING
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
SCRIPTING
SCRIPTING
End If

If Result