]> gitweb.fluxo.info Git - playlister.git/commitdiff
Initial import
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 18 Sep 2014 19:36:30 +0000 (16:36 -0300)
committerSilvio Rhatto <user@example.org>
Thu, 18 Sep 2014 19:36:30 +0000 (16:36 -0300)
README.md [new file with mode: 0644]
TODO.md [new file with mode: 0644]
playlist-copy [new symlink]
playlist-drop [new symlink]
playlist-get [new file with mode: 0755]
playlist-ls [new file with mode: 0755]

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/TODO.md b/TODO.md
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/playlist-copy b/playlist-copy
new file mode 120000 (symlink)
index 0000000..a766a62
--- /dev/null
@@ -0,0 +1 @@
+playlist-get
\ No newline at end of file
diff --git a/playlist-drop b/playlist-drop
new file mode 120000 (symlink)
index 0000000..a766a62
--- /dev/null
@@ -0,0 +1 @@
+playlist-get
\ No newline at end of file
diff --git a/playlist-get b/playlist-get
new file mode 100755 (executable)
index 0000000..170f6be
--- /dev/null
@@ -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 (executable)
index 0000000..1894ae6
--- /dev/null
@@ -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