From 9d3f243e756dcd94797aefdb11fb478e6cded042 Mon Sep 17 00:00:00 2001 From: Colin P. McCabe Date: Fri, 3 Jun 2022 17:30:08 -0700 Subject: [PATCH] audible-to-mp3.sh: check for mp3splt, use gfind --- audible-to-mp3.sh | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/audible-to-mp3.sh b/audible-to-mp3.sh index 1b2054d..6af8f4a 100755 --- a/audible-to-mp3.sh +++ b/audible-to-mp3.sh @@ -21,6 +21,13 @@ $0: convert Audible .aax files to mp3s. EOF } +# On MacOS, use gfind since AAXtoMP3 needs it. +FIND=find +which gfind &> /dev/null +if [[ $? -eq 0 ]]; then + FIND=gfind +fi + debug=0 while getopts "a:dhi:o:" flag; do case $flag in @@ -37,6 +44,7 @@ shift $((OPTIND-1)) which AAXtoMP3 &> /dev/null || die "Failed to locate AAXtoMP3. Please install it." which audiobooker &> /dev/null || die "Failed to locate audiobooker. Please install it." which tagger.py &> /dev/null || die "Failed to locate tagger.py. Please install it." +which mp3splt &> /dev/null || die "Failed to locate mp3splt. Please install it." [[ -v authcode ]] || die "You must specify the authcode." [[ -v input ]] || die "You must specify the input file." [[ -f "${input}" ]] || die "Not a normal file: ${input}" @@ -57,7 +65,7 @@ AAXtoMP3 --authcode "${authcode}" --single "${tmpdir}/input.aax" # For some reason, AAXtoMP3 doesn't give us much control over the output file name. # Let's find out what it is using the "find" command, and change it to something well-behaved. pushd "${tmpdir}" &> /dev/null || die "failed to pushd ${tmpdir}" -find -name '*.mp3' -type f -print0 | xargs -0 -I{} mv {} "${tmpdir}/input.mp3" +$FIND -name '*.mp3' -type f -print0 | xargs -0 -I{} mv {} "${tmpdir}/input.mp3" popd &> /dev/null [[ $? -eq 0 ]] || die "Failed to locate and move the AAXtoMP3 output." mkdir -p "${tmpdir}/output" || die "failed to create ${tmpdir}/output directory" -- 1.6.6.rc1.39.g9a42