aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md0
-rw-r--r--TODO.md0
l---------playlist-copy1
l---------playlist-drop1
-rwxr-xr-xplaylist-get65
-rwxr-xr-xplaylist-ls16
6 files changed, 83 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README.md
diff --git a/TODO.md b/TODO.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TODO.md
diff --git a/playlist-copy b/playlist-copy
new file mode 120000
index 0000000..a766a62
--- /dev/null
+++ b/playlist-copy
@@ -0,0 +1 @@
+playlist-get \ No newline at end of file
diff --git a/playlist-drop b/playlist-drop
new file mode 120000
index 0000000..a766a62
--- /dev/null
+++ b/playlist-drop
@@ -0,0 +1 @@
+playlist-get \ No newline at end of file
diff --git a/playlist-get b/playlist-get
new file mode 100755
index 0000000..170f6be
--- /dev/null
+++ b/playlist-get
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+# Get playlist files using git-annex.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+PLAYLIST="$1"
+DEST="$2"
+MEDIA="/var/cache/media/noise"
+PLAYLISTS="$MEDIA/playlists"
+APP="git annex"
+
+# Basic syntax
+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
+
+# Set action
+if [ "$BASENAME" == "playlist-drop" ]; then
+ action="drop"
+elif [ "$BASENAME" == "playlist-copy" ]; then
+ if [ -z "$DEST" ]; then
+ echo "No destination specified"
+ exit 1
+ elif [ -d "$DEST" ]; then
+ APP="cp -Lv"
+ action=""
+
+ # Force absolute path
+ DEST="`cd $DEST && pwd`"
+ else
+ DEST="--to $DEST"
+ action="copy"
+ fi
+else
+ action="get"
+fi
+
+echo "Getting files from $PLAYLISTS/$PLAYLIST.m3u..."
+cd $MEDIA
+
+# Process
+cat $PLAYLISTS/$PLAYLIST.m3u | while read file; do
+ if [ -z "$action" ] && [ "$APP" == "cp -Lv" ]; then
+ prefix="/$(dirname "$file")"
+ mkdir -p "$DEST$prefix"
+ $APP $action "$file" "$DEST$prefix"
+ elif [ "$action" == "get" ]; then
+ $APP $action "$file"
+ else
+ $APP $action "$file" $DEST
+ fi
+done
diff --git a/playlist-ls b/playlist-ls
new file mode 100755
index 0000000..1894ae6
--- /dev/null
+++ b/playlist-ls
@@ -0,0 +1,16 @@
+#!/bin/bash
+#
+# Get files for playlist using git-annex and mpd
+#
+
+# Parameters
+BASENAME="`basename $0`"
+PLAYLIST="$1"
+MEDIA="/var/cache/media/noise"
+PLAYLISTS="$MEDIA/playlists"
+
+if [ -z "$PLAYLIST" ]; then
+ ls -C $PLAYLISTS
+elif [ -f "$PLAYLISTS/$PLAYLIST.m3u" ]; then
+ cat "$PLAYLISTS/$PLAYLIST.m3u"
+fi