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
$ 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:

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 --output 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1863k  100 1863k    0     0  2200k      0 --:--:-- --:--:-- --:--:-- 2197k
$ python2 
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 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
$ 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 (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.


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

$ ./ -l uk
[*] Player ID is 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
activation_bytes: 6328eb28
$ cd ../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
  cd audible-activator-master/
  sudo pip install requests
  sudo pip install selenium
  mv ~/Downloads/HarryPotterandtheHalf-BloodPrinceBook6_ep6.aax .
  ./ -1 us
  ./ -l us
  cd ..
  cd audible-activator-master/
  cd ..
  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/