fix tmp_chapter_file: unbound variable

This commit is contained in:
fabh2o 2021-09-28 19:56:14 +02:00
parent f1c4b97bc1
commit bf1f384341

View File

@ -394,13 +394,6 @@ trap 'rm -r -f "${working_directory}"' EXIT
# Set up some basic working files ASAP. Note the trap will clean this up no matter what.
working_directory=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`
metadata_file="${working_directory}/metadata.txt"
# Creating a temp file to store the chapter data collected in save_metadata, as the output
# folder will only be defined after save_metadata has been executed.
# This file is only required when using audible-cli data and executing in single mode to
# get proper chapter titles in single file m4b output.
if [[ "${audibleCli}" == "1" && "${mode}" == "single" ]] ; then
tmp_chapter_file="${working_directory}/chapter.txt"
fi
# -----
# Validate the AAX and extract the metadata associated with the file.
@ -534,6 +527,11 @@ save_metadata() {
# chapter titles from the .json generated by audiblecli and store
# them correctly formatted for mp4chaps in a chapter.txt
if [ "${mode}" == "single" ]; then
# Creating a temp file to store the chapter data collected in save_metadata, as the output
# folder will only be defined after save_metadata has been executed.
# This file is only required when using audible-cli data and executing in single mode to
# get proper chapter titles in single file m4b output.
tmp_chapter_file="${working_directory}/chapter.txt"
jq -r \
'def pad(n): tostring | if (n > length) then ((n - length) * "0") + . else . end;
.content_metadata.chapter_info.chapters |