blob: f5a4ea999e0e20a2ba943c1723a85d59ef897683 (
plain)
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
|
#!/bin/bash
DIR="$HOME/audio/playlists"
cd "$DIR" || exit
# phone -> desktop
for playlist_path in "$DIR"/phone-export/*; do
playlist="$(basename "$playlist_path")"
# normalize filenames to <playlist name>.m3u
tmp="$(echo $playlist | sed 's/.m3u8$//g' | sed 's/.m3u$//g').m3u"
mv "phone-export/$playlist" "phone-export/$tmp" > /dev/null 2>&1
# \r\n -> \n
sed -i 's/\r$//g' "phone-export/$tmp"
done
# actual import
for playlist_path in "$DIR"/phone-export/*; do
playlist="$(basename "$playlist_path")"
# -nt is a bashism
if [ "$DIR/phone-export/$playlist" -nt "$DIR/$playlist" ]; then
echo "Importing $playlist"
sed -e 's/^primary\/Music\/library\///g' \
-e '/-FLAC\//s/opus$/flac/g' -e '/-MP3\//s/opus$/mp3/g' -e '/-WAVE\//s/opus$/wav/g'\
-e '/^#/d' \
"$DIR/phone-export/$playlist" > "$DIR/$playlist"
git add "$DIR/$playlist" > /dev/null 2>&1
git commit -m "Updated $playlist" > /dev/null 2>&1
fi
done
|