mirror of
https://github.com/KrumpetPirate/AAXtoMP3.git
synced 2024-11-17 18:58:58 +01:00
Adding --complete_dir option and documentation
This commit is contained in:
parent
1727d10be3
commit
8327f15ac2
56
AAXtoMP3
56
AAXtoMP3
@ -5,14 +5,15 @@
|
||||
# Command Line Options
|
||||
|
||||
# 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.
|
||||
extension=mp3 # Default encoder extention.
|
||||
mode=chaptered # Multi file output
|
||||
auth_code= # Required to be set via file or option.
|
||||
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
|
||||
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
|
||||
@ -22,33 +23,35 @@ container=mp3 # Just in case we need to change the container. Use
|
||||
while true; do
|
||||
case "$1" in
|
||||
# Flac encoding
|
||||
-f | --flac ) codec=flac; extension=flac; mode=single; container=flac; shift ;;
|
||||
-f | --flac ) codec=flac; extension=flac; mode=single; container=flac; shift ;;
|
||||
# Apple m4a music format.
|
||||
-a | --aac ) codec=copy; extension=m4a; mode=single; container=m4a; shift ;;
|
||||
-a | --aac ) codec=copy; extension=m4a; mode=single; container=m4a; shift ;;
|
||||
# Ogg Format
|
||||
-o | --opus ) codec=libopus; extension=ogg; container=flac; shift ;;
|
||||
-o | --opus ) codec=libopus; extension=ogg; container=flac; shift ;;
|
||||
# If appropriate use only a single file output.
|
||||
-s | --single ) mode=single; shift ;;
|
||||
-s | --single ) mode=single; shift ;;
|
||||
# If appropriate use only a single file output.
|
||||
-c | --chaptered ) mode=chaptered; shift ;;
|
||||
-c | --chaptered ) mode=chaptered; shift ;;
|
||||
# This is the same as --single option.
|
||||
-e:mp3 ) codec=libmp3lame; extension=mp3; mode=single; container=mp3; shift ;;
|
||||
-e:mp3 ) codec=libmp3lame; extension=mp3; mode=single; container=mp3; shift ;;
|
||||
# Identical to --acc option.
|
||||
-e:m4a ) codec=copy; extension=m4a; mode=single; container=m4a; shift ;;
|
||||
-e:m4a ) codec=copy; extension=m4a; mode=single; container=m4a; shift ;;
|
||||
# Similiar to --aac but specific to audio books
|
||||
-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.
|
||||
-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)
|
||||
-A | --authcode ) auth_code="$2"; shift 2 ;;
|
||||
-A | --authcode ) auth_code="$2"; shift 2 ;;
|
||||
# Extremely verbose output.
|
||||
-d | --debug ) DEBUG=1; shift ;;
|
||||
-d | --debug ) DEBUG=1; shift ;;
|
||||
# Command synopsis.
|
||||
-h | --help ) printf "$usage" $0 ; exit ;;
|
||||
-h | --help ) printf "$usage" $0 ; exit ;;
|
||||
# Standard flag signifying the end of command line processing.
|
||||
-- ) shift; break ;;
|
||||
-- ) shift; break ;;
|
||||
# Anything else stops command line processing.
|
||||
* ) break ;;
|
||||
* ) break ;;
|
||||
|
||||
esac
|
||||
done
|
||||
@ -108,7 +111,17 @@ fi
|
||||
# Check the target dir for if set if it is writable
|
||||
if [[ "x${targetdir}" != "x" ]]; 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"
|
||||
exit 1
|
||||
fi
|
||||
@ -256,7 +269,6 @@ do
|
||||
# Chapter names are used in a few place.
|
||||
chapter_title="${title}-$(printf %0${#chaptercount}d $chapternum) ${chapter}"
|
||||
chapter_file="${output_directory}/${chapter_title}.${extension}"
|
||||
|
||||
|
||||
# the ID3 tags must only be specified for *.mp3 files,
|
||||
# the other container formats come with their own
|
||||
@ -322,4 +334,12 @@ do
|
||||
log "Done ${title}"
|
||||
# Lastly get rid of any extra stuff.
|
||||
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
|
||||
|
@ -28,7 +28,7 @@ Thanks to kbabioch, this script has also been packaged in the [AUR](https://aur.
|
||||
|
||||
## 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>...
|
||||
```
|
||||
|
||||
* **<AAX INPUT_FILES>**... 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 **--authcode <AUTHCODE>** for this execution of the command use the provided <AUTHCODE> to decode the AAX file.
|
||||
* **-t** or **--target_dir <PATH>** change the default output location to the named <PATH>. Note the default location is ./Audiobook of the directory to which each AAX file resides.
|
||||
* **-C** or **--complete_dir <PATH>** 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: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.
|
||||
|
Loading…
Reference in New Issue
Block a user