From 35308ccb11e109797d9191b24c818ac4eb0b0833 Mon Sep 17 00:00:00 2001 From: Dewey Hylton Date: Mon, 2 Jul 2018 19:26:15 -0400 Subject: [PATCH 1/2] check for GNU sed, recommend gnu-sed for mac os x if missing --- AAXtoMP3 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index af7e8db..cd9dbef 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -146,6 +146,16 @@ if ! [[ $(type -P "$GREP") ]]; then exit 1 fi +# ----- +# Detect which annoying version of sed we have +SED=$(sed --version 2>&1 | $GREP -q GNU && echo "sed" || echo "gsed") +if ! [[ $(type -P "$SED") ]]; then + echo "$SED (GNU sed) is not in your PATH" + echo "Without it, this script will break." + echo "On macOS, you may want to try: brew install gnu-sed" + exit 1 +fi + # ----- # Detect ffmpeg and ffprobe if [[ "x$(type -P ffmpeg)" == "x" ]]; then @@ -296,7 +306,7 @@ get_metadata_value() { local key key="$1" # Find the key in the meta data file # Extract field value # Remove the following /'s "(Unabridged) at start end and multiples. - echo "$($GREP --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2- | sed -e 's#/##g;s/ (Unabridged)//;s/^[[:blank:]]\+//g;s/[[:blank:]]\+$//g' | sed 's/[[:blank:]]\+/ /g')" + echo "$($GREP --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2- | $SED -e 's#/##g;s/ (Unabridged)//;s/^[[:blank:]]\+//g;s/[[:blank:]]\+$//g' | $SED 's/[[:blank:]]\+/ /g')" } # ----- @@ -325,7 +335,7 @@ do save_metadata "${aax_file}" genre=$(get_metadata_value genre) artist=$(get_metadata_value artist) - title=$(get_metadata_value title | sed 's/'\:'/'-'/g' | sed 's/- /-/g' | xargs -0) + title=$(get_metadata_value title | $SED 's/'\:'/'-'/g' | $SED 's/- /-/g' | xargs -0) if [ "x${targetdir}" != "x" ] ; then output_directory="${targetdir}/${genre}/${artist}/${title}" else From 67a190b0a67f0ef3b8f18b47cd60a73caa1751b3 Mon Sep 17 00:00:00 2001 From: James Hewitt Date: Sun, 22 Jul 2018 21:46:15 +0100 Subject: [PATCH 2/2] Fix bad argument name in usage --- AAXtoMP3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index cd9dbef..91f99a9 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -5,7 +5,7 @@ # Command Line Options # Usage Synopsis. -usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--chaptered]\n[-e:mp3] [-e:m4a] [-e:m4b] [--authcode ]\n[--output_dir ] [--complete_dir ] [--validate]\n{FILES}\n' +usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--chaptered]\n[-e:mp3] [-e:m4a] [-e:m4b] [--authcode ]\n[--target_dir ] [--complete_dir ] [--validate]\n{FILES}\n' codec=libmp3lame # Default encoder. extension=mp3 # Default encoder extention. mode=chaptered # Multi file output