jgoguen / calibre-kobo-driver

An extension of the existing KoboTouch driver provided with Calibre. This plugin allows modifying ePub files to enable extra Kobo features. I am providing code in the repository to you under an open source license. Because this is my personal repository, the license you receive to my code is from me and not my employer.
GNU General Public License v3.0
326 stars 21 forks source link

"This book can't be opened" #5

Closed giorgio130 closed 11 years ago

giorgio130 commented 11 years ago

I have a couple of books that, when transferred with the extended driver, can only show the cover; when you try to change page a popup comes up saying "This book can't be opened" (approximated translation). If I move the file out from the device and then manually in (so that the database is purged from references to it) they work without problems. I am also having another issue with chapters that seem to open in random order if I let the driver to add references to them in the database, while they are read in order if no changes to the database are made. Is there any reason to add rows to the database relating to sigle chapters? I just see problems coming from this right now, but maybe it enables some feature I'm not aware of.

jgoguen commented 11 years ago

Right now there is no reason at all. Try using the no-database branch, it doesn't touch the Kobo's internal database at all. The master branch probably needs a README update to encourage using no-database instead.

The current database code is based on what I observed was changed when I added books and let the Kobo do its processing. It really won't have any useful effect until I can figure out how to stop the device from doing its own processing on new books. The whole point if that huge chunk of code is simply to add the rows that the Kobo itself adds and to set series information on the initial upload. Currently that fails because the Kobo overwrites it during its own processing. See bug #1.

Could you forward a couple of the books that cause this to '''removed''' please?

giorgio130 commented 11 years ago

Thank you, I've sent you some books that fail. Regarding avoiding reprocessing, maybe it would work putting the books in the folder where kobo stores its kepub, a subfolder of /mnt/onboard/.kobo.

jgoguen commented 11 years ago

Not a bad idea. Calibre won't allow that as a path, it forbids any path component starting with a period, but perhaps there's a function I can override to force it.

Can you try the no-database branch and let me know if adding books with that code displays them correctly?

jgoguen commented 11 years ago

Can you try this with the updated code? I'm not able to make this happen with any of the books I have now.

There was an issue that prevented some of the database rows from being added and the ones that were being added may not have necessarily had the correct content IDs associated with them. Depending on the order of documents within the files, this could have had some interesting effects. I still can't explain why one book looped on the cover page, but that seems fixed also.

giorgio130 commented 11 years ago

I've tested the current code in the master branch and I get this:

calibre, version 0.9.7 ERRORE: Errore: Errore di comunicazione col dispositivo

'NoneType' object has no attribute 'xpath'

Traceback (most recent call last): File "site-packages/calibre/gui2/device.py", line 85, in run File "site-packages/calibre/gui2/device.py", line 551, in _upload_books File "calibre_plugins.kobotouch_extended.driver", line 273, in upload_books AttributeError: 'NoneType' object has no attribute 'xpath'

It seems to be related with the previous issue, of the books that I've tested only thos which had that problem are showing this behaviour, and some that I did not test so I can't tell for sure.

giorgio130 commented 11 years ago

well, wait, this errors out but the books are present on the device. I wait for your opinion to close this because I don't know if this way changes are made to the database or not.

jgoguen commented 11 years ago

So, first thing (although I don't think it would cause this issue), your calibre version is one day away from being 10 full weeks (and 10 full versions) out of date. You really should update. My code is only tested on the current version of calibre (currently 0.9.16, tomorrow it will be 0.9.17); although it should work on the entire 0.9.x series, I make no guarantees that anything but the current release version will work at all and if I can't reproduce an issue on the current release I will require that you try again after upgrading.

With that said, this error is not one that I'm sure if I should handle or allow to continue. It will depend very strongly on why this is happening. The position of the error indicates that you have an empty or invalid NCX file. I know that EPUB3 removes the TOC from the NCX and delivers it as part of the OPF file, perhaps that's what's happening here. Can you send me the book this fails on so I can investigate the contents?

jgoguen commented 11 years ago

Yes, this one was rather embarrassing. I made an assumption constructing the path to the TOC file, then made a code change that made my assumption invalid, and never updated the code constructing the path to the TOC file. This should only affect the master branch.

giorgio130 commented 11 years ago

Everything looks to be working well now. Thanks, I'm closing this, feel free to reopen though.