From 9f34fe4a8aff1b2fe42ebed559aaa391e20f05f8 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Fri, 13 Aug 2021 15:05:18 -0400 Subject: [PATCH] Get audiobook title --- audible-converter.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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