From 71e140259be803f69447737e5b3a15eb7cd85775 Mon Sep 17 00:00:00 2001 From: upuv Date: Mon, 4 Jun 2018 16:10:00 +1000 Subject: [PATCH] Refactor some variables for readability. --- AAXtoMP3 | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index 12b1bd2..a6f9ff3 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -63,6 +63,7 @@ if [ "$#" -eq 0 ]; then exit 1 fi +# Setup safer bash script defaults. set -o errexit -o noclobber -o nounset -o pipefail # ======================================================================== @@ -231,28 +232,28 @@ normalize_whitespace() { # ======================================================================== # Main Transcode Loop -for path +for aax_file do # Check for Presense of Audiobook. Note this break the processing of # of a list of books once a single missing file is found. - if [[ ! -r "${path}" ]] ; then - echo "ERROR: Input Audiobook file $path missing" + if [[ ! -r "${aax_file}" ]] ; then + echo "ERROR: Input Audiobook file $aax_file missing" exit 1 fi # ----- # Make sure everything is a variable. Simplifying Command interpretation - save_metadata "${path}" + 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' | sed 's/- /-/g' | xargs -0) if [ "x${targetdir}" != "x" ] ; then output_directory="${targetdir}/${genre}/${artist}/${title}" else - output_directory="$(dirname "${path}")/${genre}/${artist}/${title}" + output_directory="$(dirname "${aax_file}")/${genre}/${artist}/${title}" fi - full_file_path="${output_directory}/${title}.${extension}" + output_file="${output_directory}/${title}.${extension}" bitrate="$(get_bitrate)k" album_artist="$(get_metadata_value album_artist)" album="$(get_metadata_value album)" @@ -264,26 +265,26 @@ do # Fancy declartion of which book we are decoding. Including the AUTHCODE. dashline="----------------------------------------------------" log "$(printf '\n----Decoding---%s%s--%s--' "${title}" "${dashline:${#title}}" "${auth_code}")" - log "Decoding ${path}" + log "Source ${aax_file}" # Big long DEBUG output. Fully describes the settings used for transcoding. # Not this is a long debug command. It's not critical to operation. It's purely for people debugging # and coders wanting to extend the script. - debug_vars "Book and Variable values" title auth_code mode path container codec bitrate artist album_artist album album_date genre copyright full_file_path metadata_file working_directory + debug_vars "Book and Variable values" title auth_code mode aax_file container codec bitrate artist album_artist album album_date genre copyright output_file metadata_file working_directory # ----- # This is the main work horse command. This is the primary transcoder. # This is the primary transcode. All the heavy lifting is here. -