jdalbey / libbyfetch

A Python program for downloading MP3 audiobooks from libbyapp.com website
MIT License
17 stars 5 forks source link

Not able to fetch Audiobook URL #23

Open JaegerMaster opened 4 days ago

JaegerMaster commented 4 days ago

Script is timing out after waiting to fetch the Audiobook URL. Happening with all books and multiple libraries

`Initializing webdriver. Reading library card configuration file. Loading library page for 'wccls' Starting signin to Washington County Cooperative Library Services. Library card number entered. PIN entered. Sign In completed. Loans page loaded.

  1. Beneath Stone and Sacri
    Enter the number of the desired title: 1 Opening Audiobook. Retrieving audiobook url... waiting waiting waiting waiting waiting waiting waiting waiting waiting waiting Timed out waiting for audiobook url. Page says: An error was encountered while opening this audiobook.`
jdalbey commented 4 days ago

Oh no, I'm sorry this is happening for you. I discovered this problem and reported it as issue #17 so you can read about it there. It's possible that Libby is blocking users who are downloading MP3's with libbyfetch. (See 'Warning' in README). If this is true that would be very bad. I have installed a fix 57c364b418224680316bf4113c581bddd43f26c5 so that it won't timeout and instead displays an error. But that doesn't repair the underlying issue, which is that Libby is not allowing your card to access materials. Try to manually play an audio book and see what happens.

jdalbey commented 4 days ago

Duplicate of #17

JaegerMaster commented 4 days ago

Hi @jdalbey sorry for opening this issue as this started happening suddenly and I am using it with v1.04 so don't think it is related to #17.

jdalbey commented 4 days ago

@JaegerMaster I'm sorry for the confusion. The behavior you reported above, where libbyfetch prints "waiting" ten times and then says "Time out" is what results from the fix I mentioned above (https://github.com/jdalbey/libbyfetch/commit/57c364b418224680316bf4113c581bddd43f26c5). I see now that the message displayed doesn't provide very much troubleshooting information. I can add a better explanation in the future.

To see what is causing the timeout, I suggest that you manually login to libbyapp.com and try to play an audiobook you have on loan. I'm guessing that it won't allow you to access the audiobook. If that's the case then libbyfetch won't work for you either.

JaegerMaster commented 4 days ago

@jdalbey I am able able to play the audiobook on libbyapp.

Also, this is happening on multiple cards, tried it on multiple devices to rule out IP blocks.

I am not sure if this is something about the card being blacklisted by Overdrive.

JaegerMaster commented 4 days ago

If needed, I can share the library card details to test this further.

jdalbey commented 4 days ago

@JaegerMaster Thanks for the additional info. I see you are able to play the audiobook on libbyapp. So that sounds like your issue is slightly different than the one previously reported so I'm going to reopen this issue.

jdalbey commented 4 days ago

@JaegerMaster You said that "this started happening suddenly" so you were able to download MP3 files with previous versions of libbyfetch? Did the error occur when you updated to the current version?

JaegerMaster commented 4 days ago

Hi, I was able to download with 1.04 as well. Worked with 2-3 books. Then suddenly started happening with the 4th book and now happens with everything. I tried 2 different cards. Will try with a 3 card and let you know. Will mail you the card number.

jdalbey commented 4 days ago

That's odd that it worked for a few books then stopped. Quite a head scratcher.

JaegerMaster commented 4 days ago

Not working with the 3rd card as well. Don't think this is an IP block as didn't work on a different machine as well. If you can add a more detailed log option, I can help with the logs.

jdalbey commented 3 days ago

@JaegerMaster Thanks, at last I was able to reproduce the error. I've gathered these two examples for diagnosis:

  1. Here's the developer console log from a successful audiobook load after logging in manually (Firefox).

  2. Here's a log of HTTP Requests captured by libbyfetch form a run that produced "An error was encountered ..." message trying to open an audiobook.

By studying these and looking for discrepancies I hope to identify why the manual process works but libbyfetch fails.

JaegerMaster commented 3 days ago

Thanks @jdalbey for looking into this.

flyswimr commented 3 days ago

Were the books that were tested already checked out and accessed at least one time prior via libbyapp.com or Overdrive, and prior to trying any of the LF scripts? I seem to recall I had the same thing going on until I checked out a new audio book and tried to access via libbyapp.com. At that point could not listen via the browser or access via LF.

jdalbey commented 3 days ago

@flyswimr Very interesting. To clarify, you were able to listen to audiobooks via libbyapp.com, and you tried Libby Fetch and it worked okay? But after checking out a new audiobook, you were no longer able to access any loans via libbyapp.com?

