Comments (4)
Make sure you have registered a device (and save the credentials) before you make a licenserequest. A registration is needed for the licenserequest
endpoint.
If you have registered a device you can try this code:
import base64
import json
import pathlib
import audible
import httpx
from audible.aescipher import decrypt_voucher_from_licenserequest as dv
# files downloaded via this script can be converted
# audible uses a new format (aaxc instead of aax)
# more informations and workaround here:
# https://github.com/mkb79/Audible/issues/3
# especially: https://github.com/mkb79/Audible/issues/3#issuecomment-705262614
# get license response for book
def get_license_response(client, asin, quality):
try:
response = client.post(
f"content/{asin}/licenserequest",
body={
"drm_type": "Adrm",
"consumption_type": "Download",
"quality": quality
}
)
return response
except Exception as e:
print(f"Error: {e}")
return
def get_download_link(license_response):
# example download function
return license_response["content_license"]["content_metadata"]["content_url"]["offline_url"]
def download_file(url, filename):
with httpx.stream("GET", url) as r:
with open(filename, 'wb') as f:
for chunck in r.iter_bytes():
f.write(chunck)
return filename
if __name__ == "__main__":
# These 3 variables must be filled out
fn = FILENAME_OF_AUTH_FILE
asin = YOUR_ASIN
title = TARGET_FILE_AAXC
auth = audible.FileAuthenticator(
filename=fn
)
client = audible.Client(auth)
lr = get_license_response(client, asin, quality="Extreme")
if lr:
dl_link = get_download_link(lr)
filename = pathlib.Path.cwd() / title
print(f"download link now: {dl_link}")
status = download_file(dl_link, filename)
print(f"downloaded file: {status} to {filename}")
voucher_file = filename.with_suffix(".json")
decrypted_voucher = dv(auth=auth, license_response=lr)
print(decrypted_voucher)
voucher_file.write_text(json.dumps(decrypted_voucher, indent=4))
print(f"saved voucher to: {voucher_file}")
This is tested now and running fine!
from audible.
Works like a charm. That's something I would never have tried
from audible.
You are mean the registration? Please make sure to reuse registration data. This prevent you for filling your Amazon devices list on every new registration!
from audible.
Thank you for the additional hint. Yes, I totally misunderstood the meaning of 'register' in this context. I had seen it as related to opening an account (which I did not intend to do via python ;) ) as opposed to registering a device. Additionally, I am totally new to Audible and was therefore taken by surprise that it is quite a challenge to get their content on my mp3-player. But now after a small software installation marathon (and thanks to your help) it works
from audible.
Related Issues (20)
- 错误提示 HOT 19
- Quality is set to `Extreme` even set to `high` HOT 1
- TEST: New device registration method HOT 4
- Extract Audible Bookmark Notes HOT 3
- Issue getting activation bytes from auth server HOT 9
- Switch to poetry, implement CI+CD, remove Python version <3.8
- Lift upper version restriction on `httpx`. HOT 3
- Is there any way to get a list of books in a series? HOT 1
- Amazon authentication code not handled properly HOT 2
- I need some help with metadata HOT 2
- Audible brazil HOT 11
- Brazil Account Can not login by external_login HOT 3
- RecursionError introduced in 0.9.0 in some cases HOT 3
- API doc: Only High and Normal is allowed as quality
- `valid_mail` regex is too strict HOT 4
- How does the BestSellers sort_by option in the APIs work? HOT 3
- Where does the file get stored with to_file() HOT 5
- Can't filter plus catalog books from 'catalog/products' HOT 9
- state token for library requests HOT 2
- response_callback no longer works properly with the endpoint: https://cde-ta-g7g.amazon.com/FionaCDEServiceEngine/sidecar HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from audible.