forked from jpeirce/deadloader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deadldr
executable file
·34 lines (34 loc) · 1.25 KB
/
deadldr
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
#!/bin/bash
# Arguments - URL
#Download full webpage
raw=$(curl $1)
#Get playlist file url using >VBR< title and cut
playlist="http://archive.org"$(echo "$raw" | grep ">VBR<" | cut -d \" -f 2)
#Get the performance name using cut and tail
name=$(echo "$raw" | grep "itemprop=\"name\"" | cut -d \< -f 2 | cut -d \> -f 2 | tail -1)
#Replace any slashes with dashes
name=$(echo "$name" | sed 's#/#-#g')
#Get titles using cut then turn into array
titles=$(echo "$raw" | grep "\"title\":" | grep "mp3" | cut -d \" -f 4 | cut -d \ -f 2-100)
#Replace any slashes with dashes
titles=$(echo "$titles" | sed 's#/#-#g')
readarray -t titles <<<"$titles"
#Gets the list of all files to download from playlist file
files=$(wget -qO- $playlist)
#Gets the year information from html tags in the webpage
year=$(echo "$raw" | grep "data-year" | tail -1 | cut -d \" -f 2)
#Makes a directory named after the performance name
mkdir -p "$name"
#Gets all files from performance and opens up one process for every file
echo "$files" | xargs -n 1 -P ${#titles[@]} wget -P "$name" -c
#Renames all riles to appropriate track name
i=0
for file in $(ls "$name")
do
old="$name/$file"
new="$name/$((i + 1)) - ${titles[$i]}.mp3"
echo "Processed $new"
mv "$old" "$new"
id3v2 -y "$year" "$new"
let i+=1
done