Git Product home page Git Product logo

Comments (12)

mkb79 avatar mkb79 commented on May 25, 2024

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:
If you download a book with the licenserequest method, it downloads the book in aaxc format. This format can’t be encrypted at this moment (I think so)! Please read #3 for more informations how to download books in aax format.

Regards

from audible.

lanouettea avatar lanouettea commented on May 25, 2024

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.

from audible.

mkb79 avatar mkb79 commented on May 25, 2024

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

from audible.

lanouettea avatar lanouettea commented on May 25, 2024

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

from audible.

mkb79 avatar mkb79 commented on May 25, 2024

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.

from audible.

mkb79 avatar mkb79 commented on May 25, 2024

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}")

from audible.

lanouettea avatar lanouettea commented on May 25, 2024

I still receive a 500 error with no details on the request

from audible.

mkb79 avatar mkb79 commented on May 25, 2024

Have you register a device and use sign request method or you use access token authentication? You can test this with print(auth.adp_token). If you get a not None response you use sign request method.

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)

from audible.

lanouettea avatar lanouettea commented on May 25, 2024

print(auth.adp_token) returns None. So I guess I am using the sign request method.

The code above returns the following:
Headers({'x-adp-host': 'H3K246P9RFUS2E', 'content-length': '87', 'date': 'Fri, 24 Jul 2020 15:30:13 GMT', 'connection': 'close', 'server': 'Amazon Web Server'})

from audible.

mkb79 avatar mkb79 commented on May 25, 2024

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.

from audible.

lanouettea avatar lanouettea commented on May 25, 2024

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.

from audible.

mkb79 avatar mkb79 commented on May 25, 2024

That‘s great to hear!

I will adjust my download example to make sure adp_token is present in auth file.

from audible.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.