JaegerMaster commented 3 days ago

Yes. Tried playing the book on libbyapp and then downloading using the script. Didn't work.

lsixecho commented 2 days ago

I disabled headless mode so I could see where it failed and it displays the audiobook book but underneath says "An error occurred while opening this audiobook."

Screenshot 2024-11-23 at 1 27 35 PM


This audiobook plays perfectly on a normal chrome window, just not the libbyfetch window.

jdalbey commented 2 days ago

@lsixecho Thanks for confirming this behavior. This seems like the same error others are experiencing. When in headless mode libbyfetch will display the error after attempting to retrieve the audiobook URL times out (as seen in the initial reporting of this issue). Do you recall if you acquired the loan of this audiobook BEFORE you tried to download any other books with libbyfetch? Or had you downloaded other audiobooks with libbyfetch and then subsequently acquired this one on your "shelf".

I'm curious what will happen if you now acquire a new audiobook loan and try to play it manually (not with libbyfetch). Does that work? Are you able to checkout additional audiobooks and listen to them through the web browser? If you have time to try it let me know what happens.

lsixecho commented 2 days ago

@lsixecho Thanks for confirming this behavior. This seems like the same error others are experiencing. When in headless mode libbyfetch will display the error after attempting to retrieve the audiobook URL times out (as seen in the initial reporting of this issue). Do you recall if you acquired the loan of this audiobook BEFORE you tried to download any other books with libbyfetch? Or had you downloaded other audiobooks with libbyfetch and then subsequently acquired this one on your "shelf".

I'm curious what will happen if you now acquire a new audiobook loan and try to play it manually (not with libbyfetch). Does that work? Are you able to checkout additional audiobooks and listen to them through the web browser? If you have time to try it let me know what happens.

Ok, I tried another couple audiobooks on different cards and they all have the same waiting/timeout error. I tried playing first, then downloading first alternatively. They all play normally during a default session of chrome, regardless of being played first or download attempted first, so I am guessing it's a selenium issue. I have previously downloaded many audiobooks before this sudden error and none since. Any other ideas for debugging?

jdalbey commented 2 days ago

@lsixecho Thanks, that's a very interesting report. It's good that you can still play audiobooks through the browser. That is no longer working for me; even the browser gives me the "error encountered" message. If you would like to help debug I could use some logs from using Libby in the browser. Here are some directions for how to Capture HTTP requests from the browser. If you could capture a complete session using Libby to sign in, go to your loans page, and play an audiobook. Then post the resulting file containing HAR log as an attachment to a comment here. That way I can compare a session that succeeds against one that fails and see what's happening. Also if you could report what Settings you have enabled in Chrome regarding Cookie handling.

jdalbey commented 1 day ago

I found that one cause of "An error was encountered" message when using Libby in the browser is if you have ad blocker or privacy extensions enabled. Try disabling ad blocker or similar privacy extensions while using libbyapp.com.

OGQueenie commented 1 day ago

I too am experiencing this issue, I can access the books just fine via the app or browser, I have yet to successfully download a book via your program though

ApKNJ commented 1 day ago

I'm seeing this issue as well. I'm testing on a new Linux VM set up just for this purpose with a fresh install of Chromium, no extensions. Issue occurs on a book that was already on loan before trying lf for the first time, and one that was borrowed after trying lf, no difference. Both books will play in Chromium normally.

lsixecho commented 12 hours ago

@lsixecho Thanks, that's a very interesting report. It's good that you can still play audiobooks through the browser. That is no longer working for me; even the browser gives me the "error encountered" message. If you would like to help debug I could use some logs from using Libby in the browser. Here are some directions for how to Capture HTTP requests from the browser. If you could capture a complete session using Libby to sign in, go to your loans page, and play an audiobook. Then post the resulting file containing HAR log as an attachment to a comment here. That way I can compare a session that succeeds against one that fails and see what's happening. Also if you could report what Settings you have enabled in Chrome regarding Cookie handling.

Here are the HAR files. I'm not sure what you mean but cookie settings, presumably just the default, but they certainly haven't changed and downloading was working before this error.

Har Files.zip

Not-working.har is the libbyfetch session (logs turned on during pause to select audiobook, which is the first change you get)

Working.har is normal chrome session that plays audiobook (the full capture, although libbyfetch doesn't fail until the play stage anyway)

jdalbey commented 9 hours ago

@lsixecho Thanks for taking time to create these HAR files. I'm looking into this problem but haven't yet isolated what's going wrong.