Accepts
Rich Text, Text and URLs
COMMENT
Deezer music 🎵 downloader.
Ripped from source directly.
V: 3.0.0, Made by /u/74Y3M
COMMENT
Set this text to iCloud to save files on iCloud or Browser for saving on Browser app. You can also use "iCloud and Browser" to save on both of 'em 😉
TEXT
iCloud

Text
VARIABLES
Set variable
SaveTo
to
Text
COMMENT
When sharing from deezer, input is messed up hence we split and combine them for getting the actual urls.
TEXT
Split
Shortcut Input
by
Spaces

Split Text
TEXT
Combine
Split Text
with
New Lines

Combined Text
SCRIPTING
If
Combined Text
contains
Combined Text
SCRIPTING
Otherwise
TEXT
Found deezer links on clipboard, would you like to continue with download?
Clipboard

Text
SHARING
Get clipboard

Clipboard
SCRIPTING
If
Clipboard
contains
deezer.com
COMMENT
Let the user know if they wanna download the content from their clipboard link and if they don't go with search!
SCRIPTING
Choose from Menu

Menu Result
SCRIPTING
Yes

Menu Result
SCRIPTING
No

Menu Result
NOTHING
Nothing
SCRIPTING
End Menu

Menu Result
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
VARIABLES
Set variable
Input
to
If Result
COMMENT
Enter quality to download.
128/320/1411
128 - 128 kbps mp3
320 - 320 kbps mp3
1411 - 1411 kbps flac
NUMBER
1441

Number
VARIABLES
Set variable
Quality
to
Number
SCRIPTING
If
Input
contains
lnk.to
COMMENT
Artists nowadays usually share artistname.lnk.to/album-name like urls for redirecting to various streaming services. If we have this on input, parse it for getting deezer urls.
NETWORK
Get contents of
Input
Options Under Construction

Contents of URL
DOCUMENTS
Make HTML from
Contents of URL

HTML from Rich Text
TEXT
Match
https?.*?deezer.com/.*
in
HTML from Rich Text

Matches
VARIABLES
Set variable
Input
to
Matches
SCRIPTING
End If

If Result
SCRIPTING
If
Input
contains
deezer.com
COMMENT
If we have deezer link, just move along with downloads.
SCRIPTING
Otherwise
TEXT
Enter search input or type any of this:
- "C" for top 10 tracks!
- "A:album name" for albums
- "P:playlist name" for playlists
- ":search query" for tracks, playlists and albums
PS: Word (A/P) before colon (:) are case sensitive. Without colon only tracks results will be fetched.

Text
SCRIPTING
Ask
Text
Default Answer
[{'class': 'magic', 'value': 'Shortcut Input', 'glyph': 'assets/cat/Input.svg', 'UUID': ''}]

Provided Input
SCRIPTING
If
Ask for Input
is
C
COMMENT
C is for top charts. You can replace this url with any of your specific charts.
URL
https://api.deezer.com/chart/0/tracks

URL
SCRIPTING
Otherwise
SCRIPTING
URL
Encode
Ask for Input

URL Encoded Text
SCRIPTING
If
URL Encoded Text
contains
:
SCRIPTING
If
URL Encoded Text
contains
A:
TEXT
Match
[^:]+$
in
URL Encoded Text

Matches
URL
https://api.deezer.com/search/album?q=
Text Matches

URL
SCRIPTING
Otherwise
SCRIPTING
If
URL Encoded Text
contains
P:
TEXT
Match
[^:]+$
in
URL Encoded Text

Matches
URL
https://api.deezer.com/search/playlist?q=
Text Matches

URL
SCRIPTING
Otherwise
TEXT
Match
[^:]+$
in
URL Encoded Text

Matches
TEXT
https://api.deezer.com/search/track?q=
Text Matches
https://api.deezer.com/search/playlist?q=
Text Matches
https://api.deezer.com/search/album?q=
Text Matches

Text
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
COMMENT
If none of charts, album or playlist was selected go with default track search.
URL
https://api.deezer.com/search?q=
URL Encoded Text

URL
SCRIPTING
End If

If Result
SCRIPTING
End If

If Result
NETWORK
Get contents of
If Result
Options Under Construction

Contents of URL
COMMENT
If ":" was selected it gets multiple pages else one single page was fetched. Just repeat with each and add results to variable.
SCRIPTING
Repeat with each item in
Contents of URL

Repeat Results
SCRIPTING
Get
Value
for
data
in
Repeat Item

Dictionary Value
SCRIPTING
Count
Items
in
Dictionary Value

Count
COMMENT
Every search results have 25 results but we cut them to 10 for decreasing clutter. Specially when ":" was used it gets messy! Change the number if you want more result but don't go over 25.
SCRIPTING
If
Count
is greater than
10.0
NUMBER
10.0

Number
VARIABLES
Set variable
ItemsData
to
Number
SCRIPTING
End If

If Result
SCRIPTING
Get
Items in Range
Start Index
to
ItemsData
from
Dictionary Value

Item from List
COMMENT
From dictionary > data we get the actual tracks. Repeat with each and add to our list for downloading on next step.
SCRIPTING
Repeat with each item in
Item from List

Repeat Results
SCRIPTING
Get
Value
for
artist
in
Repeat Item 2

Dictionary Value
URL
Repeat Item 2

URL
SCRIPTING
Set name of
URL
to
Repeat Item 2
-
Dictionary Value

Renamed Item
VARIABLES
Add
Renamed Item
to
SearchItems
SCRIPTING
End Repeat

Repeat Results
SCRIPTING
End Repeat

Repeat Results
COMMENT
Here we choose songs from our searched results. By default, we select only one song. You can enable multiple button here for selecting multiple songs.
SCRIPTING
Choose from
SearchItems
Prompt
Select a music to download

Chosen Item
VARIABLES
Set variable
Input
to
Selected Item
SCRIPTING
End If

If Result
DOCUMENTS
Replace
.+?(?=/album|/artist|/playlist|/profile|/track)
with
http://api.deezer.com
in
Input

Updated Text
COMMENT
Replace all the deezer links with their api endpoint. You shouldn't download multiple albums/playlist at the same time, only tracks are good.
SCRIPTING
If
Updated Text
contains
/track/
TEXT
Split
Updated Text
by
New Lines

Split Text
SCRIPTING
Count
Items
in
Split Text

Count
COMMENT
Deezer have a api limit and that is 50 requests every 5 seconds. So we have to use their api slowly if we have more than 50 tracks. If we have less tracks we will fetch 'em all at once!
SCRIPTING
If
Count
is greater than
50.0
SCRIPTING
Repeat with each item in
Split Text

Repeat Results
NETWORK
Get contents of
Repeat Item
Options Under Construction

Contents of URL
SCRIPTING
End Repeat

Repeat Results
SCRIPTING
Otherwise
NETWORK
Get contents of
Replace Text
Options Under Construction

Contents of URL
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
COMMENT
Here we are gonna fetch album/playlist or anything else with a single request. Please bear in mind, we cannot get more than 400 tracks from a playlist with a single request.
SCRIPTING
If
Updated Text
contains
deezer.com
NETWORK
Get contents of
Updated Text
Options Under Construction

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

Dictionary Value