-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsong_getter2.sh
70 lines (38 loc) · 1017 Bytes
/
song_getter2.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
#!/bin/bash
echo "Song Getter 2.0"
artist=$1
source=$2
isNew=0
echo " checking: $1"
#check if an artist exists
if [ -d "/media/pi/BE4B-8D55/Music/$1" ]
then
echo "This artist already exists"
isNew=0
else
echo "$1 is a new Artist, Creating new Directory"
isNew=1
mkdir /media/pi/BE4B-8D55/Music/$artist
fi
#move to temp folder for extraction
cd /media/pi/BE4B-8D55/Temp
#extract the file
youtube-dl -x -i --audio-format mp3 $2
echo "********** Extraction complete *********"
echo " Cleaning Files... "
FILES=/media/pi/BE4B-8D55/Temp/*
echo "files: "
echo $Files
#loop through each track to clean
for f in $FILES
do
#remove the .webm files
#if grep -q .w
song_title=${f::-16}
new_name="${song_title}.mp3"
echo "Renaming file to : $new_name"
mv -- "$f" "$new_name"
done
mv /media/pi/BE4B-8D55/Temp/* /media/pi/BE4B-8D55/Music/$1
ls /media/pi/BE4B-8D55/Music/$artist
echo " ****** Finished Download Successfully ************"