Leseratte10 / acsm-calibre-plugin

Calibre plugin for ACSM->EPUB and ACSM->PDF conversion.
https://www.mobileread.com/forums/showthread.php?t=341975
GNU General Public License v3.0
653 stars 23 forks source link

Returning book doesn't work #31

Closed p1nkyy closed 1 year ago

p1nkyy commented 2 years ago

Bug description

Hello, I mainly borrowed books from Overdrive or BorrowBox. Returning books don't really work. I click the arrow, it said 'Book is returned' and it disappeared from the Show Loaned Books list, but when I get back to the library's 'Loan' page, the book is still there and not yet returned. Only when I click Return manually will the book disappear. I currently am waiting for 1 book that I returned from the plugin to see whether after several hours it will be returned in Overdrive. I don't know what debug process to include but let me know what to do so I can help. Thanks!

Operating system

Windows

Which version of Calibre are you running?

6.0

Which version of the DeACSM plugin are you running?

v0.0.16

Further information

No response

Leseratte10 commented 2 years ago

Can you test if returning books through ADE works fine? Maybe the library just didn't implement book returns correctly and it would fail with ADE, too, and only works through their website.

If it works just fine with ADE, can you start calibre in debug mode (The drop-down menu "Preferences", then "Restart in debug mode"). Once you're in debug mode, import a new ACSM file from that library and then try to return it again, then close Calibre. After that the log file should open in a text editor, then just post that log here and I'll check if I can see anything that looks wrong.

p1nkyy commented 2 years ago

Yes my ADE is indeed very unstable. It keeps freezing every second, even when I do nothing at all and I need to end it via Task Manager. Can this affect it? I can return the books fine though via ADE when it's working. de-ACSM also don't always work in the first time. Here are the log of trying to process ACSMs and the ACSMs stay as ACSMs still & the log of trying to return books.

https://tusfiles.com/w4jf74g651u0 https://tusfiles.com/5upzftwh6czi

Leseratte10 commented 2 years ago

Okay, the first error (ACSM not turning into an EPUB) is because the overdrive server returned a 404 HTTP error while trying to download the book. This is usually a server error / temporary outage at overdrive (or maybe the result of an overzealous antivirus / security / crap program like that). I can try to have the plugin retry upon encountering the first 404 error but I don't think that has a high chance of working. You'd probably get similar errors in ADE from time to time. Does this error go away when you import the same ACSM file later, or re-download the ACSM file?

As for returning books, I currently don't know why that didn't work. I'll add some more debug logging to the plugin for book returns and will let you know when that's done so you can send another debug log.

p1nkyy commented 2 years ago

No, I rarely encountered ADE unable to process ACSM. This time, they return with "Error getting license. License server communication problem. E_ADEPT_NO_FULFILLMENT_RESULT" with 2 books. But maybe you're right, it's OD that is currently down. I kept trying to process the ACSMs and finally they work even though it requires many many tries. I tried to use ACSM from Google Play Books and it works immediately. Just need the Returning feature to work because in BorrowBox, once you process it through ADE, you can only return the book via ADE and not the site (in OD we can still go back to the library and return manually) and my ADE is too unstable and almost unusable at the moment to be able to do that. Thanks for responding to me so far!

Leseratte10 commented 2 years ago

Interesting. I've just had this exact issue (book return apparently successful but the book is not returned at the library) happen with the library I'm regularly using. I wonder if Adobe has changed something in how library returns work, because I definitely remember successfully returning books in the past. And I can't see anything useful in my logs either.

I guess I need to spin up ADE2 again on a Windows machine and compare dumps ...

p1nkyy commented 2 years ago

Yeah if you could look into it, I'd be immensely grateful. My ADE is literally unusable, just moving it around will freeze it and no amount of install & uninstalling could fix it. I am so thankful for your plugin because I don't have to deal with ADE but I really need the return book feature because BorrowBox (unlike Overdrive) only gives you option to return from the ADE if the book is processed through ADE.

Leseratte10 commented 2 years ago

Okay, I just messed around with ADE a bit and found some parts of the book return process that my plugin doesn't implement correctly. ACS 5 (which was introduced with ADE 3 and which most book stores used in the past) didn't care, but ACS 6 (introduced with ADE 4) apparently does.

I'll try to get this implemented into the plugin ASAP and will let you know when there's a new test version.

Leseratte10 commented 2 years ago

Interesting. I fixed that bug but it's still not working ...

Leseratte10 commented 2 years ago

Hm. Did not manage to get it to work reliably, but I don't want to mess with the library always loading and returning books. I'll leave this issue open, maybe I'll get another idea later.

Leseratte10 commented 2 years ago

@p1nkyy Would you mind testing if c6b9e5c59bf6fe965b959a6ee208d546b9118146 fixes the issue? I believe I found and fixed the bug.

EDIT: Note this will only work for books first downloaded with that test version, not for books you've already downloaded with the old version.

You can download that version from the Github Actions page. The issue got auto-closed because I mentioned the issue number in the commit message, if this does not fix the issue just open it again.

p1nkyy commented 2 years ago

