diff --git a/AAXtoMP3 b/AAXtoMP3 index af7e8db..ffc9bb8 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -210,6 +210,28 @@ if [[ "x${targetdir}" != "x" ]]; then exit 1 fi fi +======= +auth_code=""; +for dir in $authcodeDirs; do + codeFile="${dir}$authcode"; + + if [ ! -f "$codeFile" -o ! -s "$codeFile" ]; then + codeFile="" + echo "INFO: Sorry, missing or empty \"$codeFile\" found, skipping."; + fi; +done; + +if [ ! -f "$codeFile" ]; then + auth_code=$1 + shift +else + auth_code=`head -1 "$codeFile"` +fi + +if [ -z "$auth_code" ]; then + echo "INFO: Sorry, no authcode provided."; + exit 1; +fi; # ----- # Check the target dir for if set if it is writable @@ -448,6 +470,55 @@ do # Detect if we are actuall m4b instead of m4a Then rename the file. if [[ ${extension} == "m4a" && ${container}="m4b" ]]; then mv "${output_file}" "${output_file/.m4a/.m4b}" +======= + 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 | sed 's/'\:'/'\ -'/g' | xargs -0) + output_directory="$(dirname "${path}")/${genre}/${artist}/${title}" + mkdir -p "${output_directory}" + full_file_path="${output_directory}/${title}.${extension}" + +