audible-cli icon indicating copy to clipboard operation
audible-cli copied to clipboard

Get voucher (activation_bytes) for aaxc.

Open nospam2k opened this issue 2 years ago • 10 comments

I'm sorry for asking for a how to but I have seen bits and pieces about using api to get activation_bytes for aaxc. It seems that aaxc files have per file activation_bytes. Can you please direct me to the proper command line for getting the activation_bytes for aaxc for a specific audio book in my library?

Thank you and again, sorry for using this for a how to but I'm running out of options online.

nospam2k avatar Jan 19 '23 00:01 nospam2k

Here you can find the code to make a licenserequest and decrypting the license.

mkb79 avatar Jan 19 '23 05:01 mkb79

Thanks for that. I'm having a hard time trying to translate that into how to provide command line parameters. I would appreciate it if you could provide an example command line using audible-cli. Thanks!

nospam2k avatar Jan 26 '23 16:01 nospam2k

When you download an aaxc book with audible-cli the voucher file is automatically downloaded. Or do you want the voucher file only?

mkb79 avatar Jan 26 '23 16:01 mkb79

Yes, I just want the voucher file. Thank you. I have a script that just runs ffmpeg against a folder of aax files that uses the activation_bytes I grabbed from a different script. This works fine for aax. I only recently found out that aaxc uses a per book activation_bytes so I just want to store those codes separately per book. I ran into a problem where something went wrong with Audible and a book I had downloaded was no longer available, but I still had the aaxc file on my phone. I had been trying to figure out how to get the aaxc activation_bytes when I ran across your code. Fortunately, in the mean time, Audible was able to fix the problem but I want to be able to be sure and have all the aaxc activation_bytes for safe keeping.

nospam2k avatar Jan 26 '23 18:01 nospam2k

Aaxc files make use of a key/iv pair to decrypt the book. The key/iv pair is responded with a licenserequest. But the key/iv pair is encrypted. For decrypting the key/iv pair you need the device serial and other stuff (look here). So the key/iv is unique for every book, account and device. audible-cli creates a virtual device for this. So I does not know if you can use these key/iv with books downloaded from another source/app.

You can test these out by downloading an aaxc book with my app. You can abort the progress after the voucher is saved - you don’t need the aaxc file for this to finish. Then use the key/iv with your other already downloaded book.

mkb79 avatar Jan 26 '23 18:01 mkb79

Just as a side note: If you have the voucher and the aaxc files, the you can simply use ffmpeg to decrypt the aaxc as follows: ffmpeg -y -audible_key {voucher.content_license.license_response.key} -audible_iv {voucher.content_license.license_response.iv} -i {filepath.aaxc} -c copy -map 0 {filepath.mp4} "-y" to allow overwriting the target / "audible_key/audible_iv" are the decryption key and the initialization vector / "-i" is the input aaxc file / "-c copy" will tell ffmpeg to not reencode / "-map 0" will take over all the streams from the aaxc file

lchiocca avatar Oct 18 '23 17:10 lchiocca

ffmpeg -y -audible_key {voucher.content_license.license_response.key} -audible_iv {voucher.content_license.license_response.iv} -i {filepath.aaxc} -c copy -map 0 {filepath.mp4}

It feels like it is part of script. How does beginning and ending looks like?

M05QU170 avatar Nov 01 '23 18:11 M05QU170

@M05QU170 If you use audible-cli you have to replace:

  1. {voucher.content_license.license_response.key} with the key value from the voucher file.
  2. {voucher.content_license.license_response.iv} with the iv value from the voucher file
  3. {filepath.aaxc} with the file path of the downloaded aaxc file.
  4. {filepath.mp4} with the file path of the target (decrypted) file.

Please ignore the leading { and trailing }!

But you can use this script for `audible-cli too. This will make the work for you.

mkb79 avatar Nov 01 '23 19:11 mkb79

@M05QU170 If you use audible-cli you have to replace:

1. {voucher.content_license.license_response.key} with the `key` value from the voucher file.

2. {voucher.content_license.license_response.iv} with the `iv` value from the voucher file

3. {filepath.aaxc} with the file path of the downloaded aaxc file.

4. {filepath.mp4} with the file path of the target (decrypted) file.

Please ignore the leading { and trailing }!

But you can use this script for `audible-cli too. This will make the work for you.

Thank you, I have checked it, it's working very well. Just quick question why there is chapter intergration work going on? If converting from aax/aaxc to m4b all it needs to pass "-c copy" flag to ffmpeg.

M05QU170 avatar Nov 02 '23 08:11 M05QU170

Just quick question why there is chapter intergration work going on? If converting from aax/aaxc to m4b all it needs to pass "-c copy" flag to ffmpeg.

If you use ffmpeg this way, the chapter information from the aaxc file are taken. Often this will result in chapter names like Chapter 1, Chapter 2 and so on. The Audible app for iOS and Android will display you more detailed chapter names, because they take the chapter information from the API and not from the file. Therefore audible-cli will let you download chapter information from the API too. You can now manually integrate this information in your final m4b file or you can use my decrypt plugin for this purpose.

mkb79 avatar Nov 02 '23 08:11 mkb79