shell/music: update playlist dir
This commit is contained in:
parent
de874c9604
commit
cf33fa7b79
5 changed files with 21 additions and 17 deletions
|
@ -1,25 +1,20 @@
|
|||
export AUDIO="$DATA/audio"
|
||||
MUSIC_RAW="$AUDIO/songs/_raw"
|
||||
|
||||
alias scbra='scpr zebra "/srv/funkwhale/data/music${PWD/$MUSIC}"'
|
||||
# See also scripts/pl
|
||||
|
||||
# Finds common music files in the current directory, optionally taking a regex
|
||||
findsongs() {
|
||||
find -regextype posix-extended -maxdepth 1 -type f \
|
||||
-iregex "${1:-.*\.(mp3|flac|wav|m4a)}" -printf "%P\n"
|
||||
}
|
||||
|
||||
addtopl() {
|
||||
pl=$1
|
||||
shift
|
||||
playlists=$MUSIC/Playlists
|
||||
realpath --relative-to $playlists "$@" | tee -a $playlists/$pl*
|
||||
}
|
||||
|
||||
addmix() {
|
||||
AUDIO="$DATA/audio"
|
||||
mv -v "$1.cue" "$AUDIO/recordings/cues"
|
||||
addsong "$1.flac" Mixes
|
||||
}
|
||||
|
||||
# Used to keep music directory small, pretty much obsolete now
|
||||
MUSIC_RAW="$d4/songs/_raw"
|
||||
|
||||
addsong() {
|
||||
test "$1" = "-q" && shift && quick="true"
|
||||
|
||||
|
@ -41,6 +36,7 @@ addsong() {
|
|||
test ! "$PWD" -ef "$MUSIC_RAW/$2" && mv -v "$raw.flac" "$MUSIC_RAW/$2" && (test "$isflac" || rm -v "$1")
|
||||
}
|
||||
|
||||
# Execute inside an album folder with the desired target path
|
||||
addalbum() {
|
||||
mkdir -p "$MUSIC/$1"
|
||||
mkdir -p "$MUSIC_RAW/$1"
|
||||
|
@ -86,8 +82,10 @@ updatemusic() {
|
|||
formatsongs() {
|
||||
(
|
||||
find -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | formatin
|
||||
find "$@" "$PWD" -type d | while read d;
|
||||
find "${@:-$PWD}" -type d | while read d;
|
||||
do builtin cd "$d" && findsongs | formatin
|
||||
test $(find -maxdepth 1 -name '01 *' | wc -l) -gt 1 -a $(find -maxdepth 1 -name '02 *' | wc -l) -eq 0 &&
|
||||
zmv -W '01 *' '*'
|
||||
done
|
||||
)
|
||||
# fd --no-ignore-vcs --type f --extension opus --exec opusdec --quiet "{}" "{.}.wav" \; ".*" "$@"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# args: either a playlist file name, or a list of terms which all have to match
|
||||
# TODO fails on "Alchemy"
|
||||
# TODO implement finding by tags
|
||||
PLAYLISTS="${PLAYLISTS:-$MUSIC/Playlists}"
|
||||
PLAYLISTS="${PLAYLISTS:-$MUSIC/playlists}"
|
||||
mpc -q clear || mpdr
|
||||
if test -z "$1"
|
||||
then mp -q "$PLAYLISTS/focus.m3u"
|
||||
|
|
|
@ -4,9 +4,15 @@
|
|||
# depends: xargs realpath mpc
|
||||
# env: MUSIC
|
||||
# TODO auto-convert unknown types with ffmpeg to flac rather than linking (wav, opus, ...)
|
||||
if test $# -eq 0
|
||||
then echo "Usage: $0 [files...]"
|
||||
mpdr
|
||||
mpc play
|
||||
exit 0
|
||||
fi
|
||||
MPD_CONF=${XDG_CONFIG_HOME:-$HOME/.config}/mpd/mpd.conf
|
||||
MUSIC="${MUSIC:-$(cat $MPD_CONF | grep music_directory | cut -d'"' -f2 | sed "s|~|$HOME|")}"
|
||||
PLAYLISTS="$(cat $MPD_CONF | grep playlist_directory | cut -d'"' -f2 | sed "s|~|$HOME|" || echo "$MUSIC/Playlists")"
|
||||
PLAYLISTS="$(cat $MPD_CONF | grep playlist_directory | cut -d'"' -f2 | sed "s|~|$HOME|" || echo "$MUSIC/playlists")"
|
||||
LINKS="$MUSIC/.links"
|
||||
if test "$1" = "-r"
|
||||
then shift
|
||||
|
@ -16,7 +22,7 @@ then shift
|
|||
do
|
||||
matchname="$(basename -- "$arg" | sed 's|\(\[.*\)\]|\\\1\\]|;s|\?|\\?|')"
|
||||
filepath="$({ find "$(dirname -- "$arg")" -maxdepth 1 -name "$matchname" -exec realpath {} + ||
|
||||
find "$(dirname -- "$arg")" "$MUSIC/$(dirname -- "$arg")" "$MUSIC/Playlists/$(dirname -- "$arg")" -maxdepth 1 \
|
||||
find "$(dirname -- "$arg")" "$MUSIC/$(dirname -- "$arg")" "$PLAYLISTS/$(dirname -- "$arg")" -maxdepth 1 \
|
||||
-name "$matchname*" -exec realpath {} +; } 2>/dev/null)"
|
||||
test -n "$verbose" && echo "Scanning path '$filepath' $(
|
||||
test "$arg" != "$filepath" && echo "from '$arg' ")(MUSIC: '$MUSIC', PWD: '$PWD')" >&2
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh -e
|
||||
# Reload mpd with appropriate config
|
||||
yadm alt
|
||||
cd $XDG_CONFIG_HOME/mpd
|
||||
cd ${XDG_CONFIG_HOME:-/home/janek/.config}/mpd
|
||||
mv *template ..
|
||||
mv ../*template .
|
||||
systemctl --user restart mpd
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh -e
|
||||
# MPC add file to queue
|
||||
# Add file to mpd queue
|
||||
for arg
|
||||
do fullpath=$(realpath "$arg")
|
||||
mpc insert "${fullpath/$MUSIC\//}"
|
||||
|
|
Loading…
Add table
Reference in a new issue