For epubs on the Sony devices, the number of pages will be calculated by the Adobe RMSDK. And the current page will be based on that. The description of the method is in the Wiki, but have a look the Count Pages for an implementation.
To calculate a percent read, what Kovid pointed to should work. You will also need the current position from the database on the Sony. From memory, this is stored in an Adobe specific way. I assume it comes from the RMSDK as the Kobo's use it for epubs as well. The calibre viewer uses a different position method (the same as for epub3?). I don't know if there is already a way to translate between them, but it shouldn't be to hard*.
From memory, iterator/book.py has to unpack the book to work. That means calculating the percent read could take some time. For one book, it shouldn't be to bad, but if you are doing it for all the books on the device, it might take a while. I suppose that should only happen once when the store positions is first run.
* Imagine me laughing maniacally while I typed that.
|