bin: rename and fix play to mp

This commit is contained in:
xeruf 2021-10-15 12:05:29 +02:00
parent 0fa0d830ae
commit f022a98560
2 changed files with 9 additions and 7 deletions

View File

@ -17,3 +17,5 @@ playlist_plugin {
replaygain "track"
auto_update "yes"
follow_outside_symlinks "yes"

View File

@ -1,20 +1,20 @@
#!/bin/sh -e
# Play given files on mpd, enabling playing of external files through symlinking and recursively resolving playlists
# depends: mpc
# depends: xargs mpc realpath
# env: MUSIC
links="$MUSIC/links"
for arg;
test "$1" = "-r" || next=true
{ for arg;
do path="$(test -e "$MUSIC/$arg" && echo "$MUSIC/$arg" || realpath "$arg")"
test -n "$path" || continue
if file "$path" | grep -i ' playlist' || expr "$path" : ".*\.m3u8\?$" >/dev/null
then pushd "$(dirname "$path")" >/dev/null && cat "$path" | xargs --delim='\n' play && popd >/dev/null
then pushd "$(dirname "$path")" >/dev/null && cat "$path" | xargs --delim='\n' play -r && popd >/dev/null
else
find "$path" -name "*.flac" -o -name "*.mp3" | while read file
do case "$path" in
($MUSIC/*) echo "${file/$MUSIC\/}";;
(*) mkdir -p "$links" && ln -s "$file" "$links/$(basename $file)" && echo "links/$(basename $file)";;
(*) mkdir -p "$links" && ln -fs "$file" "$links/$(basename "$file")" && echo "links/$(basename "$file")";;
esac done
fi
done | xargs --delim='\n' mpc insert
# TODO only call on exit point
mpc next
done && mpc update --wait -q; } | xargs --delim='\n' mpc insert
test "$next" && test "$(mpc status | wc -l)" -gt 1 || mpc play -q && mpc next