How to convert Audible aax files to mp3 in Linux


update Dec 2020

When trying to follow the streamlined procedure on my Ubuntu 20.04 machine I encountered various problems related to the following:

The first hurdle to overcome was to install pip for Python2.7. It turns out that this is not straightforward in Ubuntu 20.4:

$ python2 -m pip install requests
/usr/bin/python2: No module named pip
mperdikeas@mp-ThinkStation-P320:~/aax2mp3tools-if-this-is-a-man/audible-activator-master#
$ sudo apt install python-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python3-pip

E: Package 'python-pip' has no installation candidate
        
…, in the end I followed the procedure identified in this SO answer:
$ sudo apt update
(output omitted)
$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1863k  100 1863k    0     0  2200k      0 --:--:-- --:--:-- --:--:-- 2197k
mperdikeas@mp-ThinkStation-P320:~/aax2mp3tools-if-this-is-a-man/audible-activator-master#
$ python2 get-pip.py 
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 1.1 MB/s 
Collecting setuptools<45
  Downloading setuptools-44.1.1-py2.py3-none-any.whl (583 kB)
     |████████████████████████████████| 583 kB 22.8 MB/s 
Collecting wheel
  Downloading wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-20.3.4 setuptools-44.1.1 wheel-0.37.0
mperdikeas@mp-ThinkStation-P320:~/aax2mp3tools-if-this-is-a-man/audible-activator-master#
$ pip --version
pip 20.3.4 from /home/mperdikeas/.local/lib/python2.7/site-packages/pip (python 2.7)

After that I verified that I have two versions of pip: one for Python2.7 and one for Python 3 (with pip corresponding to pip2):

$ pip2 --version
pip 20.3.4 from /home/mperdikeas/.local/lib/python2.7/site-packages/pip (python 2.7)
$ pip --version
pip 20.3.4 from /home/mperdikeas/.local/lib/python2.7/site-packages/pip (python 2.7)
$ pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8) 

Installing pip for Python2 allowed me to properly install and requests and selenium for Python2 and finally be able to successfully run audible-activator.py (which uses the Python2 interpreter).

However, that was not the end of my problems as when I tried to run the AAXtoMP3 script I encountered further problems related to the availability of ffmpeg libraries for my Ubuntu 20.04 machine. I am not able to do a write down of that part (which was quite chaotic) as there was a power outage / reboot cycle and I have lost the terminal history, but in the end I got AAXtoMP3 to work as well (albeit after trying a number of things in a very chaotic manner as conceded). But in the end, I managed to get everything to work and basically followed the "streamlined" procedure described below.

Streamlined

The below are for the audible site at the UK (notice the -l uk switch):

mperdikeas@mp-t420:~/aax2mp3tools-hp-5/audible-activator-master
$ ./audible-activator.py -l uk
Username: scharamousou@gmail.com
Password: 
[*] Player ID is 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
activation_bytes: 6328eb28
mperdikeas@mp-t420:~/aax2mp3tools-hp-5/audible-activator-master#
$ cd ../AAXtoMP3-master/
mperdikeas@mp-t420:~/aax2mp3tools-hp-5/AAXtoMP3-master#
$ ./AAXtoMP3 --authcode 6328eb28 ../HarryPotterandtheOrderofthePhoenixBook5_ep6.aax 
        

previous messy instructions

I followed the instructions from here which I found in this stackexchange answer.

Every step of that guide worked flawlessly except for a minor snag at the last step. That last incantation should actually read:

./AAXtoMP3 --authcode <authcode> <aax-file>

I.e. you need to explicitly type the --authcode option.

A PDF printout of that page (obtained 2019-01-07) is here.

The work was executed on the T420 machine, directory ~/aax2mp3tools. The history (with the audible authentication code anonymized) is given below:

  apt-get install ffmpeg
  sudo apt-get install ffmpeg
  echo $?
  mkdir aax2mp3tools
  cd aax2mp3tools
  wget https://github.com/inAudible-NG/audible-activator/archive/master.zip
  unzip master.zip
  rm master.zip
  cd audible-activator-master/
  sudo pip install requests
  sudo pip install selenium
  wget https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
  unzip chromedriver_linux64.zip
  ./chromedriver
  mv ~/Downloads/HarryPotterandtheHalf-BloodPrinceBook6_ep6.aax .
  ./audible-activator.py -1 us
  ./audible-activator.py -l us
  cd ..
  cd audible-activator-master/
  cd ..
  wget https://github.com/KrumpetPirate/AAXtoMP3/archive/master.zip
  unzip master.zip
  rm master.zip
  cd AAXtoMP3-master/
  mv ../audible-activator-master/HarryPotterandtheHalf-BloodPrinceBook6_ep6.aax ..
  ./AAXtoMP3 XXXXXXXX ../HarryPotterandtheHalf-BloodPrinceBook6_ep6.aax
* ./AAXtoMP3 -h
  ./AAXtoMP3 --authcode XXXXXXXX ../HarryPotterandtheHalf-BloodPrinceBook6_ep6.aax
  ls ../Audiobook/