Merge branch 'append-narrator' of github.com:fabh2o/AAXtoMP3 into audible-cli-integration

This commit is contained in:
fabh2o 2021-02-06 18:51:01 +01:00
commit 0972886b58
2 changed files with 18 additions and 4 deletions

View File

@ -5,7 +5,7 @@
# Command Line Options # Command Line Options
# Usage Synopsis. # Usage Synopsis.
usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--level <COMPRESSIONLEVEL>]\n[--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [--authcode <AUTHCODE>] [--no-clobber]\n[--target_dir <PATH>] [--complete_dir <PATH>] [--validate]\n[--continue <CHAPTERNUMBER>]{FILES}\n' usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--level <COMPRESSIONLEVEL>]\n[--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [--authcode <AUTHCODE>] [--no-clobber]\n[--target_dir <PATH>] [--complete_dir <PATH>] [--validate] [--append-narrator]\n[--continue <CHAPTERNUMBER>]{FILES}\n'
codec=libmp3lame # Default encoder. codec=libmp3lame # Default encoder.
extension=mp3 # Default encoder extension. extension=mp3 # Default encoder extension.
level=-1 # Compression level. Can be given for mp3, flac and opus. -1 = default/not specified. level=-1 # Compression level. Can be given for mp3, flac and opus. -1 = default/not specified.
@ -20,6 +20,7 @@ noclobber=0 # Default off, clobber only if flag is enabled
continue=0 # Default off, If set Transcoding is skipped and chapter splitting starts at chapter continueAt. continue=0 # Default off, If set Transcoding is skipped and chapter splitting starts at chapter continueAt.
continueAt=1 # Optional chapter to continue splitting the chapters. continueAt=1 # Optional chapter to continue splitting the chapters.
audibleCli=0 # Default off, Use additional data gathered from mkb79/audible-cli audibleCli=0 # Default off, Use additional data gathered from mkb79/audible-cli
appendNarrator=0 # Default off, Append the narrator name to the Folder name. Needs mediainfo
# ----- # -----
# Code tip Do not have any script above this point that calls a function or a binary. If you do # Code tip Do not have any script above this point that calls a function or a binary. If you do
@ -62,6 +63,8 @@ while true; do
--use-audible-cli-data ) audibleCli=1; shift ;; --use-audible-cli-data ) audibleCli=1; shift ;;
# Compression level # Compression level
--level ) level="$2"; shift 2 ;; --level ) level="$2"; shift 2 ;;
# Append Narrator
--append-narrator ) appendNarrator=1; shift ;;
# Command synopsis. # Command synopsis.
-h | --help ) printf "$usage" $0 ; exit ;; -h | --help ) printf "$usage" $0 ; exit ;;
# Standard flag signifying the end of command line processing. # Standard flag signifying the end of command line processing.
@ -144,7 +147,7 @@ log() {
# ----- # -----
# Print out what we have already after command line processing. # Print out what we have already after command line processing.
debug_vars "Command line options as set" codec extension mode container targetdir completedir auth_code audibleCli debug_vars "Command line options as set" codec extension mode container targetdir completedir auth_code appendNarrator audibleCli
# ======================================================================== # ========================================================================
# Variable validation # Variable validation
@ -297,6 +300,13 @@ if [ "${level}" != "-1" ]; then
fi fi
fi fi
# -----
# Check for presence of mediainfo in case the flag --append-narrator is used
if [[ "${appendNarrator}" == 1 && "x$(type -P mediainfo)" == "x" ]]; then
echo "ERROR --append-narator specified, but mediainfo is not in PATH"
exit 1
fi
# ----- # -----
# Clean up if someone hits ^c or the script exits for any reason. # Clean up if someone hits ^c or the script exits for any reason.
trap 'rm -r -f "${working_directory}"' EXIT trap 'rm -r -f "${working_directory}"' EXIT
@ -494,7 +504,11 @@ do
description="" description=""
publisher="" publisher=""
fi fi
# If the flag --append-narrator is used, we append the narrator name to the output dir
if [[ "${appendNarrator}" == 1 ]]; then
output_directory="${output_directory}"-"${narrator}"
output_file="${output_directory}/${title}.${extension}"
fi
if [[ "${noclobber}" = "1" ]] && [[ -d "${output_directory}" ]]; then if [[ "${noclobber}" = "1" ]] && [[ -d "${output_directory}" ]]; then
log "Noclobber enabled but directory '${output_directory}' exists. Exiting to avoid overwriting" log "Noclobber enabled but directory '${output_directory}' exists. Exiting to avoid overwriting"
exit 0 exit 0

View File

@ -51,9 +51,9 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level <COMPRESS
* **-c** or **--chaptered** Output a single file per chapter. The `--chaptered` will only work if it follows the `--aac -e:m4a -e:m4b --flac` options. * **-c** or **--chaptered** Output a single file per chapter. The `--chaptered` will only work if it follows the `--aac -e:m4a -e:m4b --flac` options.
* **--continue &lt;CHAPTERNUMBER&gt;** If the splitting into chapters gets interrupted (e.g. by a weak battery on your laptop) you can go on where the process got interrupted. Just delete the last chapter (which was incompletely generated) and redo the task with "--continue &lt;CHAPTERNUMBER&gt;" where CHAPTERNUMBER is the chapter that got interrupted. * **--continue &lt;CHAPTERNUMBER&gt;** If the splitting into chapters gets interrupted (e.g. by a weak battery on your laptop) you can go on where the process got interrupted. Just delete the last chapter (which was incompletely generated) and redo the task with "--continue &lt;CHAPTERNUMBER&gt;" where CHAPTERNUMBER is the chapter that got interrupted.
* **--level &lt;COMPRESSIONLEVEL&gt;** Set compression level. May be given for mp3, flac and opus. * **--level &lt;COMPRESSIONLEVEL&gt;** Set compression level. May be given for mp3, flac and opus.
* **--append-narrator** Append narrator name to the destination folder, useful if you have multiple version of a book. Requires mediainfo.
* **--use-audible-cli-data** Use additional data got with mkb79/audible-cli. See [below](#audible-cli-integration) for more infos. * **--use-audible-cli-data** Use additional data got with mkb79/audible-cli. See [below](#audible-cli-integration) for more infos.
### [AUTHCODE] ### [AUTHCODE]
**Your** Audible auth code (it won't correctly decode otherwise) (required). **Your** Audible auth code (it won't correctly decode otherwise) (required).