bin: flexibilize music playing

This commit is contained in:
xeruf 2022-06-13 15:47:47 +02:00
parent 11720e3a27
commit ac370731ad
2 changed files with 5 additions and 3 deletions

View File

@ -97,6 +97,7 @@ formatsong() {
s/^\([A-z]\+\) The \([^-]\+\)$/\1, the \2/g; s/^\([A-z]\+\) The \([^-]\+\)$/\1, the \2/g;
s/ \(\..\{2,4\}\)$/\1/; s/ \(\..\{2,4\}\)$/\1/;
s/---/ - /; s/---/ - /;
s/-LLS\././;
s/^[0-9]\{6\}_//; s/^[0-9]\{6\}_//;
s/\([^/]\)_/\1 /g; s/\([^/]\)_/\1 /g;
s/ \././g; s/ \././g;

View File

@ -3,7 +3,7 @@
# Play given files on mpd, playing external files through symlinking and recursively resolving playlists # Play given files on mpd, playing external files through symlinking and recursively resolving playlists
# depends: xargs realpath mpc # depends: xargs realpath mpc
# env: MUSIC # env: MUSIC
# TODO auto-convert unknown types with ffmpeg to flac # TODO auto-convert unknown types with ffmpeg to flac rather than linking (wav, opus, ...)
MUSIC="${MUSIC:-$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/mpd/mpd.conf | grep music_directory | cut -d'"' -f2 | sed "s|~|$HOME|")}" MUSIC="${MUSIC:-$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/mpd/mpd.conf | grep music_directory | cut -d'"' -f2 | sed "s|~|$HOME|")}"
PLAYLISTS="$MUSIC/Playlists" PLAYLISTS="$MUSIC/Playlists"
LINKS="$MUSIC/links" LINKS="$MUSIC/links"
@ -13,9 +13,10 @@ then shift
# TODO this is sooo slow... # TODO this is sooo slow...
for arg for arg
do do
filepath="$({ find "$(dirname -- "$arg")" -maxdepth 1 -name "$(basename -- "$arg")*" -exec realpath {} + || matchname="$(basename -- "$arg" | sed 's|\(\[.*\)\]|\\\1\\]|;s|\?|\\?|')*"
filepath="$({ find "$(dirname -- "$arg")" -maxdepth 1 -name "$matchname" -exec realpath {} + ||
find "$MUSIC/$(dirname -- "$arg")" "$MUSIC/Playlists/$(dirname -- "$arg")" -maxdepth 1 \ find "$MUSIC/$(dirname -- "$arg")" "$MUSIC/Playlists/$(dirname -- "$arg")" -maxdepth 1 \
-name "$(basename -- "$arg")*" -exec realpath {} +; } 2>/dev/null)" -name "$matchname" -exec realpath {} +; } 2>/dev/null)"
test -n "$verbose" && echo "Scanning path '$filepath' $( test -n "$verbose" && echo "Scanning path '$filepath' $(
test "$arg" != "$filepath" && echo "from '$arg' ")(MUSIC: '$MUSIC', PWD: '$PWD')" >&2 test "$arg" != "$filepath" && echo "from '$arg' ")(MUSIC: '$MUSIC', PWD: '$PWD')" >&2
test $(printf "$filepath" | wc -l) -gt 0 && printf "$filepath" | xargs --delim='\n' "$0" -r $verbose && continue test $(printf "$filepath" | wc -l) -gt 0 && printf "$filepath" | xargs --delim='\n' "$0" -r $verbose && continue