GitHub github.com
fallback directory if don't match · Issue #3327 · beetbox/beets
Jee Jee
@GitHub

Thank’s for your answer and sorry for my late reply. It’s look like a little bit tricky for me, do you have some example how to do that please ?

After reading this issue https://github.com/beetbox/beets/issues/3444 i’d be more comfortable with an “real” exit code when beets failed to import music skip.

My watch script look like this he run in background in a docker container on my Nas :

#!/bin/bash

beets_dir="/config/beets"
beets_config="/config/config.yaml"
WATCH_DIR="/Incoming/Music"

BEETSDIR=/config
export BEETSDIR
FPCALC=/usr/bin/fpcalc
export FPCALC

inotifywait -m -e create,moved_to --format '%w%f' "$WATCH_DIR" | while IFS= read -r dir_path; do
    /usr/local/bin/beet -c "$beets_config" import -q -i --flat "$dir_path"
done

I might add a condition in the loop after Beets’s job like this (not tested):

#set my variable from beets's exit code
beets_exit_code="$?"

if [ ! "$beets_exit_code = 0 ]
then
   cp -rf "$dir_path" /my/fallback_dir/
  echo "[$date] Not imported  $dir_path" >> $log_file
fi

Another solution i said previously, can be to add a third option custom_script alongside asis or skip for the quiet_fallback “mode” who run script instead of implement code that i would be may be the only one who use it.

#beets #fallback #exit #code #automation #music #import