blob: d43e296b44943c1da84569b2895df88ac02842be (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/bin/bash
#
# Get files for playlist using git-annex and mpd
#
# Parameters
BASENAME="`basename $0`"
PLAYLIST="$1"
DEST="$2"
MEDIA="/var/cache/media/noise"
PLAYLISTS="$MEDIA/playlists"
if [ -z "$PLAYLIST" ]; then
echo "Usage: $BASENAME <playlist> [dest]"
if [ -d "$PLAYLISTS" ]; then
echo ""
echo "Available playlists: "
ls $PLAYLISTS
fi
exit 1
elif [ ! -f "$PLAYLISTS/$PLAYLIST.m3u" ]; then
echo "No such playlist $PLAYLISTS/$PLAYLIST.m3u"
exit 1
fi
if [ "$BASENAME" == "playlist-drop" ]; then
command="drop"
elif [ "$BASENAME" == "playlist-copy" ]; then
if [ -z "$DEST" ]; then
echo "No destination specified"
exit 1
fi
DEST="--to $DEST"
command="copy"
else
command="get"
fi
echo "Getting files from $PLAYLISTS/$PLAYLIST.m3u..."
cat $PLAYLISTS/$PLAYLIST.m3u | while read file; do
dir="$(dirname "$file")"
base="$(basename "$file")"
mkdir -p "$MEDIA/$dir"
( cd "$MEDIA/$dir" && git annex $command "$base" $DEST )
done
|