From b7e978c8bbc7f23ae00c0370576cd1c8a382e23e Mon Sep 17 00:00:00 2001 From: fabh2o Date: Thu, 4 Feb 2021 13:45:42 +0100 Subject: [PATCH] better HQ cover processing --- AAXtoMP3 | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index 3fcc16a..4577c86 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -324,7 +324,7 @@ validate_aax() { } validate_extra_files() { - local extra_media_file extra_title extra_chapter_file + local extra_media_file # extra_title extra_chapter_file extra_media_file="$1" # Bash trick to delete, non greedy, from the end up until the first '-' extra_title="${extra_media_file%-*}" @@ -336,16 +336,23 @@ validate_extra_files() { # Chapter file: BookTitle-chapters.json extra_chapter_file="${extra_title}-chapters.json" - debug_vars "Audible-cli files" extra_media_file extra_title extra_chapter_file # Test for chapter file existence if [[ ! -r "${extra_chapter_file}" ]] ; then log "ERROR File NOT Found: ${extra_chapter_file}" return 1 fi + + extra_find_command='find -maxdepth 1 -regex ".*/${extra_title}_([0-9]+)\.jpg"' + # extra_cover_file="$(find -maxdepth 1 -regex \".*/${extra_title}_\(\[\0\-\9\]\+\)\\.jpg\")" - # Test for cover art existence (any resolution) - if [[ ! $(find -maxdepth 1 -regex ".*/${extra_title}_([0-9]+)\\.jpg") ]]; then + # We want the output of the find command, we will turn errexit on later + set +e errexit + extra_cover_file="$(eval ${extra_find_command})" + set -e errexit + + debug_vars "Audible-cli files" extra_media_file extra_title extra_chapter_file extra_cover_file + if [[ "x${extra_cover_file}" == "x" ]] ; then log "ERROR Cover File NOT Found" return 1 fi @@ -479,9 +486,20 @@ do fi # Grab the cover art if available. cover_file="${output_directory}/cover.jpg" + extra_crop_cover='' if [ "${continue}" == "0" ]; then - log "Extracting cover into ${cover_file}..." - ${chapternum}))" = "0" ]; then # Extract chapter by time stamps start and finish of chapter. # This extracts based on time stamps start and end. log "Splitting chapter ${chapternum}/${chaptercount} start:${chapter_start%?}(s) end:${chapter_end}(s)" -