View Single Post
Old 04-11-2021, 02:40 AM   #2202
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Beta - Update ToC in device database

Attached (assuming I remember to), is a beta with a new function. This is to update the ToC in the database for books on the device. The function checks for any differences, displays what books are different and then lets you update the books or the ToC.

At this point the ToC updating only supports kepub and epub on the device. And supports both epub2 and epub3.

The function works by:
  1. Connect the device and wait for the connection jobs to finish.
  2. Select some books in the library.
  3. Select the "Update TOC for Selected Books" option in the plugins menu.
  4. The function will analyze the ToC for the book in three places: calibre, on the device and the database on the device.
  5. A dialog is displayed showing the ToC status of the books.
    Click image for larger version

Name:	KoboUtilities-UpdateToC.png
Views:	2031
Size:	26.6 KB
ID:	186533
  6. On the dialog, you can select books to send to the device or update ToC in the device database.
  7. Press the "Send Books" or "Update ToC" button and the action will be taken.

The dialog shows the results of the comparison and hence the status. The columns shown are:
  • Overall status of the book as an icon.
  • Title of the book.
  • Author of the book.
  • "Library ToC" - The number of ToC entries in the book in the calibre library.
  • "Library Format" - The format of the book in the calibre library.
  • "Kobo ToC" - The number of ToC entries in the book on the device.
  • "Kobo Format" - The format of the book on the device.
  • "Status" - Shows if the book matches or if it needs to be sent to the device.
  • "Send" - Checkbox to for whether to send book when the "Send Books" button is pressed. It will be selected if the above status indicates the book on the device needs to be updated.
  • "Kobo Database ToC" - The number of ToC entries in the database on device.
  • "Status" - Shows if the ToC in the database needs to be updated compared to the book on the device.
  • "ToC" - Checkbox to for whether to update the ToC in the database when the "Update ToC" button is pressed. It will be selected if the ToC status indicates the database on the device needs to be updated from the book on the device.
  • "Reading Position" - Reading position in the database. Currently this is not used.
  • "Comment" - Describes the status of the book and what needs to be done.

The three status columns use the following icons to show the status:
  • Green tick - ToC matches and nothing needs to be done.
  • Device icon with arrow - The ToC does not match between the calibre library and the book on the device.
  • ToC icon with hand - The ToC needs to be updated in the database on the device.
  • Red x - Nothing can be done for the book on the device. This usually means the format on the device is not one supported for this function.
  • Red minus - Some other problem. This will probably not be displayed, but, is used internally.
The icons used are part of calibre so may be replaced by an icon theme.


The comparisons are done purely on what Kobo extracts from a book as the ToC. This is done when the book is imported on the device. The details are from the ToC in the book and the manifest. The changes considered are the actual ToC in the book and any related internal file names. This means the ToC will be considered different if any of the following are different:
  • Total number of ToC entries.
  • Internal file name for a ToC entry. Including any directory names.
  • Text for a ToC entry.
  • ToC entry depth.

No attempt to check for any other changes in the book are made. If things like spelling or styles are changed, these will not trigger any issues on the device if the book is replaced properly.

When the ToC is updated in the database, it is completely replaced. It is always updated from the copy of the book on the device. If this copy does not match the book in the library, the book should be sent to the device first.

The way I use this is:
  1. New or changed books are added to the send-to-device Reading list.
  2. Books where the ToC has changed are added to an "Updated" reading list.
  3. When I connect the device, the books on the send-to-device Reading list are sent and the list is cleared.
  4. I display the books in Updated reading list and select them all.

As far as I can tell, everything is working after updating the ToC in the database. I have been using this for a while no for testing. I did the epub code several years ago with no issues. The kepub updating is much newer and more complex but works well. But, it is not very fast. It reads two copies of each book plus the database. This takes time. I recommend only using it for books where you believe there have been changes.

The function in the beta is fully working and I do not believe there are any problems with the actual ToC updates. There are probably some things that can be done to make the interface better. Please try the function and report what happens, either good or bad. If there are problems, I will need to see a debug log from calibre and possibly the books involved.
Attached Files
File Type: zip KoboUtilities-beta.zip (304.3 KB, 1692 views)
davidfor is offline