bin: music utilities
This commit is contained in:
parent
8b36d80d5e
commit
231496fc1a
|
@ -1,15 +1,18 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Playlist utilities
|
# Playlist management
|
||||||
# optdepends: highlight python
|
# optdepends: highlight python
|
||||||
# env: MUSIC
|
# env: MUSIC
|
||||||
test $# -gt 0 && command=$1 && shift
|
test $# -gt 0 && command=$1 && shift
|
||||||
|
test "$1" = '-v' && verbose='true' && shift || verbose='false'
|
||||||
case $command in
|
case $command in
|
||||||
(update)
|
(update)
|
||||||
for pl; do
|
for pl; do
|
||||||
highlight $pl
|
highlight $pl
|
||||||
cat $pl | rev | cut -d'/' -f-2 | rev | while read f; do
|
cat $pl | rev | cut -d'/' -f-2 | rev | while read f; do
|
||||||
|
$verbose && printf "\e[31;1mSearching for '$f'\e[0m\n" >&2
|
||||||
test -n "$f" || continue
|
test -n "$f" || continue
|
||||||
newpath="$(find $MUSIC -path "*${f#*../}" -prune | grep . || find $MUSIC -path "*${f##* - }" -o -path "*${f##*/}" | grep -m 1 .)"
|
newpath="$(find $MUSIC -path "*${f#*../}" -prune | grep . || find $MUSIC -path "*${f##* - }" -o -path "*${f##*/}" | grep -m 1 .)"
|
||||||
|
$verbose && printf "\e[31;1mFound '$newpath'\e[0m\n" >&2
|
||||||
test -n "$newpath" && realpath --relative-to $(dirname "$pl") "$newpath" || echo "$f"
|
test -n "$newpath" && realpath --relative-to $(dirname "$pl") "$newpath" || echo "$f"
|
||||||
done | tee $pl
|
done | tee $pl
|
||||||
done;;
|
done;;
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
# Play given files on mpd, enabling playing of external files through symlinking and recursively resolving playlists
|
||||||
|
# depends: mpc
|
||||||
|
# env: MUSIC
|
||||||
|
links="$MUSIC/links"
|
||||||
|
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
|
||||||
|
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)";;
|
||||||
|
esac done
|
||||||
|
fi
|
||||||
|
done | xargs --delim='\n' mpc insert
|
||||||
|
# TODO only call on exit point
|
||||||
|
mpc next
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh -e
|
||||||
# Copy recursively over ssh
|
# Copy recursively over ssh
|
||||||
server="$1"
|
server="$1"
|
||||||
folder="$2"
|
folder="$2"
|
||||||
|
|
Loading…
Reference in New Issue