View Single Post
Old 07-01-2020, 12:12 AM   #4
geek1011
Wizard
geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.geek1011 ought to be getting tired of karma fortunes by now.
 
Posts: 2,805
Karma: 7423683
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
Quote:
Originally Posted by davidfor View Post
As @PeterT said, my Kobo Utilities plugin can get the reading status of the book from the device. That includes the percent read and the last read timestamp. It doesn't get the time spent reading. That one I have to revisit as it is stored. But, there is an issue if you use multiple devices to read the same book.
Since Calibre is written using Qt, it should be simple enough to decide the Qt QDataStream from the ExtraData blob (it's an encoded QMap<QString, QVariant>, and the format hasn't changed between versions of Qt and Nickel). The field you're looking for is ExtraDataReadingSeconds in the ExtraData for event 46 for the book.

~~Note that the last time I checked, PyQt didn't have full support for decoding encoded objects with type parameters. You may need to read the stream manually, but it isn't all that complex (and you can still use the read* functions on the PyQt datastream so you don't need to implement all of it from scratch). For reference, you might find my Go implementation of QDataStream useful (note that it implements a lot more than is needed for the ExtraData).~~ Update: see below

Update: I just checked PyQt, and it does actually support the required types for reading it directly. You'll need to initialize a QDataStream from a QByteArray of the ExtraData blob from event 46 in the DB, set the version to Qt 5.2, call readQVariantMap, get the ExtraDataReadingSeconds from the map, then call toInt on the QVariant to get the actual value as a usable number.

Last edited by geek1011; 07-01-2020 at 12:23 AM.
geek1011 is offline   Reply With Quote