Sure, I will test it and get back to you. Thanks a lot!

p1nkyy commented 2 years ago

Yes it works!! You're a genius! Thanks a lot!!

Leseratte10 commented 2 years ago

Great, I will include that fix in the next version then. Thanks for testing.

p1nkyy commented 2 years ago

Great, I will include that fix in the next version then. Thanks for testing.

Will I get auto update notif if I'm running this alternative version?

Leseratte10 commented 2 years ago

Good question. I assume yes, but I've never tested it before.

p1nkyy commented 2 years ago

Hello found 2 bugs here, if you could re-open this issue, thanks. (I couldn't maybe because you're the author and you closed it)

  1. Processing more than 1 ACSM files from 1 library will show only 1 titles in the 'Loaned Book List'. I need to add the others one by one later on OR add them 1 by 1 since the beginning and not just a bunch at once.

  2. There is 1 instance of returning book didn't work, the title is still in BorrowBox, BUT when I re-downloaded and processed the ACSM, they don't work or don't get converted to .ePUB. Usually in normal ADE the message given back would be E_BAD_LOAN_ID or E_LICENSE_ALREADY_RETURNED (not the exact wording) So: returning > book still show up > tried the same ACSM > not converted into epub > downloaded fresh ACSM from the Borrowbox > still doesn't work

log 3.txt

Leseratte10 commented 2 years ago
  1. That's interesting. I guess I never tested adding multiple books from a library at once. I'll take a look at that.
  2. If, during redownload, you get the error E_LIC_ALREADY_RETURNED (as it's the case in your log file), that means according to Adobe, the book return was definitely successful and Adobe thinks the book's been properly returned. Why that information didn't make it to BorrowBox - no idea. How many books did you test? Was this like 1 out of 3 where it didn't work (which could be a bug in the plugin) or more like 1 out of 20 (which might as well have been a small glitch or bug at BorrowBox)? If this happens always / very often, I'd need to see a log of the (seemingly successful) return of a book that later still shows up as not returned.
p1nkyy commented 2 years ago

E_LIC_ALREADY_RETURNED only happened this one time with de-ACSM. Previously with my very unstable ADE, if I am in the middle or returning and my ADE froze, this will cause this error to happen, that ADE said it has been returned but Borrowbox still think it hasn't. I have several books that I can't return at the moment in BorrowBox due to this (ADE froze all the time).

Because it can't be predicted when this error would happen, don't think I'd be able to capture it as I'm not using the debug mode all the time but could it be internet connection problem?

Leseratte10 commented 2 years ago

Could be, yes. While the process of returning a book to Adobe (which is what marks the loan as returned so you'd get E_LIC_ALREADY_RETURNED on another download attempt) is standardized and identical for each library (which means it's easier for me to debug), the process of returning a book to the actual library is different for each library, so it's difficult or even impossible for me to add proper error checking and/or having the plugin verify if the book return was really successful.

So I guess we'll mark that as a one-off error, unless you notice it happen more often.

As for the loan record issue, I've just had that happen as well while trying to fulfill three ACSM files at once. How many did you try to add at once?

Looking at the log from my attempt, this most likely happens because the process is like "get the existing loan list, add the new book to it, then write back the new list that has one more book". But since Calibre is processing all three ACSM files in parallel and not one after the other, what probably happens is that the loan records for two books were created at the exact same time, both "instances" of the plugin grabbed the then-current loan list, each added "their" book to the copy of the list, and then wrote their list back to the config file, when one instance overwrote the changes of the other.

So, I'll have to make that process atomic so multiple instances don't overwrite data. I'll look into that.

p1nkyy commented 2 years ago
  1. Yes, I also think it should be a one-off incident.

  2. Yes, I now remembered I processed 3 at once at first and the other instance defo more than 3 as well. However, I have since processed 30 new books using the 0.0.17 and all titles are accounted for in the Loaned List. Not all 30 at once, but perhaps 5-10 at once.

p1nkyy commented 2 years ago

image

Hello, is this the intended behavior? Old books don't get removed from the Show Loaned List after their loan period ends. Thanks!

Leseratte10 commented 2 years ago

That's definitely not intended, books are supposed to disappear from that list once the time is up. I'll take another look.

Leseratte10 commented 1 year ago

The bug with old entries not always getting removed from that list is now fixed with the latest commit.

Now that loaned books and loan management should work as intended, I'm going to close this issue and open a new one for the still-existing issue that happens when importing multiple ACSM files at once, as that doesn't really have anything to do with returning books.

p1nkyy commented 1 year ago

Sorry for the silly question but do I re-download v0.16 to be able to get this issue solved?

Leseratte10 commented 1 year ago

Nope, the 0.0.16 download hasn't been changed. The bugfix will be in the next version that's not released yet. If you want, you can download the test version from https://github.com/Leseratte10/acsm-calibre-plugin/suites/8680259517/artifacts/391182561

Leseratte10 commented 1 year ago

The Submit button automatically becomes available once all the necessary fields are filled out (Title, Description, Operating System, Calibre version, plugin version). If that doesn't work for some reason you can also click on the "Open a blank issue" link and open an issue without the form.