31 Commits
v1.0 ... 1.1

Author SHA1 Message Date
a691b5fd54 Merge pull request #53 from SendSpams/master
Fixed HOME environment variable missing under Windows
2018-04-06 10:55:32 -05:00
db014f8f51 Update AAXtoMP3 2018-04-06 07:04:19 +01:00
1d1f738713 Update AAXtoMP3 2018-04-06 07:03:25 +01:00
120f02fe07 Modified to work with missing HOME environment variable under Windows
The HOME environment variable is not set on Windows by default. Instead Windows uses USERPROFILE. It is possible for HOME to be set on Windows but for users who have not done this they will get: `HOME: unbound variable`. I have added a line that sets HOME to USERPROFILE if HOME is missing and USERPROFILE is found. This solves the unbound variable error.
2018-04-06 07:02:00 +01:00
2ae7e326bb Renabled AAC for copy with no re-encode step 2018-03-22 14:06:19 -05:00
e3d9a9ea35 Merge pull request #51 from corbolais/master
chg: use authcode file located in HOME dir.
2018-03-14 19:40:34 -05:00
Me
15945b18b1 chg: search HOME and local dir for authcode file in this order, first occurence accepted.
Signed-off-by: Me <corbolais@gmail.com>
2018-03-15 00:35:57 +01:00
Me
1031e3ae1d chg: use authcode file located in HOME dir.
Signed-off-by: Me <corbolais@gmail.com>
2018-03-14 16:46:45 +01:00
626bab226a Updated readme for OPUS convertion, gitignore to ignore aax files in directory and output dir 2018-03-13 19:39:02 -05:00
83e83d959f Merge pull request #50 from bladegunner/add_opus
add support for the opus codec
2018-03-11 10:08:10 -05:00
d7752b4779 add support for the opus codec
it seems like ffmpeg still has some issues with the native opus
container format (*.opus), so let's use the OGG container format for
now.
2018-03-03 18:09:53 +01:00
0c2c439d55 Removed AAX, causes issues with some audiobooks 2018-02-18 01:13:00 -06:00
ed084692a2 Updated README 2018-02-18 00:34:33 -06:00
da3ca76930 Merge pull request #40 from voltagex/aac
Add support for copying to m4b (no reencode)
2018-02-18 00:29:17 -06:00
a09e502574 Fixed ':' in input file name protocol error 2018-02-18 00:27:31 -06:00
1132602f65 Add support for copying to m4b (no reencode) 2017-11-16 00:16:24 +11:00
de01589b94 Merge pull request #38 from dloeckx/master
Add cover art + improve track metadata
2017-10-22 21:40:38 -05:00
972123a932 Update metadata: track number = chapternum, appended chapter number to track title
track number was eg "Chapter 03", and is now eg 3 . This fits better in most mp3 players.
track title was the book title for all tracks, now it is eg "Book Title - 01 Chapter 1" (same as filename)
2017-10-22 22:54:10 +02:00
1ac66d1a94 Embedded cover art to (chapter) MP3's 2017-10-22 22:51:41 +02:00
15abb34c0e Merge pull request #36 from thecb1/better-chapter-names
Update of chapter titles with sortable 0padded numbers
2017-10-21 18:51:30 -05:00
6c33459f24 Merge branch 'master' into better-chapter-names 2017-10-21 18:51:21 -05:00
f06b768c55 Merge pull request #34 from thecb1/patch-1
Fix chaptercount for 0-padding
2017-10-21 18:48:55 -05:00
cb1
2fc7329bf5 Update of chapter titles with sortable 0padded numbers
* Removed chapter_padding()
* Fixed $chaptercount
* Redone 0-padded chapter titles with printf()
2017-10-20 14:44:32 +02:00
cb1
f7c4d0dce8 Fix chaptercount for 0-padding 2017-10-18 17:55:19 +02:00
1017f9a6e7 Updated grep detection with README changes and better colon support 2017-10-12 20:27:04 -05:00
c500062c96 Added ggrep detection for OSX 2017-10-09 18:09:43 -05:00
05274634d4 Removed strange _config.yml file... 2017-09-08 08:51:49 -05:00
240068be87 Merge pull request #28 from 2001db8/patch-1
Added chapter padding
2017-09-07 21:01:09 -05:00
ee01461f9a Added chapter padding
As discussed in https://github.com/KrumpetPirate/AAXtoMP3/issues/26 I've added a quick and dirty fix to add chapter padding (for audio books containing up to 999 chapters) for non-single conversion mode.
2017-09-06 19:39:02 +02:00
8002baf1c5 Set theme jekyll-theme-midnight 2017-06-29 13:17:41 -05:00
56b6b6ad98 Set theme jekyll-theme-slate 2017-06-29 12:28:17 -05:00
3 changed files with 80 additions and 34 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
ACTIVATION
.authcode
*aax
Audiobook/*

View File

@ -5,9 +5,21 @@ 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
echo "$GREP (GNU grep) is not in your PATH"
echo "Without it, this script will break."
echo "On macOS, you may want to try: brew install grep"
exit 1
fi
if [ "$#" -eq 0 ]; then
echo "Usage: bash AAXtoMP3.sh [--flac] [--single] AUTHCODE {FILES}"
echo "Usage: bash AXtoMP3 [--flac] [--aac] [--opus ] [--single] AUTHCODE {FILES}"
echo " Note that order does matter!"
exit 1
fi
@ -18,18 +30,46 @@ then
shift
fi
if [[ "$1" == '--aac' ]]
then
codec=copy
extension=m4a
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="";
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
auth_code=`head -1 .authcode`
fi
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}"
@ -48,11 +88,11 @@ save_metadata() {
get_metadata_value() {
local key
key="$1"
normalize_whitespace "$(grep --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2 | sed -e 's#/##g;s/ (Unabridged)//' | tr -s '[:blank:]' ' ')"
normalize_whitespace "$($GREP --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2- | sed -e 's#/##g;s/ (Unabridged)//' | tr -s '[:blank:]' ' ')"
}
get_bitrate() {
get_metadata_value bitrate | grep --only-matching '[0-9]\+'
get_metadata_value bitrate | $GREP --only-matching '[0-9]\+'
}
normalize_whitespace() {
@ -66,7 +106,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}"
@ -75,26 +115,42 @@ do
debug "Created ${full_file_path}."
if [ "${mode}" == "chaptered" ]; then
debug "Extracting chapter files from ${full_file_path}..."
cover_path="${output_directory}/cover.jpg"
debug "Extracting cover into ${cover_path}..."
</dev/null ffmpeg -loglevel error -activation_bytes "${auth_code}" -i "${path}" -an -codec:v copy "${cover_path}"
if [ "${mode}" == "chaptered" ]; then
chaptercount=$($GREP -Pc "Chapter.*start.*end" $metadata_file)
debug "Extracting ${chaptercount} chapter files from ${full_file_path}..."
chapternum=1
while read -r -u9 first _ _ start _ end
do
if [[ "${first}" = "Chapter" ]]
then
read -r -u9 _
read -r -u9 _ _ chapter
chapter_file="${output_directory}/${title} - ${chapter}.${extension}"
</dev/null ffmpeg -loglevel error -stats -i "${full_file_path}" -ss "${start%?}" -to "${end}" -codec:a copy -metadata track="${chapter}" "${chapter_file}"
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
# 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}" \
"${chapter_file}"
chapternum=$((chapternum + 1 ))
fi
done 9< "$metadata_file"
rm "${full_file_path}"
debug "Done creating chapters. Chaptered files contained in ${output_directory}."
fi
cover_path="${output_directory}/cover.jpg"
debug "Extracting cover into ${cover_path}..."
</dev/null ffmpeg -loglevel error -activation_bytes "${auth_code}" -i "${path}" -an -codec:v copy "${cover_path}"
debug "Done."
rm "${metadata_file}"
done

View File

@ -24,33 +24,21 @@ can obtain this string from a tool like [audible-activator](https://github.com/i
## OSX
Thanks to thibaudcolas, this script has been tested on OSX 10.11.6 El Capitan. YMMV, but it should work for
conversions in OSX.
conversions in OSX. It is recommended that you install GNU grep using 'brew install grep' for chapter padding to work.
## AUR
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
```
bash AAXtoMP3 <AUTHCODE> {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 <AUTHCODE> {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