Audible
Audible copied to clipboard
Can't filter plus catalog books from 'catalog/products'
Hello there, I started working with this repo a few hours ago because I do like the idea of archiving audiobooks.
This is a plus catalog audiobook so anyone with the subscription can help me with it.
ASIN - 1665074620
Title - What Addicts Know
I am using Google Colab for this as I like to try new things there and then implement the rest on my server.
I have a few questions about the usage but before that, I want to know how to download the audiobooks. I don't care about the format (.aax or .aacx) because I can decode either. Which link do I download? The following is my code to get the download URL:
body = {
"supported_drm_types" : [
"Mpeg",
"Adrm"
],
"quality" : "High",
"consumption_type" : "Download"
}
token = client.post("1.0/content/1665074620/licenserequest", body)
print(json.dumps(token, indent=3, sort_keys=True))
OUTPUT:
{
"content_license": {
"access_expiry_date": "2024-12-31T12:00:00Z",
"acr": "CXXXXXX",
"allowed_users": [
"amzn1.account.XXXXXXXXXXXXXXXXXXXXXXXXX"
],
"asin": "1665074620",
"content_metadata": {
"content_url": {
"offline_url": "https://dze5l2jxnquy5.cloudfront.net/bk_blak_016548it/28335321/aax/XXXX....XXXX"
}
},
"drm_type": "Adrm",
"license_id": "XXXXXXXXXXXXXXXXXXXXXXXX",
"license_response": "y/XXXXXX.....XXXXX",
"message": "Customer [XXXXXXXXXXXXXXX] has rights to asin [1665074620] for AYCL",
"refresh_date": "2022-03-18T06:28:07Z",
"removal_date": "2022-04-27T06:28:07Z",
"request_id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"requires_ad_supported_playback": false,
"status_code": "Granted",
"voucher_id": "cdn:XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"response_groups": [
"always-returned"
]
}
### When I click the offline_url, I get this following error:
##
At first I thought that my macBook and the Colab instance have different IP Addresses and thats why I can't download it. Then I tried downloading it directly on the colab instance but it still wouldn't download.
I don't understand what I am doing wrong here. I read the closed thread for downloading files but the first post is from back in 2019 and it doesn't work.
The other question I have is about only getting the Audible Plus Catalog. I see the plan for it is named "Audible-AYCL" which is not included in plans[]. I created a function for this and I got around it but it would be nice if it was updated.
### My whole code:
!mkdir /content/audible
import audible, urllib, cv2, json
from google.colab.patches import cv2_imshow (I am running this in google colab)
DIR_PATH = "/content/audible"
email = "xx"
pasword = "xx"
country = "xx"
def cb(captcha_url):
urllib.request.urlretrieve(captcha_url, "/content/audible/captcha.jpg")
image = cv2.imread('/content/audible/captcha.jpg')
cv2_imshow(image)
print(captcha_url)
answer = input("Answer for CAPTCHA: ")
answer = str(answer).strip().lower()
return answer
!rm /content/captcha.jpg
auth = audible.Authenticator.from_login(
email,
pasword,
locale = country,
with_username=False,
captcha_callback=cb
)
auth.to_file(DIR_PATH+country)
auth = audible.Authenticator.from_file(DIR_PATH+country)
client = audible.Client(auth)
body = {
"supported_drm_types" : [
"Mpeg",
"Adrm"
],
"quality" : "High",
"consumption_type" : "Download"
}
token = client.post("1.0/content/1665074620/licenserequest", body)
print(json.dumps(token, indent=3, sort_keys=True))
Looking forward to solving this problem. Will update if I find something new.
I‘m downloading aaxc files with my audible-cli
package using an authenticated client and the User-Agent Audible/671 CFNetwork/1240.0.4 Darwin/20.6.0
! You can try it yourself this way:
import audible
import httpx
auth = audible.Authenticator.from_file(...)
aaxc_url = "..."
headers = {
"User-Agent": "Audible/671 CFNetwork/1240.0.4 Darwin/20.6.0"
}
with httpx.Client(auth=auth, headers=headers, follow_redirects=True) as client:
resp = client.get(aaxc_url)
Audible Plus Catalog producsts are marked in is_ayce
(all you can eat)! So you only have to check if this key is True.
I'll hope this help you!
Edit:
Forgot to mention, that the offline_url
is the correct aaxc download url!
Thanks for the help. I later found out that you provided examples in the repo and everything works great now. A few things to note, when i download audible wit pip3, it downloads version 0.4.3(or something, current version 0.7.0) and it gives error for
audible.Authenticator.from_login_external
because of version incompatibility.
I used the master branch for installation which solved the problem. It could be because I messed something up somewhere, but still letting you know just in case.
I still can't find the Audible plus catalog. Can you give me an example of what you meant by is_ayce
?
If it is mentioned here then while calling GET 1.0/catalog/products
with plan = "AllYouCanEat"
it requires in_plan_timestamp
.
What should I put in in_plan_timestamp
?
Thank you for the information about the pip3 installation. I will take a look on this.
The is_ayce
key can be found only in the library. I thought it where in the catalog too, nur it isn't. The in_plan_timestamp
should be in this format 2000-01-01T00:00:00Z
but I'm not sure! In my country Audible Plus is not available, so I can't test this. Maybe some other here can help?
I read the documentation again and yes, it is significantly different than the products section.
For not having an account in audible plus country, I found a workaround.
I noticed today that you can make the API calls without having a membership at all (well except getting license). API calls such as
https://api.audible.ca/1.0/catalog/products?response_groups=product_plans&num_results=50
will give you the same results as you would get with
client.get('catalog/products', response_groups='product_plans',num_results=50)
Now as for getting the plan details, the following url
https://api.audible.ca/1.0/catalog/products/B07NYTNX9J?response_groups=product_plans&num_results=50
will show you the following
{ "product": { "asin": "B07NYTNX9J", "plans": [ { "end_date": "2025-03-01T12:00:00.00000Z", "plan_name": "Audible-AYCL", "start_date": "2022-03-01T08:00:00.00000Z" } ] }, "response_groups": [ "always-returned", "product_plans" ] }
This book is in the plus catalog in Canada and its name is Winter Dark.
I am specifically interested in "plans": [ { "end_date": "2025-03-01T12:00:00.00000Z", "plan_name": "Audible-AYCL", "start_date": "2022-03-01T08:00:00.00000Z" } ] as this is different that 'is_ayce' My question is how can I get without adding plus catalog books in my library? Is there a specific way to only get plus section books as response?
I hope that you would be able to help regarding this with the direct API calls.
Edit - PS. I am renamming the issue as this is no longer a download issue
Thank you for your information!
As far as I know, Audible Plus titles have there own categories. You can check the categories of your book above and then request books for this category!
Hi all,
I am a novice and this is my first attempt at contributing something to open source. Be gentle with me.
This seems to relate to Issue #50.
I have also been looking at the plus catalogue as I am uncomfortable with archiving something I have not paid for and must one day return. For the avoidance of doubt, Audible members get access to the Plus Catalogue as part of their membership and can add a variety of audiobooks to their library for free for a period of time, or until they pause/cancel membership. Therefore, because they must be returned at some point, I feel a bit funny archiving them and then relying on my memory to manage the collection.
TL;DR:
- Using UK profiles to make api requests
-
plans
may be key to identifying whether an Audiobook is part of the Plus Catalogue -
response_groups=customer_rights
shows 4 fields inproduct > customer_rights
-
is_consumable
suggests access to the audiobook -
is_consumable_indefinitely
suggests purchase made/ownership -
is_consumable_until
suggests an expiry date whenindefinitely
above isfalse
- This date mirrors
product > plans > end_date
, suggesting it is available on the members' benefit mentioned above
- This date mirrors
A bit more
I have explored some of the API via Audible-CLI:
audible -P primary api "/1.0/catalog/products/1774247976?response_groups=customer_rights" | jq
{
"product": {
"asin": "1774247976",
"customer_rights": {
"is_consumable": true,
"is_consumable_indefinitely": false,
"is_consumable_offline": true,
"is_consumable_until": "2024-02-29T12:00:00Z"
},
"plans": [
{
"end_date": "2024-02-29T12:00:00.00000Z",
"plan_name": "Audible-AYCL",
"start_date": "2022-03-07T21:58:00.00058Z"
}
]
},
"response_groups": [
"customer_rights",
"always-returned"
]
}
Comparing the above primary profile, which has Audible membership and this audiobook in library, to the secondary profile which doesn't:
audible -P secondary api "/1.0/catalog/products/1774247976?response_groups=customer_rights" | jq
{
"product": {
"asin": "1774247976",
"customer_rights": {
"is_consumable": false,
"is_consumable_indefinitely": false,
"is_consumable_offline": false,
},
"plans": [
{
"end_date": "2024-02-29T12:00:00.00000Z",
"plan_name": "Audible-AYCL",
"start_date": "2022-03-07T21:58:00.00058Z"
}
]
},
"response_groups": [
"customer_rights",
"always-returned"
]
}
As this is totally unowned by the second profile, I think it's safe to say that is_consumable_until
represents the return date of the Audiobook based on its availability on the Plus Catalogue via membership.
I also note the entries in plans
in both responses, suggesting this may be an indicator as to whether a book is part of the Plus Catalogue or not.
Remaining questions:
- Is preventing the downloading of Plus Catalogue audiobooks by default appropriate? (I would lean towards trusting the user to manage their library instead of preventing it)
- Is adding an optional parameter to allow downloading books with
product > customer_rights > is_consumable_indefinitely = false
more appropriate? (or the other way round; parameter defaults to allow Plus Catalogue?) - Does the API vary per region?
- ~~How can I contribute to the (UK?) API documentation?~~ Found it
- Is an open issue 'fair game' despite its age? (Sorry if not)
I am not yet skilled enough to translate any of this into code suggestions, but I hope to have added some value and appreciate your work.
Kind regards, Dale
Hello DaleQuest,
thank you for sharing your discoveries. The customer_rights
togehter with the plans
response section seams to be the right place to detect Audible Plus titles. Let's see how I can incorporate this into my project.
Is preventing the downloading of Plus Catalogue audiobooks by default appropriate? (I would lean towards trusting the user to manage their library instead of preventing it)
I totally agree with you. Therefore, audible-cli
also supports the download of Plus titles. Until now, titles could only be downloaded if they were added to the library before. Now I've tried a licencerequest
with an AYCL title that I didn't add before. And the license was granted. Maybe this could be a feature for audible-cli
to download books directly from the catalog by searching there name/asin.
Does the API vary per region?
No. In any case, I don't know anything else.
How can I contribute to the (UK?) API documentation?
The source code for the API documentation is located here and published here.
If you want to contribute:
- Fork
audible
. - Create a new branch.
- Make your changes to
external_api_rst
including commit and pull. - Open a pull request to my repo (please don't open a PR to the
master
branch). - After a review I will merge your changes and readthedocs will rebuild the API documentation.
For describing the API please use httpdomain. It may still be important to mention that the documentation is written in the reStructuredText (rst)
format. Here you can read about these format.
Is an open issue
fair game
despite its age? (Sorry if not)
I like to leave issues open so that you can quickly find important things and possibly new comments can be added, even after a long time. Maybe they can be moved to the discussions in the future.
This issue has not been updated for a while and will be closed soon.
This issue has automatically been closed due to no activities.