Added .authcode support and fixed README

This commit is contained in:
KrumpetPirate 2017-01-05 18:29:37 -06:00
parent aa93813892
commit a8bddf3df1
3 changed files with 46 additions and 24 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
ACTIVATION ACTIVATION
.authcode

View File

@ -4,6 +4,12 @@ set -o errexit -o noclobber -o nounset -o pipefail
codec=libmp3lame codec=libmp3lame
extension=mp3 extension=mp3
mode=chaptered
if [ "$#" -eq 0 ]; then
echo "Usage: bash AAXtoMP3.sh [--flac] [--single] AUTHCODE {FILES}"
exit 1
fi
if [[ "$1" = '--flac' ]] if [[ "$1" = '--flac' ]]
then then
@ -12,8 +18,18 @@ then
shift shift
fi fi
if [[ "$1" == '--single' ]]
then
mode=single
shift
fi
if [ ! -f .authcode ]; then
auth_code=$1 auth_code=$1
shift shift
else
auth_code=`head -1 .authcode`
fi
debug() { debug() {
echo "$(date "+%F %T%z") ${1}" echo "$(date "+%F %T%z") ${1}"
@ -56,6 +72,7 @@ do
debug "Created ${full_file_path}." debug "Created ${full_file_path}."
if [ "${mode}" == "chaptered" ]; then
debug "Extracting chapter files from ${full_file_path}..." debug "Extracting chapter files from ${full_file_path}..."
while read -r -u9 first _ _ start _ end while read -r -u9 first _ _ start _ end
@ -68,7 +85,9 @@ do
ffmpeg -loglevel error -stats -i "${full_file_path}" -ss "${start%?}" -to "${end}" -codec:a copy "${chapter_file}" ffmpeg -loglevel error -stats -i "${full_file_path}" -ss "${start%?}" -to "${end}" -codec:a copy "${chapter_file}"
fi fi
done 9< "$metadata_file" done 9< "$metadata_file"
debug "Done creating chapters. Single file and chaptered files contained in ${output_directory}." rm ${full_file_path}
debug "Done creating chapters. Chaptered files contained in ${output_directory}."
fi
cover_path="${output_directory}/cover.jpg" cover_path="${output_directory}/cover.jpg"
debug "Extracting cover into ${cover_path}..." debug "Extracting cover into ${cover_path}..."

View File

@ -1,6 +1,6 @@
# AAXtoMP3 # AAXtoMP3
The purpose of this software is to convert AAX files to a more common MP3 format The purpose of this software is to convert AAX files to a more common MP3 format
through a basic perl script frontend to FFMPEG. through a basic bash script frontend to FFMPEG.
Audible uses this file format to maintain DRM restrictions on their audio Audible uses this file format to maintain DRM restrictions on their audio
books and if you download your book through your library it will be books and if you download your book through your library it will be
@ -12,10 +12,6 @@ your **personal** Audible account. The purpose of this software is to
create a method for you to download and store your books just in case create a method for you to download and store your books just in case
Audible fails for some reason. Audible fails for some reason.
I recently converted this script to bash instead of perl. Something about more people knowing bash or something rather.
Additionally I put some work into creating chaptered files as well as the mp3 version. A directory of structure GENRE/WRITER/TITLE
will contain the large mp3 as well as chaptered mp3s extracted from the AAX file metadata.
TODO: Automatically fix the MP3 tags on the generated audio files. For now I use easytag which seems to work okay. TODO: Automatically fix the MP3 tags on the generated audio files. For now I use easytag which seems to work okay.
## Setup ## Setup
@ -25,7 +21,6 @@ can obtain this string from a tool like [audible-activator](https://github.com/i
## Requirements ## Requirements
* bash 4.3.42 or later tested * bash 4.3.42 or later tested
* ~~perl version 5.22.0 or later~~ (Converted the script to bash for greater readability!)
* ffmpeg version 2.8.3 or later * ffmpeg version 2.8.3 or later
* libmp3lame (came from lame package on Arch, not sure where else this is stored) * libmp3lame (came from lame package on Arch, not sure where else this is stored)
@ -36,12 +31,19 @@ bash AAXtoMP3.sh <AUTHCODE> {INPUT_FILES}
* AUTHCODE: **your** Audible auth code (it won't correctly decode otherwise) (required) * AUTHCODE: **your** Audible auth code (it won't correctly decode otherwise) (required)
* Everything else is considered an input file, useful for batching! * Everything else is considered an input file, useful for batching!
Tested on Linux with the above requirements. No effort will be made to You can also convert the output to FLAC encoding instead of MP3 by doing the following *in order*
port this work to any other operating system, though it may work fine. Want a Windows/ ```
OSX port? You'll have to fork the work. bash AAXtoMP3.sh --flac <AUTHCODE> {INPUT_FILES}
```
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. For example here is the full usage with a
.authcode file available:
```
bash AAXtoMP3.sh [--flac] [--single] {FILES}
```
## Anti-Piracy Notice ## Anti-Piracy Notice
Note that this project does NOT crack the DRM. It simplys allows the user to Note that this project does NOT crack the DRM. It simply allows the user to
use their own encryption key (fetched from Audible servers) to decrypt the use their own encryption key (fetched from Audible servers) to decrypt the
audiobook in the same manner that the official audiobook playing software does. audiobook in the same manner that the official audiobook playing software does.