From 66dc8953ad85a89dd8c2c7ba10a484e0225a5f4d Mon Sep 17 00:00:00 2001 From: upuv Date: Sat, 19 May 2018 23:01:34 +1000 Subject: [PATCH 1/6] Enhanced debug flag. --- AAXtoMP3 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index 0f0490f..8699484 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -12,7 +12,7 @@ targetdir= DEBUG=0 # ----- -# Code tip Do not have any scritp above this point that calls a function or a binary. If you do +# Code tip Do not have any script above this point that calls a function or a binary. If you do # the $1 will no longer be a ARGV element. So you should only do basic variable setting above here. # # Process the command line options. This allows for un-ordered options. Sorta like a getops style @@ -135,9 +135,17 @@ do fi mkdir -p "${output_directory}" full_file_path="${output_directory}/${title}.${extension}" + bitrate="$(get_bitrate)k" + album_artist="$(get_metadata_value album_artist)" + album="$(get_metadata_value album)" + album_date="$(get_metadata_value date)" + copyright="$(get_metadata_value copyright)" + + # Big long DEBUG output. Fully describes the settings used for transcoding. I could probably do this better. + debug "$(printf '\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %s\n%-18s: %sn%-18s: %s' title "${title}" auth_code "${auth_code}" mode "${mode}" path "${path}" codec "${codec}" bitrate "${bitrate}" artist "${artist}" album_artist "${album_artist}" album "${album}" album_date "${album_date}" genre "${genre}" copyright "${copyright}" full_file_path "${full_file_path}" metadata_file "${metadata_file}" working_directory "${working_directory}" )" # This is the primary transcode. All the heavy lifting is here. - Date: Sat, 19 May 2018 23:04:08 +1000 Subject: [PATCH 2/6] Updated .gitignore Attempting to avoid any accidental uploading to github of copyright material that only the user owns. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 71a9d6a..bc3dd24 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ ACTIVATION .authcode +*aax +Audiobook/* From 0efe3fa28e5b4cf95c2db1ed94dc892e0e2505c7 Mon Sep 17 00:00:00 2001 From: upuv Date: Sat, 19 May 2018 23:07:04 +1000 Subject: [PATCH 3/6] Redundant AAXtoMP3 now does this. --- AAXtoM4A | 108 ------------------------------------------------------- 1 file changed, 108 deletions(-) delete mode 100755 AAXtoM4A diff --git a/AAXtoM4A b/AAXtoM4A deleted file mode 100755 index 7288d08..0000000 --- a/AAXtoM4A +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o noclobber -o nounset -o pipefail - -codec=copy -extension=m4a -mode=chaptered -GREP=$(grep --version | grep -q GNU && echo "grep" || echo "ggrep") - -if ! [[ $(type -P "$GREP") ]]; then - echo "$GREP (GNU grep) is not in your PATH" - echo "Without it, this script will break." - echo "On macOS, you may want to try: brew install grep" - exit 1 -fi - -if [ "$#" -eq 0 ]; then - echo "Usage: bash AAXtoM4A [--single] AUTHCODE {FILES}" - exit 1 -fi - -if [[ "$1" == '--single' ]] -then - mode=single - shift -fi - -if [ ! -f .authcode ]; then - auth_code=$1 - shift -else - auth_code=`head -1 .authcode` -fi - -debug() { - echo "$(date "+%F %T%z") ${1}" -} - -trap 'rm -r -f "${working_directory}"' EXIT -working_directory=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'` -metadata_file="${working_directory}/metadata.txt" - -save_metadata() { - local media_file - media_file="$1" - ffprobe -i "$media_file" 2> "$metadata_file" -} - -get_metadata_value() { - local key - key="$1" - normalize_whitespace "$($GREP --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2- | sed -e 's#/##g;s/ (Unabridged)//' | tr -s '[:blank:]' ' ')" -} - -get_bitrate() { - get_metadata_value bitrate | $GREP --only-matching '[0-9]\+' -} - -normalize_whitespace() { - echo $* -} - -for path -do - debug "Decoding ${path} with auth code ${auth_code}..." - - save_metadata "${path}" - genre=$(get_metadata_value genre) - artist=$(get_metadata_value artist) - title=$(get_metadata_value title) - output_directory="$(dirname "${path}")/${genre}/${artist}/${title}" - mkdir -p "${output_directory}" - full_file_path="${output_directory}/${title}.${extension}" - - Date: Sat, 19 May 2018 23:08:11 +1000 Subject: [PATCH 4/6] Nuked redundant m4a script --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index eab30e6..6fe3af4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# AAXtoMP3 AAXtoM4A AAxtoM4B +# AAXtoMP3 AAxtoM4B The purpose of this software is to convert AAX files to common MP3, M4A and M4B formats through a basic bash script frontend to FFMPEG. @@ -32,7 +32,6 @@ Thanks to kbabioch, this script has also been packaged in the [AUR](https://aur. ## Usage(s) ``` bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [-A|--authcode ] [-o|--output_dir ] ... -bash AAXtoM4A [AUTHCODE] ... bash AAXtoM4B [AUTHCODE] ... ``` From 2ac1ba67ec892b377c37b085809f879cb13b38bb Mon Sep 17 00:00:00 2001 From: upuv Date: Sat, 19 May 2018 23:09:38 +1000 Subject: [PATCH 5/6] remove redundant AAXtoM4A --- AAXtoM4A | 108 ------------------------------------------------------- 1 file changed, 108 deletions(-) delete mode 100755 AAXtoM4A diff --git a/AAXtoM4A b/AAXtoM4A deleted file mode 100755 index 7288d08..0000000 --- a/AAXtoM4A +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o noclobber -o nounset -o pipefail - -codec=copy -extension=m4a -mode=chaptered -GREP=$(grep --version | grep -q GNU && echo "grep" || echo "ggrep") - -if ! [[ $(type -P "$GREP") ]]; then - echo "$GREP (GNU grep) is not in your PATH" - echo "Without it, this script will break." - echo "On macOS, you may want to try: brew install grep" - exit 1 -fi - -if [ "$#" -eq 0 ]; then - echo "Usage: bash AAXtoM4A [--single] AUTHCODE {FILES}" - exit 1 -fi - -if [[ "$1" == '--single' ]] -then - mode=single - shift -fi - -if [ ! -f .authcode ]; then - auth_code=$1 - shift -else - auth_code=`head -1 .authcode` -fi - -debug() { - echo "$(date "+%F %T%z") ${1}" -} - -trap 'rm -r -f "${working_directory}"' EXIT -working_directory=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'` -metadata_file="${working_directory}/metadata.txt" - -save_metadata() { - local media_file - media_file="$1" - ffprobe -i "$media_file" 2> "$metadata_file" -} - -get_metadata_value() { - local key - key="$1" - normalize_whitespace "$($GREP --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2- | sed -e 's#/##g;s/ (Unabridged)//' | tr -s '[:blank:]' ' ')" -} - -get_bitrate() { - get_metadata_value bitrate | $GREP --only-matching '[0-9]\+' -} - -normalize_whitespace() { - echo $* -} - -for path -do - debug "Decoding ${path} with auth code ${auth_code}..." - - save_metadata "${path}" - genre=$(get_metadata_value genre) - artist=$(get_metadata_value artist) - title=$(get_metadata_value title) - output_directory="$(dirname "${path}")/${genre}/${artist}/${title}" - mkdir -p "${output_directory}" - full_file_path="${output_directory}/${title}.${extension}" - - Date: Sat, 19 May 2018 23:35:11 +1000 Subject: [PATCH 6/6] Added big FAT metadata to DEBUG output. --- AAXtoMP3 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/AAXtoMP3 b/AAXtoMP3 index 8699484..a09b107 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -83,6 +83,16 @@ debug() { fi } +# debug dump contents of a file to STDOUT +debug_file() { + if [ $DEBUG == 1 ] ; then + echo "$(date "+%F %T%z") DEBUG" + echo "================================================================================" + cat "${1}" + echo "================================================================================" + fi +} + # log log() { echo "$(date "+%F %T%z") ${1}" @@ -96,6 +106,8 @@ save_metadata() { local media_file media_file="$1" ffprobe -i "$media_file" 2> "$metadata_file" + debug "Metadata file $metadata_file" + debug_file "$metadata_file" } get_metadata_value() {