Improve handling of kobo Date Added during sync

Bug #1254226 reported by Brett Rosen
This bug affects 1 person
Affects Status Importance Assigned to Milestone
David Forrester

Bug Description

When using calibre to add books and synchronize metadata to a kobo device like Kobo Aura or Kobo Aura HD, it would be helpful if there was an option to map a calibre field such as Date or Published to the Kobo Date Added field. This would allow for better sorting of the items on the Kobo, so that sorting by Date Added would display the most recent books added first.

While this kind of works today if the books are added in small batches, this does not work if books are added in large batches as they will all have essentially the same Date Added. Additionally, since the Date fields in Calibre can be edited, this would allow for the Date Added field in Kobo to be modifiable by a user.

I suspect this should be a fairly simple change as it would just be a matter of adding the GUI and preference to set up the mapping and option (is this feature enabled, which Calibre field is used to map to the kobo field) , and then just updating some SQL when modifying the kobo SQLLite database.

Tags: kobo-driver
Revision history for this message
Brett Rosen (bdrosen) wrote :

I'm not an expert with the code, but I suspect the field in question is DateCreated in the content table in database .kobo/KoboReader.sqlite . I think that a function like set_readstatus with some modifications could be used to do the work required in calibre.devices.kobo.driver using the update to set DateCreated instead of using the value chosen by the kobo when the book is copied via USB.

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1254226

Changing the component for this bug.

 assignee davidfor
 tag kobo-driver
 status triaged

Changed in calibre:
assignee: nobody → David Forrester (davidfor)
status: New → Triaged
Revision history for this message
David Forrester (davidfor) wrote :

Sorry, but it isn't as simple as that.

The only sorts on the device that use the date columns are "Recently Read" and "Date Added". The latter is only on shelves.

The "Date Added" sort is only on shelves. It is the date added to the shelf, not to the device. Because of that, it wouldn't be that useful for this purpose. I suppose if you had a shelf that had all the books on it, it could be done, but that feels like overkill. I have used the "Date Added" sort in my utilities plugin to give series sorting in shelves.

The "Recently Read" is a more complicated. It uses two columns. One is "___SyncTime", which is the timestamp for when the book is first seen by the device. The other is "DateLastRead", which changed each time you open or close a book, mark it finished or unfinished. The sort uses DateLastRead unless it is null, then it uses __SyncTime.

For the other dates available in the devices database:

- "DateCreated" is the publishing date. It is displayed on the book details screen.
- "DateAdded" was added in 2.9.0 and I haven't looked at it much. It looks like it is the book purchase date for kepubs and the added to Pocket date for Pocket articles.

Because of way the "Recently Read" sort works, and the data it uses is maintained, I can't see how changing the values through the driver will help.

Revision history for this message
Brett Rosen (bdrosen) wrote :

From my point of view, I was looking for something related to Date Added in the shelves. (I have thousands of books on shelves, but the sorting is less than useful) I'd be happy if there was a way to map that to the Calibre Date column, If that has to be done via set_bookshelf instead, that would be fine. ie:

if shelfName in book.current_shelves:
            if show_debug:
                debug_print(' book already on shelf.')
           cursor.execute(updatedatequery, updatedate_values)

to update only the date if already on the shelf, and then have the add/update queries later on both set Date Added as well when the book is not already in the shelves list.

Does that make sense?

Revision history for this message
Brett Rosen (bdrosen) wrote :

Also, in the same function (set_bookshelf), it seems like the following is wrong:

add_values = (shelfName, book.contentID, time.strftime(self.TIMESTAMP_STRING, time.gmtime()), )

Instead of time.gmtime(), the date from the book should be used as that reflects the date used in calibre metadata vs the date the synch to kobo happened, which can be very different, (This is likely the best that can be done as calibre does not track the date that the shelf/collection equivalent changes were made)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.