-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeezbeezkneez.sh
217 lines (189 loc) · 5.84 KB
/
deezbeezkneez.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
Main() {
# Gloabal Variables
ECHO="echo -e"
SMLOADR="$HOME/bin/SMLoadr" # Path to SMloader tool
# LOGDATE="date +%Y%m%d%H%M%S"
LOG=$(tee -a "$OUTPUT"/deezbeezknees.log) # Path to logfile
# Exit function
_polly() {
whiptail --title "YOU SHALL NOT PASS" --msgbox Exiting 10 60
clear
curl -s parrot.live
}
_inputbox() {
# Usage: _inputbox <TITLE> <PROMPT> <COMMAND> <exitTITLE> <exitMSG>
local TITLE="$1"
local PROMPT="$2"
project_NAME=$(whiptail --title "$TITLE" --inputbox "$PROMPT" 10 60 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
"$3"
local exitTITLE="$4"
local exitMSG="$5"
whiptail --title "$exitTITLE" --msgbox "$exitMSG" 10 60
else
_polly
fi
}
# Mirror Deezer to local directory
_mir() {
# rm -rf "$OUTPUT"/mirrordeezer.log # Removing existing mirrordeezer.log
mkdir -p "$OUTPUT" # Creates output folder if not already created
$ECHO "Starting full mirror of Deezer starting at 1" | $LOG
$ECHO " --quality parameter set to FLAC" | $LOG
sleep 5
local x="13000000" # Possible highest value of artists on Deezer
local parallelARGS=(
"--link"
"-j12"
"--joblog=${parallel_log}"
"-X"
"--progress"
"--load=50%"
"--retries=3"
"--noswap"
"--memfree 128M"
"--resume-failed"
"--delay"
"--eta"
)
local smloadrARGS=(
"--quality='FLAC'"
"--downloadmode='single'"
"--path=$OUTPUT"
)
# Base path for artists
local smloadrSITE="https://www.deezer.com/us/ar/us/artist/"
local OUTPUT="$HOME/files/Music" # Path to output folder
seq $x | parallel "${parallelARGS[@]}" "$SMLOADR" "${smloadrARGS[@]}" ${smloadrSITE}{}
$ECHO "" | "$LOG"
$ECHO "" | "$LOG"
## TODO: verify working script. \
## find out how to pipe from SMloader
## create url log of completed scripts
}
_mirtocloud() {
# rm -rf "$OUTPUT"/mirrordeezer.log # Removing existing mirrordeezer.log
mkdir -p "$OUTPUT" # Creates output folder if not already created
$ECHO "Starting full mirror of Deezer starting at 1" | $LOG
$ECHO " --quality parameter set to FLAC" | $LOG
sleep 5
local green='\033[0;32m'
local red='\033[0;31m'
local cyan='\033[0;36m'
local black='\033[0;30m'
local x="13000000" # Possible highest value of artists on Deezer
local parallelARGS=(
"--link"
"-j4"
"--joblog=${parallel_log}"
"-X"
"--progress"
"--load=50%"
"--retries=3"
"--noswap"
"--memfree 128M"
"--resume-failed"
"--delay"
"--eta"
)
local smloadrARGS=(
"--quality='FLAC'"
"--downloadmode='single'"
"--path=$OUTPUT"
)
local URL="https://www.deezer.com/us/ar/us/artist/"
local rcloneREMOTE="omg"
local rcloneOUTPUT="OMG_share/Plex-Media/deezbeezkneez/*"
local rcloneARGS=(
"--checksum"
"--contimeout=60s"
"--drive-chunk-size=$CHUNK"
"--drive-upload-cutoff=$CHUNK"
"--fast-list"
"--log-level=DEBUG"
"--low-level-retries=10"
"--low-level-retries=20"
"--min-size=0"
"--no-check-certificate"
"--retries=3"
"--retries=20"
"--stats-log-level=DEBUG"
"--stats=10s"
"--stats=10s"
"--timeout=300s"
"--tpslimit float"
# "--log-file=$LOGFILE"
# "--transfers=8"
# "--checkers=8"
)
seq $x | parallel "${parallelARGS[@]}" "$SMLOADR" "${smloadrARGS[@]}" ${URL}{}
$ECHO "" | "$LOG"
$ECHO "" | "$LOG"
}
_smloader() {
# Removing existing mirrordeezer.log
rm -rf "$OUTPUT"/mirrordeezer.log
}
_cfg() {
$SMLOADR
}
_install() {
local packageURL="https://u.teknik.io/QfOC8.zip"
mkdir -p ~/bin
rm -rf ~/bin/SMLoadr.zip
rm -rf ~/bin/SMLoadr*
wget -q -O ~/bin/SMLoadr.zip "$packageURL" &&
unzip -qo -d ~/bin/ ~/bin/SMLoadr.zip &&
mv ~/bin/SMLoadr-* ~/bin/SMLoadr &&
chmod +x ~/bin/SMLoadr &&
$ECHO "Installation to ~/bin/ Complete"
}
_hlp() {
$ECHO ""
$ECHO "Usage: deezbeezkneez.sh <option(s)>"
$ECHO ""
$ECHO "Available options:"
$ECHO "-m, --mirror : Mirror deezer starting at artist 1"
$ECHO "-g, --gdrive : Mirror deezer starting at artist 1 directly to gdrive"
$ECHO "-h, --help : This help page."
$ECHO "-i, --install : download SMloader to $HOME/bin"
$ECHO "-r, --run : run SMloader like normal. same as --config"
$ECHO "-c, --config : Run SMloader alone the first time to config Deezer account"
$ECHO ""
}
while [ ! $# -eq 0 ]; do
case $1 in
-h | --help)
hlp
exit 0
;;
-m | --mirror)
mir
exit 0
;;
-g | --gdrive)
mirtocloud
exit 0
;;
-s | --smloader)
smloader
exit 0
;;
-i | --install)
install
exit 0
;;
-c | --config)
cfg
exit 0
;;
*)
hlp
exit 0
;;
esac
shift
done
}