Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get voucher (activation_bytes) for aaxc. #136

Open
nospam2k opened this issue Jan 19, 2023 · 10 comments
Open

Get voucher (activation_bytes) for aaxc. #136

nospam2k opened this issue Jan 19, 2023 · 10 comments
Labels
question Further information is requested

Comments

@nospam2k
Copy link

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.

@mkb79
Copy link
Owner

mkb79 commented Jan 19, 2023

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

@nospam2k
Copy link
Author

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!

@mkb79
Copy link
Owner

mkb79 commented Jan 26, 2023

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

@nospam2k
Copy link
Author

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.

@mkb79
Copy link
Owner

mkb79 commented Jan 26, 2023

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 mkb79 added the question Further information is requested label Feb 23, 2023
@lchiocca
Copy link

lchiocca commented Oct 18, 2023

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

@M05QU170
Copy link

M05QU170 commented Nov 1, 2023

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?

@mkb79
Copy link
Owner

mkb79 commented Nov 1, 2023

@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.

@M05QU170
Copy link

M05QU170 commented Nov 2, 2023

@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.

@mkb79
Copy link
Owner

mkb79 commented Nov 2, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants