From 221e7d6d0de9f58d0d82ba42a9fc55a157706f6d Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 18 Sep 2014 16:36:30 -0300 Subject: Initial import --- README.md | 0 TODO.md | 0 playlist-copy | 1 + playlist-drop | 1 + playlist-get | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ playlist-ls | 16 +++++++++++++++ 6 files changed, 83 insertions(+) create mode 100644 README.md create mode 100644 TODO.md create mode 120000 playlist-copy create mode 120000 playlist-drop create mode 100755 playlist-get create mode 100755 playlist-ls diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..e69de29 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 [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 -- cgit v1.2.3