diff --git a/.gitignore b/.gitignore index 71a9d6a..bc3dd24 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ ACTIVATION .authcode +*aax +Audiobook/* diff --git a/AAXtoMP3 b/AAXtoMP3 index 293de3f..d0d9e03 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -5,6 +5,9 @@ set -o errexit -o noclobber -o nounset -o pipefail codec=libmp3lame extension=mp3 mode=chaptered +authcode=".authcode"; +if [ -z ${HOME+x} ] && ! [ -z ${USERPROFILE+x} ]; then HOME="$USERPROFILE"; fi +authcodeDirs="${HOME}/ ./" GREP=$(grep --version | grep -q GNU && echo "grep" || echo "ggrep") if ! [[ $(type -P "$GREP") ]]; then @@ -15,7 +18,8 @@ if ! [[ $(type -P "$GREP") ]]; then fi if [ "$#" -eq 0 ]; then - echo "Usage: bash AAXtoMP3.sh [--flac] [--single] AUTHCODE {FILES}" + echo "Usage: bash AAXtoMP3 [--flac] [--aac] [--opus ] [--single] AUTHCODE {FILES}" + echo " Note that order does matter!" exit 1 fi @@ -26,18 +30,47 @@ then shift fi +if [[ "$1" == '--aac' ]] +then + codec=copy + extension=m4a + mode=single + shift +fi + +if [[ "$1" = '--opus' ]] +then + codec=libopus + extension=ogg + shift +fi + if [[ "$1" == '--single' ]] then mode=single shift fi -if [ ! -f .authcode ]; then - auth_code=$1 - shift -else - auth_code=`head -1 .authcode` -fi +auth_code=""; +for dir in $authcodeDirs; do + codeFile="${dir}$authcode"; + + if [ ! -f "$codeFile" ]; then + auth_code=$1 + shift + break; + elif [ -s "$codeFile" ]; then + auth_code=`head -1 "$codeFile"` + break; + else + echo "INFO: Sorry, empty \"$codeFile\" found, skipping."; + fi; +done; + +if [ -z "$auth_code" ]; then + echo "INFO: Sorry, no authcode provided."; + exit 1; +fi; debug() { echo "$(date "+%F %T%z") ${1}" @@ -74,7 +107,7 @@ do save_metadata "${path}" genre=$(get_metadata_value genre) artist=$(get_metadata_value artist) - title=$(get_metadata_value title) + title=$(get_metadata_value title | sed 's/'\:'/'-\ '/g' | xargs -0) output_directory="$(dirname "${path}")/${genre}/${artist}/${title}" mkdir -p "${output_directory}" full_file_path="${output_directory}/${title}.${extension}" @@ -105,7 +138,16 @@ do read -r -u9 _ _ chapter chapter_title="${title} - $(printf %0${#chaptercount}d $chapternum) ${chapter}" chapter_file="${output_directory}/${chapter_title}.${extension}" - {INPUT_FILES} +```bash +bash AAXtoMP3 [--flac] [--aac] [--opus] [--single] AUTHCODE {FILES} ``` * AUTHCODE: **your** Audible auth code (it won't correctly decode otherwise) (required) * Everything else is considered an input file, useful for batching! -You can also convert the output to FLAC encoding instead of MP3 by doing the following *in order*: -``` -bash AAXtoMP3 --flac {INPUT_FILES} -``` -Note that FLAC encoding is typically a little faster, at the cost of compatibility with some players. +Note that any optional flags have to be inputed *in order* to function correctly. -If you wish to convert to a single file you can add --single to the input. This will prevent chaptered content from being extracted. - -Additionally, if you have a .authcode file available in the current working directory, it will read the first line of -that line and treat it like your auth_code. When you do this you do not need to specify an AUTHCODE input. - -Here is the full usage (NOTE: Order matters!) -``` -bash AAXtoMP3 [--flac] [--single] AUTHCODE {FILES} -``` +Additionally, if you have a .authcode file available in either your home directory or the current working directory, it will read the first line of that line and treat it like your auth_code. When you do this you do not need to specify an AUTHCODE input. ## Anti-Piracy Notice Note that this project does NOT ‘crack’ the DRM. It simply allows the user to diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c741881 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-slate \ No newline at end of file