mirror of
				https://github.com/KrumpetPirate/AAXtoMP3.git
				synced 2025-11-03 20:40:43 +01:00 
			
		
		
		
	
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1,4 @@
 | 
				
			|||||||
ACTIVATION
 | 
					ACTIVATION
 | 
				
			||||||
.authcode
 | 
					.authcode
 | 
				
			||||||
 | 
					*aax
 | 
				
			||||||
 | 
					Audiobook/*
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										54
									
								
								AAXtoMP3
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								AAXtoMP3
									
									
									
									
									
								
							@@ -5,6 +5,9 @@ set -o errexit -o noclobber -o nounset -o pipefail
 | 
				
			|||||||
codec=libmp3lame
 | 
					codec=libmp3lame
 | 
				
			||||||
extension=mp3
 | 
					extension=mp3
 | 
				
			||||||
mode=chaptered
 | 
					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")
 | 
					GREP=$(grep --version | grep -q GNU && echo "grep" || echo "ggrep")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ! [[ $(type -P "$GREP") ]]; then
 | 
					if ! [[ $(type -P "$GREP") ]]; then
 | 
				
			||||||
@@ -15,7 +18,8 @@ if ! [[ $(type -P "$GREP") ]]; then
 | 
				
			|||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ "$#" -eq 0 ]; then
 | 
					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
 | 
					        exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -26,18 +30,47 @@ then
 | 
				
			|||||||
    shift
 | 
					    shift
 | 
				
			||||||
fi
 | 
					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' ]]
 | 
					if [[ "$1" == '--single' ]]
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
    mode=single
 | 
					    mode=single
 | 
				
			||||||
    shift
 | 
					    shift
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ ! -f .authcode ]; then
 | 
					auth_code="";
 | 
				
			||||||
 | 
					for dir in $authcodeDirs; do
 | 
				
			||||||
 | 
						codeFile="${dir}$authcode";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if [ ! -f "$codeFile" ]; then
 | 
				
			||||||
		auth_code=$1
 | 
							auth_code=$1
 | 
				
			||||||
		shift
 | 
							shift
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						elif [ -s "$codeFile" ]; then
 | 
				
			||||||
 | 
							auth_code=`head -1 "$codeFile"`
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
    auth_code=`head -1 .authcode`
 | 
							echo "INFO: Sorry, empty \"$codeFile\" found, skipping.";
 | 
				
			||||||
fi
 | 
						fi;
 | 
				
			||||||
 | 
					done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -z "$auth_code" ]; then
 | 
				
			||||||
 | 
						echo "INFO: Sorry, no authcode provided.";
 | 
				
			||||||
 | 
						exit 1;
 | 
				
			||||||
 | 
					fi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
debug() {
 | 
					debug() {
 | 
				
			||||||
    echo "$(date "+%F %T%z") ${1}"
 | 
					    echo "$(date "+%F %T%z") ${1}"
 | 
				
			||||||
@@ -74,7 +107,7 @@ do
 | 
				
			|||||||
    save_metadata "${path}"
 | 
					    save_metadata "${path}"
 | 
				
			||||||
    genre=$(get_metadata_value genre)
 | 
					    genre=$(get_metadata_value genre)
 | 
				
			||||||
    artist=$(get_metadata_value artist)
 | 
					    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}"
 | 
					    output_directory="$(dirname "${path}")/${genre}/${artist}/${title}"
 | 
				
			||||||
    mkdir -p "${output_directory}"
 | 
					    mkdir -p "${output_directory}"
 | 
				
			||||||
    full_file_path="${output_directory}/${title}.${extension}"
 | 
					    full_file_path="${output_directory}/${title}.${extension}"
 | 
				
			||||||
@@ -105,7 +138,16 @@ do
 | 
				
			|||||||
                read -r -u9 _ _ chapter
 | 
					                read -r -u9 _ _ chapter
 | 
				
			||||||
                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}"
 | 
				
			||||||
                </dev/null ffmpeg -loglevel error -stats -i "${full_file_path}" -i "${cover_path}" -ss "${start%?}" -to "${end}" -c copy -map 0:0 -map 1:0 -id3v2_version 3 \
 | 
					
 | 
				
			||||||
 | 
					                # the ID3 tags must only be specified for *.mp3 files,
 | 
				
			||||||
 | 
					                # the other container formats come with their own
 | 
				
			||||||
 | 
					                # tagging mechanisms.
 | 
				
			||||||
 | 
					                id3_version_param=""
 | 
				
			||||||
 | 
					                if test "${extension}" = "mp3"; then
 | 
				
			||||||
 | 
					                   id3_version_param="-id3v2_version 3"
 | 
				
			||||||
 | 
					                fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                </dev/null ffmpeg -loglevel error -stats -i "${full_file_path}" -i "${cover_path}" -ss "${start%?}" -to "${end}" -map 0:0 -map 1:0 -acodec copy ${id3_version_param} \
 | 
				
			||||||
                    -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" -metadata track="${chapternum}" -metadata title="${chapter_title}" \
 | 
					                    -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" -metadata track="${chapternum}" -metadata title="${chapter_title}" \
 | 
				
			||||||
                    "${chapter_file}"
 | 
					                    "${chapter_file}"
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
									
									
									
									
								
							@@ -30,27 +30,15 @@ conversions in OSX. It is recommended that you install GNU grep using 'brew inst
 | 
				
			|||||||
Thanks to kbabioch, this script has also been packaged in the [AUR](https://aur.archlinux.org/packages/aaxtomp3-git/). Note that you will still need to extract your activation bytes before use.
 | 
					Thanks to kbabioch, this script has also been packaged in the [AUR](https://aur.archlinux.org/packages/aaxtomp3-git/). Note that you will still need to extract your activation bytes before use.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Usage
 | 
					## Usage
 | 
				
			||||||
```
 | 
					```bash
 | 
				
			||||||
bash AAXtoMP3 <AUTHCODE> {INPUT_FILES}
 | 
					bash AAXtoMP3 [--flac] [--aac] [--opus] [--single] AUTHCODE {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!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You can also convert the output to FLAC encoding instead of MP3 by doing the following *in order*:
 | 
					Note that any optional flags have to be inputed *in order* to function correctly.
 | 
				
			||||||
```
 | 
					 | 
				
			||||||
bash AAXtoMP3 --flac <AUTHCODE> {INPUT_FILES}
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
Note that FLAC encoding is typically a little faster, at the cost of compatibility with some players.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
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 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.
 | 
				
			||||||
 | 
					 | 
				
			||||||
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}
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Anti-Piracy Notice
 | 
					## Anti-Piracy Notice
 | 
				
			||||||
Note that this project does NOT ‘crack’ the DRM. It simply allows the user to
 | 
					Note that this project does NOT ‘crack’ the DRM. It simply allows the user to
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								_config.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								_config.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					theme: jekyll-theme-slate
 | 
				
			||||||
		Reference in New Issue
	
	Block a user