Adding --complete_dir option and documentation

This commit is contained in:
upuv 2018-06-03 15:34:56 +10:00
parent 1727d10be3
commit 8327f15ac2
2 changed files with 40 additions and 19 deletions

View File

@ -5,14 +5,15 @@
# Command Line Options # Command Line Options
# Usage Synopsis. # Usage Synopsis.
usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--chaptered]\n[-e:m4a] [-e:m4b] [--authcode <AUTHCODE>] [--output_dir <PATH>] {FILES}\n' usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--chaptered]\n[-e:m4a] [-e:m4b] [--authcode <AUTHCODE>] [--output_dir <PATH>]\n[--complete_dir <PATH>] {FILES}\n'
codec=libmp3lame # Default encoder. codec=libmp3lame # Default encoder.
extension=mp3 # Default encoder extention. extension=mp3 # Default encoder extention.
mode=chaptered # Multi file output mode=chaptered # Multi file output
auth_code= # Required to be set via file or option. auth_code= # Required to be set via file or option.
targetdir= # Optional output location. Note default is basedir of AAX file. targetdir= # Optional output location. Note default is basedir of AAX file.
DEBUG=0 # Default off, If set extremely verbose output. completedir= # Optional location to move aax files once the decoding is complete.
container=mp3 # Just in case we need to change the container. Used for M4A to M4B container=mp3 # Just in case we need to change the container. Used for M4A to M4B
DEBUG=0 # Default off, If set extremely verbose output.
# ----- # -----
# 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
@ -39,6 +40,8 @@ while true; do
-e:m4b ) codec=copy; extension=m4a; mode=single; container=m4b; shift ;; -e:m4b ) codec=copy; extension=m4a; mode=single; container=m4b; shift ;;
# Change the working dir from AAX directory to what you choose. # Change the working dir from AAX directory to what you choose.
-t | --target_dir ) targetdir="$2"; shift 2 ;; -t | --target_dir ) targetdir="$2"; shift 2 ;;
# Move the AAX file to a new directory when decoding is complete.
-C | --complete_dir ) completedir="$2"; shift 2 ;;
# Authorization code associate with the AAX file(s) # Authorization code associate with the AAX file(s)
-A | --authcode ) auth_code="$2"; shift 2 ;; -A | --authcode ) auth_code="$2"; shift 2 ;;
# Extremely verbose output. # Extremely verbose output.
@ -108,7 +111,17 @@ fi
# Check the target dir for if set if it is writable # Check the target dir for if set if it is writable
if [[ "x${targetdir}" != "x" ]]; then if [[ "x${targetdir}" != "x" ]]; then
if [[ ! -w "${targetdir}" || ! -d "${targetdir}" ]] ; then if [[ ! -w "${targetdir}" || ! -d "${targetdir}" ]] ; then
echo "ERROR Target Directory is not writable: \"$targetdir\"" echo "ERROR Target Directory does not exist or is not writable: \"$targetdir\""
echo "$usage"
exit 1
fi
fi
# -----
# Check the target dir for if set if it is writable
if [[ "x${completedir}" != "x" ]]; then
if [[ ! -w "${completedir}" || ! -d "${completedir}" ]] ; then
echo "ERROR Complete Directory does not exist or is not writable: \"$completedir\""
echo "$usage" echo "$usage"
exit 1 exit 1
fi fi
@ -257,7 +270,6 @@ do
chapter_title="${title}-$(printf %0${#chaptercount}d $chapternum) ${chapter}" chapter_title="${title}-$(printf %0${#chaptercount}d $chapternum) ${chapter}"
chapter_file="${output_directory}/${chapter_title}.${extension}" chapter_file="${output_directory}/${chapter_title}.${extension}"
# the ID3 tags must only be specified for *.mp3 files, # the ID3 tags must only be specified for *.mp3 files,
# the other container formats come with their own # the other container formats come with their own
# tagging mechanisms. # tagging mechanisms.
@ -322,4 +334,12 @@ do
log "Done ${title}" log "Done ${title}"
# Lastly get rid of any extra stuff. # Lastly get rid of any extra stuff.
rm "${metadata_file}" rm "${metadata_file}"
# Move the aax file if the decode is completed and the --complete_dir is set to a valid location.
# Check the target dir for if set if it is writable
if [[ "x${completedir}" != "x" ]]; then
log "Moving Transcoded ${path} to ${completedir}"
mv "${path}" "${completedir}"
fi
done done

View File

@ -28,7 +28,7 @@ Thanks to kbabioch, this script has also been packaged in the [AUR](https://aur.
## Usage(s) ## Usage(s)
``` ```
bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [-c|--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [-A|--authcode <AUTHCODE>] [-t|--target_dir <PATH>] [-d|--debug] [-h|--help] <AAX INPUT_FILES>... bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [-c|--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [-A|--authcode <AUTHCODE>] [-t|--target_dir <PATH>] [-C|--complete_dir <PATH>] [-d|--debug] [-h|--help] <AAX INPUT_FILES>...
``` ```
* **&lt;AAX INPUT_FILES&gt;**... are considered input file(s), useful for batching! * **&lt;AAX INPUT_FILES&gt;**... are considered input file(s), useful for batching!
@ -39,6 +39,7 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [-c|--chaptered] [
* **-a** or **--aac** AAC Encoding and produce a m4a single files output. * **-a** or **--aac** AAC Encoding and produce a m4a single files output.
* **-A** or **--authcode &lt;AUTHCODE&gt;** for this execution of the command use the provided &lt;AUTHCODE&gt; to decode the AAX file. * **-A** or **--authcode &lt;AUTHCODE&gt;** for this execution of the command use the provided &lt;AUTHCODE&gt; to decode the AAX file.
* **-t** or **--target_dir &lt;PATH&gt;** change the default output location to the named &lt;PATH&gt;. Note the default location is ./Audiobook of the directory to which each AAX file resides. * **-t** or **--target_dir &lt;PATH&gt;** change the default output location to the named &lt;PATH&gt;. Note the default location is ./Audiobook of the directory to which each AAX file resides.
* **-C** or **--complete_dir &lt;PATH&gt;** a directory to place aax files after they have been decoded successfully. Note make a back up of your aax files prior to using this option. Just in case something goes wrong.
* **-e:mp3** Identical to defaults. * **-e:mp3** Identical to defaults.
* **-e:m4a** Create a m4a audio file. This is identical to --aac * **-e:m4a** Create a m4a audio file. This is identical to --aac
* **-e:m4b** Create a m4b aduio file. This is the book version of the m4a format. * **-e:m4b** Create a m4b aduio file. This is the book version of the m4a format.