-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Error when trying to get book download URL #16
Comments
Hi, I try to find some informations about the asin B07231CR59 but google found nothing. What is this for a product and which content type? Is it a serie, a SinglePartBook, a MultiPartBook or something other? Hint: Regards |
Thanks for the fast response! It is much appreciated! The specific asin I provided is the asin of a child to the book. I also attempted with the book asin ('B07148GH11') and other books and always obtained the same error. How do I determine if this is a single part book or a multipart book? Ideally, I would like 1 large file for the whole book instead of downloading it in several parts. I also tried to follow the instructions in the post you shared and found that the method 'client._sign_request' does not exist. I haven't found where it might have been moved to. |
Which version of my audible app you use? Can you try my download example at https://github.com/mkb79/Audible/blob/master/examples/download_books_aax.py |
I tried with the example you provided and I am receiving a 500 error on each calls to get the download link. I did make sure I specify a codec as available in the list of available codecs for each given book. I'm using Audible Canada, could this be an issue? I'm using the latest version published on Pypi |
Hmm, that sounds strange. Can you make the following api call: book = client.get(
"library/B07148GH11",
response_groups="product_desc, series, relationships"
)
print(book) and send me the response. You can send me a mail to [email protected] instead to post the response content here. |
Can you try this code please (please set the correct settings to your auth file): import pathlib
import shutil
import audible
import httpx
# get download link(s) for book
def _get_download_link(auth, asin, codec="LC_128_44100_stereo"):
# need at least v0.4.0dev
try:
content_url = (f"https://cde-ta-g7g.amazon.com/FionaCDEServiceEngine/"
f"FSDownloadContent")
params = {
'type': 'AUDI',
'currentTransportMethod': 'WIFI',
'key': asin,
'codec': codec
}
r = httpx.get(
url=content_url,
params=params,
allow_redirects=False,
auth=auth
)
# prepare link
# see https://github.com/mkb79/Audible/issues/3#issuecomment-518099852
link = r.headers['Location']
tld = auth.locale.domain
new_link = link.replace("cds.audible.com", f"cds.audible.{tld}")
return new_link
except Exception as e:
print(f"Error: {e}")
return
def download_file(url):
r = httpx.get(url)
try:
title = r.headers["Content-Disposition"].split("filename=")[1]
filename = pathlib.Path.cwd() / "audiobooks" / title
with open(filename, 'wb') as f:
shutil.copyfileobj(r.iter_raw, f)
return filename
except KeyError:
return "Nothing downloaded"
if __name__ == "__main__":
auth = audible.FileAuthenticator(
...
)
client = audible.Client(auth)
asin = "B07148GH11"
dl_link = _get_download_link(auth, asin)
print(dl_link)
if dl_link:
print(f"download link now: {dl_link}")
status = download_file(dl_link)
print(f"downloaded file: {status}") |
I still receive a 500 error with no details on the request |
Have you register a device and use sign request method or you use access token authentication? You can test this with Can you try this code and send me the response via mail please?: import audible
import httpx
auth = audible.FileAuthenticator(
...
)
client = audible.Client(auth)
asin = "B07148GH11"
codec="LC_128_44100_stereo"
content_url = (f"https://cde-ta-g7g.amazon.com/FionaCDEServiceEngine/"
f"FSDownloadContent")
params = {
'type': 'AUDI',
'currentTransportMethod': 'WIFI',
'key': asin,
'codec': codec
}
r = httpx.get(
url=content_url,
params=params,
allow_redirects=False,
auth=auth
)
print(r.headers) |
print(auth.adp_token) returns None. So I guess I am using the sign request method. The code above returns the following: |
If you have no adp token in your auth file then you use access token auth mode. Access token is only valid for 60 minutes. So you have to authenticate again after that time. Access token auth mode have more limitations if you make api calls. Maybe this is the problem. Can you use LoginAuthenticator with register option and save your auth data to file. Then try again the last code snippet. |
Well damn! That did the trick! I now have the "location" value in the returned header. Thanks for the great support, I'm going to be closing this issue. |
That‘s great to hear! I will adjust my download example to make sure adp_token is present in auth file. |
I'm trying to follow the different examples provided to get a book download URL.
I'm successfully authenticating and fetching my library. However, I'm getting a 500 error when trying to get the book download URL as follow:
The error obtained is as follow:
audible.exceptions.UnexpectedError: Internal Server Error (500): Unexpected error while servicing request for ASIN: B07231CR59 and ACR: null.
I tried using the book asin directly and using its child asin. Can you point me in the correct direction?
The text was updated successfully, but these errors were encountered: