diff --git a/to-m4b.sh b/to-m4b.sh index f71e395..658765f 100644 --- a/to-m4b.sh +++ b/to-m4b.sh @@ -8,18 +8,12 @@ declare -r script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # VARS LEADING_ZEROES=2 -SRC="${SRC:${script_dir}/src}" -OUT="${OUT:${script_dir}/out}" -AUTHOR="${AUTHOR:-}" -NARRATOR="${NARRATOR:-}" -TITLE="${TITLE:-}" -YEAR="${YEAR:-}" -SERIES="${SERIES:-}" -SERIES_INDEX="${SERIES_INDEX:-}" +MAIN_SRC="${SRC:${script_dir}/src}" +MAIN_OUT="${OUT:${script_dir}/out}" # FUNCTIONS parse-vars() { - # TODO implement parsing the directory structure to fill in missing vars and return them + # TODO implement parsing the directory structure of the passed directory, to fill in missing vars and return them # Series structure: ${SRC}///Book - - {}/ # Standalone structure: ${SRC}// - {}/ # Return the wihh leading zeros based on the LEADING_ZEROES variable @@ -61,13 +55,7 @@ m4b-merge() { } main() { - parse-vars - local book_dirs - IFS=$'\n' read -r -d '' -a book_dirs < <(get-book-directories && printf '\0') - for book_dir in "${book_dirs[@]}"; do - local book_output_file="${OUT}/${AUTHOR}/${(SERIES:+${SERIES}/)}${(SERIES:+Book ${SERIES_INDEX} - )}${YEAR} - ${TITLE}.m4b" - m4b-merge "${LEADING_ZEROES}" "${book_output_file}" "${book_dir}" "${AUTHOR}" "${NARRATOR}" "${TITLE}" "${YEAR}" "${SERIES}" "${SERIES_INDEX}" - done + } -main "$@" \ No newline at end of file +main "$@"