View Single Post
Old 07-01-2020, 01:21 AM   #5
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
Quote:
Originally Posted by geek1011 View Post
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.
Don't you think that that might be overkill when there is the column "TimeSpentReading" in the content table? That has been there for a while, I just haven't been that interested in fetching it. Then there is the issue of multiple devices.

But, I keep meaning to look at those. I just keep finding other things to do
davidfor is offline   Reply With Quote