07-21-2019, 02:12 AM | #1 |
Enthusiast
Posts: 36
Karma: 10
Join Date: Feb 2017
Device: Kobo Aura H2O
|
Force-updating books on a Kobo H2O from code
I'm writing a command-line tool to update online serials on my Kobo using Calibre and the Kobo plugin. From testing I've done using the GUI, the Kobo doesn't seem to recognize that a book file has changed unless I first delete it from the Calibre database and the Kobo, then add the updated file as a new book.
I want to be able to do this same thing by running a plugin from the command line (written as an __init__.py that I then execute with calibredb). However, while there's an API function to remove books from the database https://manual.calibre-ebook.com/db_...e.remove_books, it's not clear to me how I make it remove books from the device also. Is there a way to do this? Alternately, I could have my code delete books directly from the file system on the Kobo, but how do I go from a book in the Calibre db to the corresponding file on the Kobo's file system? With simple heuristics like matching title I could end up deleting the wrong book. Is there another way of forcing the Kobo to update a book other than this delete-and-recreate flow? |
07-21-2019, 04:33 AM | #2 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
What problem are you actually trying to achieve? What you say you are doing doesn't quite make sense for anything I can think of. Nothing I can think of would need you to remove the book from the calibre library.
As you mention updating online serials, I think your problem is that when you to send an updated copy of the book to the Kobo device, the ToC and metadata do not get updated. If that is the problem, there is something really simple you can do: Turn off the "Do not treat replacements as new books" option in the driver. This is on the second tab of both the KoboTouch and KoboTouchExtended drivers. For updating the metadata, there are options in the driver to do this each time the device is connected. The reason for this is that when the Kobo device sees a new sideloaded book, it imports details from it to the internal database. These details include the metadata and the ToC. When a book is changed (based on file size), it deletes the book details from the internal database and imports it as a new book. But, this means you lose the reading status, annotations and collections. The early firmware didn't do this. If you updated a book, it just accepted it. When this changed, I worked out how to prevent it and updated the KoboTouch driver (and hence the KoboTouchExtended driver) to handle resending a book this way. My logic was that if you were only making changes to things like spelling or styles, you didn't want to lose the reading status. And, if you made deeper changes you could delete the book first. That was the best of both worlds. But, due to several requests, I added the above option to the driver last year. That way people could chose which behaviour they want. The option is on by default as that is what the behaviour was before the option was added. I think turning off the option will do what you want. For updating the book in calibre, I normally select the book in the list and drop the updated version in the details pane. That replaces the version in the library without changing the metadata. I'm pretty sure there is a way to do this using the command-line, but, I've never needed try. |
Advert | |
|
07-21-2019, 05:43 AM | #3 |
null operator (he/him)
Posts: 20,572
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
07-21-2019, 06:45 PM | #4 | ||
Enthusiast
Posts: 36
Karma: 10
Join Date: Feb 2017
Device: Kobo Aura H2O
|
Quote:
However, in Calibre itself, because I had an existing copy of this book, I now end up with two copies of the same book (one with the old file, one with the new), though only one copy can be on the device at one time. How does this option interact with the main Calibre option to "Auto-merge existing books" under Adding Books in the Preferences menu? Quote:
1. Add calibredb add_format <book_id> <file_name> 2. Unplug Kobo. 3. Check on the Kobo that the book didn't update (the underlying file, the metadata, and the ToC were still using the same version). 4. Plug Kobo back in to the computer. 5. Start the Calibre GUI, find the correct entry, and hit "Send book to device." 6. Close Calibre GUI and unmount the Kobo file system. 7. Open the book. The first time I tried to open it, the Kobo told me that I was trying to open an Adobe DRM-protected Epub and reset my reading position. This is an AO3 book, so it's definitely not DRMed. (I didn't have bookmarks so I don't know if it reset that too.) I could open it and read it on a subsequent attempt, but it seems something with the database was slightly broken. I'm assuming this is the matching DB function to the CLI add_format: https://manual.calibre-ebook.com/db_...che.add_format. What function do I need to call to execute the second step of this flow, getting it to send the updated book to the device? |
||
07-21-2019, 08:34 PM | #5 | |||||
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
Quote:
Quote:
Quote:
Quote:
There doesn't seem to be a send-to-device command for the calibredb. But, there is an "export" command which will save the book to disk. You could use this with the path on the device. That would actually bypass all the driver options which would mean the device would import it as new all the time. |
|||||
Advert | |
|
Tags |
calibre, command line tools, kobo |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
All Books Flipped to Unread (Kobo H2O v2 | Hartsock | Kobo Reader | 4 | 01-16-2019 04:11 PM |
Kobo Aura H2O 2nd Edition vs old Kobo Aura H2O screen dimentions. | iXPert12 | Kobo Reader | 1 | 09-18-2017 09:35 AM |
Force updating library? | rantoie | Kobo Reader | 8 | 02-02-2014 04:31 PM |
Updating Books on the Kobo Arc7 | hanatoro | Android Devices | 0 | 01-12-2014 06:45 AM |
Kobo Books: Save $5 Aug 25 thru Sept 1 [CODE APPEARS TO BE INVALID] | KjellM | Deals and Resources (No Self-Promotion or Affiliate Links) | 14 | 08-28-2010 12:59 PM |