teticio / kindle2pdf

Convert owned Kindle books to PDF without needing a device. Good for viewing on a ReMarkable.
BSD 3-Clause "New" or "Revised" License
23 stars 0 forks source link

"Please log in to https://read.amazon.com" on Linux #8

Open singlerider opened 5 days ago

singlerider commented 5 days ago

Chrome: Version 130.0.6723.91 (Official Build) (64-bit) OS: Arch Linux x86_64 Kernel: Linux 6.11.6-arch1-1 App version: PyPi kindle2pdf==0.4.4

Reproduction steps:

  1. Log into https://read.amazon.com
  2. Close all browser windows and processes (killall chrome)
  3. Verify that xdg-open https://read.amazon.com opens browser with valid session
  4. Run application:
┌─[shane@MYHOSTNAME] - [~] - [Tue Nov 12, 09:58]
└─[$] <> kindle2pdf SERIALNUMBERGOESHERE           
Please log in to https://read.amazon.com.

This is all I get. No error messages or indication that something is wrong.

singlerider commented 5 days ago

This seems to have something to do with recent updates to the Chrome browser.

This may fix things in the future, but did not for me when I changed the browser_cookies3 dependency to this ref: https://github.com/borisbabic/browser_cookie3/pull/215

BUT, I was able to add two lines to src/kindle2pdf.py to force my Firefox session to be used:

        cj = browser_cookie3.firefox()
        r = requests.get("https://read.amazon.com", cookies=cj)

Now, I have a DRM-free PDF. Action items from this could include the ability to include a preferred browser using a command line flag such as --preferred_browser, etc.

singlerider commented 5 days ago

For the above to work consistently, I also have to add a time.sleep(10) afterwards or else the session-id cookie doesn't show up for some reason.