mirror of
https://github.com/KrumpetPirate/AAXtoMP3.git
synced 2024-11-18 03:08:57 +01:00
Merge pull request #112 from FreedomBen/no-clobber
Add no-clobber option to CLI
This commit is contained in:
commit
9f8cda5899
12
AAXtoMP3
12
AAXtoMP3
@ -5,7 +5,7 @@
|
||||
# Command Line Options
|
||||
|
||||
# Usage Synopsis.
|
||||
usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--chaptered]\n[-e:mp3] [-e:m4a] [-e:m4b] [--authcode <AUTHCODE>]\n[--target_dir <PATH>] [--complete_dir <PATH>] [--validate]\n{FILES}\n'
|
||||
usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--chaptered]\n[-e:mp3] [-e:m4a] [-e:m4b] [--authcode <AUTHCODE>] [--no-clobber]\n[--target_dir <PATH>] [--complete_dir <PATH>] [--validate]\n{FILES}\n'
|
||||
codec=libmp3lame # Default encoder.
|
||||
extension=mp3 # Default encoder extention.
|
||||
mode=chaptered # Multi file output
|
||||
@ -45,6 +45,8 @@ while true; do
|
||||
-C | --complete_dir ) completedir="$2"; shift 2 ;;
|
||||
# Authorization code associate with the AAX file(s)
|
||||
-A | --authcode ) auth_code="$2"; shift 2 ;;
|
||||
# Don't overwrite the target directory if it already exists
|
||||
-n | --no-clobber ) noclobber=1; shift ;;
|
||||
# Extremely verbose output.
|
||||
-d | --debug ) DEBUG=1; shift ;;
|
||||
# Validate ONLY the aax file(s) No transcoding occurs
|
||||
@ -234,7 +236,7 @@ if [[ "x${targetdir}" != "x" ]]; then
|
||||
fi
|
||||
|
||||
# -----
|
||||
# Check the target dir for if set if it is writable
|
||||
# Check the completed 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\""
|
||||
@ -283,7 +285,7 @@ validate_aax() {
|
||||
log "Test 2 SUCCESS: ${media_file}"
|
||||
fi
|
||||
|
||||
# This is a big test only performed when the --validate swicth is passed.
|
||||
# This is a big test only performed when the --validate switch is passed.
|
||||
if [[ "${VALIDATE}" == "1" ]]; then
|
||||
output="$(ffmpeg -hide_banner -activation_bytes ${auth_code} -i "${media_file}" -vn -f null - 2>&1)"
|
||||
if [[ $? != "0" ]] ; then
|
||||
@ -360,6 +362,10 @@ do
|
||||
album_date="$(get_metadata_value date)"
|
||||
copyright="$(get_metadata_value copyright)"
|
||||
|
||||
if [[ "${noclobber}" = "1" ]] && [[ -d "${output_directory}" ]]; then
|
||||
log "Noclobber enabled but directory '${output_directory}' exists. Exiting to avoid overwriting"
|
||||
exit 0
|
||||
fi
|
||||
mkdir -p "${output_directory}"
|
||||
|
||||
# Fancy declaration of which book we are decoding. Including the AUTHCODE.
|
||||
|
@ -29,7 +29,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>] [-C|--complete_dir <PATH>] [-V|--validate] [-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>] [-n|--no-clobber] [-t|--target_dir <PATH>] [-C|--complete_dir <PATH>] [-V|--validate] [-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] [
|
||||
* **-o** or **--opus** Ogg/Opus Encoding defaults to multiple file output by chapter. The extention is .ogg
|
||||
* **-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.
|
||||
* **-n** or **--no-clobber** If set and the target directory already exists, AAXtoMP3 will exit without overwriting anything.
|
||||
* **-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.
|
||||
* **-V** or **--validate** Perform 2 validation tests on the supplied aax files. This is more extensive than the normal validation as we attempt to transcode the aax file to a null file. This can take a long period of time. However it is useful when inspecting a large set of aax files prior to transcoding. As download errors are common with Audible servers.
|
||||
|
Loading…
Reference in New Issue
Block a user