diff --git a/audible-converter.sh b/audible-converter.sh index 5fa0d49..5eb1340 100755 --- a/audible-converter.sh +++ b/audible-converter.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +cleanString() { + tr -d '"' +} + # getHash returns the hash of a given file. function getHash() { echo $(xxd -p -l20 -s 653 ${1}) @@ -8,7 +12,7 @@ function getHash() { # getActivationBytes returns the bytes needed to decrypt a given hash. function getActivationBytes() { json=$(curl -A 'audible-converter' https://aax.api.j-kit.me/api/v2/activation/${1}) - echo $(echo $json | jq '.activationBytes' | tr -d '"') + echo $(echo $json | jq '.activationBytes' | cleanString) } # createConfig creates a config file. @@ -39,7 +43,7 @@ function getMetadataJSON() { } function getTitle() { - echo $(echo ${1} | jq '.title') + echo $(echo ${1} | jq '.title' | cleanString) } settingsFile='./settings.conf' @@ -58,4 +62,8 @@ fi metadataJSON=$(getMetadataJSON $audibleFile) json=$(getMetadataJSON $audibleFile) -removeDRM $audibleFile $activationBytes +getTitle "${json}" + +if [ ! -f "$(basename ${audibleFile} | cut -f 1 -d '.').m4b" ]; then + removeDRM $audibleFile $activationBytes +fi