From 3d8f7c619c493ba2ae1872191b92e926ab39705e Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 14 Jun 2018 19:59:32 +0200 Subject: [PATCH] Fixed empty parameter bug --- AAXtoMP3 | 22 +++---- AAXtoMP3Worker | 152 +++++++++++++++++++++++++++---------------------- printparams | 21 +++++++ 3 files changed, 114 insertions(+), 81 deletions(-) create mode 100644 printparams diff --git a/AAXtoMP3 b/AAXtoMP3 index 61afd45..82816cb 100644 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -72,32 +72,33 @@ do if [[ "$var" = '--flac' ]] then - flac='--flac' + flac='--flac ' shift fi if [[ "$var" == '--aac' ]] then aac='--aac' - single='--single' + single='--single ' shift fi if [[ "$var" = '--opus' ]] then - opus='--opus' + opus='--opus ' shift fi if [[ "$var" == '--single' ]] then - single='--single' + single='--single ' shift fi case "$var" in -a=*|--auth=*) - auth="${var#*=}"; + auth=$(echo $var | cut -d '=' -f 2) + shift esac done @@ -112,13 +113,6 @@ for dir in $authcodeDirs; do fi; done; -if [ ! -f "$codeFile" ]; then - auth_code=$1 - shift -else - auth_code=`head -1 "$codeFile"` -fi - if [ -z "$auth_code" ]; then auth_code="$auth"; fi; @@ -142,7 +136,9 @@ metadata_file="${working_directory}/metadata.txt" #if [ -z "$multi_thread" ]; then for path do - bash AAXtoMP3Worker "${flac}" "${aac}" "${opus}" "${single}" "${path}" "--auth=${auth_code}" + echo bash AAXtoMP3Worker "${flac}""${aac}""${opus}""${single}""--auth=${auth_code}" "${path}" + bash AAXtoMP3Worker "${flac}" "${aac}" "${opus}" "${single}" "--auth=${auth_code}" "${path}" + echo "running away..." done exit 0; #fi; diff --git a/AAXtoMP3Worker b/AAXtoMP3Worker index 4c74f6c..8a7e7b2 100644 --- a/AAXtoMP3Worker +++ b/AAXtoMP3Worker @@ -58,10 +58,22 @@ if [[ "$1" = '--help' ]]; then fi -#Iterate over the parameter to find all entered ones + +ParamArray=() +#the multithreadcontroller adds whitespaces to the params, they are removed here. for var in "$@" do - + if ! [[ "$var" = '' ]] + then + ParamArray+=("$var") + fi +done + + +#Iterate over the parameter to find all entered ones +for var in "${ParamArray[@]}" +do + if [[ "$var" = '--flac' ]] then codec=flac @@ -92,11 +104,11 @@ do case "$var" in -a=*|--auth=*) - auth="${var#*=}"; + auth=$(echo $var | cut -d '=' -f 2) + shift esac done - auth_code=""; for dir in $authcodeDirs; do codeFile="${dir}$authcode"; @@ -107,10 +119,7 @@ for dir in $authcodeDirs; do fi; done; -if [ ! -f "$codeFile" ]; then - auth_code=$1 - shift -else +if [ -f "$codeFile" ]; then auth_code=`head -1 "$codeFile"` fi @@ -151,64 +160,71 @@ normalize_whitespace() { echo $* } -create_path(){ - debug "Decoding $1 with auth code $2..." - - save_metadata "$1" - genre=$(get_metadata_value genre) - artist=$(get_metadata_value artist) - title=$(get_metadata_value title | sed 's/'\:'/'\ -'/g' | xargs -0) - output_directory="$(dirname "$1")/${genre}/${artist}/${title}" - mkdir -p "${output_directory}" - full_file_path="${output_directory}/${title}.${extension}" - -