Get audiobook title

This commit is contained in:
Christian Colglazier 2021-08-13 15:05:18 -04:00
parent dce5236b1f
commit 9f34fe4a8a

View File

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