3 DIR
="$( cd "$
( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4 source "$DIR/config.sh"
10 songs_file
=$
(ls "$DIR" |
grep songs |
tail -n1
)
12 if [ -z
"$songs_file" ]; then
17 if [ "$1" = "push" ]; then
18 if find "$path_to_songs/$faves_folder" -mindepth
1 -print
-quit
2>/dev
/null |
grep -q .
; then
19 find -L
"$path_to_songs/$faves_folder" -name \
*.sm
-exec md5sum {} \
; | cut
-sd
' ' -f1
> "$DIR/$me.favourites.txt"
20 scp
"$DIR/$me.favourites.txt" groovenet@cameron1729.xyz
:/mnt
/media
/GrooveNet
24 if [ "$1" = "apply" ]; then
25 if find "${DIR}"/*.favourites.txt
-type f
-print
-quit
2>/dev
/null |
grep -q .
; then
26 find "${DIR}"/*.favourites.txt
-type f
-print0 |
while read -d $
'\0' file; do
27 IFS
=$
'\n' read -d
'' -r
-a lines
< $file
28 file=$
(basename "$file")
31 if [ "$person" = "$me" ]; then
32 persons_folder
="$faves_folder"
34 formatted_person
="$(tr '[:lower:]' '[:upper:]' <<< ${person:0:1})${person:1}"
35 persons_folder
=${external_favourite_naming_scheme/\%person\%/$formatted_person}
38 rm -rf
"$path_to_songs/$persons_folder"
39 mkdir
"$path_to_songs/$persons_folder"
42 for i
in "${lines[@]}"; do
43 pattern
="${pattern}|$i"
46 pattern
="${pattern:1}"
47 song_paths
=$
(grep -E
"$pattern" "${DIR}/${songs_file}" |
sort -u
-k1
,1 | cut
-sd
/ -f5-6
)
49 while read -r song_path
; do
50 just_song
=$
(echo $song_path | cut
-sd
/ -f2
)
51 crc32
="$(echo -n "/Songs
/${persons_folder}/${just_song}/" | gzip -c | tail -c8 | hexdump -n4 -e '"%u
"')"
53 echo "${just_song} -> ${persons_folder}"
54 echo -e
"\t${path_to_song_cache}/${crc32}"
56 rm "${path_to_song_cache}/${crc32}"
57 ln -s
"$path_to_songs/$song_path" "$path_to_songs/$persons_folder/$just_song"
58 done <<< "$song_paths"