#!/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 echo "Usage: $BASENAME " 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" 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")" ( cd "$MEDIA/$dir" && git annex $command "$base" ) done