You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When viewing a book (not the book/library browser) under the tools/settings menu here is a "Progress sync" sub menu.
Config defaults to "Binary. Only identical files will be kept in sync." (versus" Filename. Files with matching names will be kept in...")
Progress Sync is not enabled by default, needs a login (or login creation).
Then either manually sync (push/pull) or auto sync (which requires setting options for when)
One setup, default is to sync using partial md5 checksum of file contents, can change this from default of "binary" (partial) to "filename"
Parts of ebook file content are ran through plain md5sum (default, "Binary" option) OR filename ran through md5 (non-default, "Filename" Progress Sync option) is used as document key:
--- Calculate partial digest of an open file. To the calculating mechanism itself,
-- since only PDF documents could be modified by KOReader by appending data
-- at the end of the files when highlighting, we use a non-even sampling
-- algorithm which samples with larger weight at file head and much smaller
-- weight at file tail, thus reduces the probability that appended data may change
-- the digest value.
-- Note that if PDF file size is around 1024, 4096, 16384, 65536, 262144
-- 1048576, 4194304, 16777216, 67108864, 268435456 or 1073741824, appending data
-- by highlighting in KOReader may change the digest value.
function util.partialMD5(filepath)
if not filepath then return end
local file = io.open(filepath, "rb")
if not file then return end
local step, size = 1024, 1024
local update = md5()
for i = -1, 10 do
file:seek("set", lshift(step, 2*i))
local sample = file:read(size)
if sample then
update(sample)
else
break
end
end
file:close()
return update()
end
API - details
All requests to API endpoints require the following headers:
Funnily enough, I wanted to implement something related to this to. I use a Kobo Libra H2O, and I wanted to write a daemon that syncs reading progress between KOReader and Calibre. Like people have said before, there's not really a standard way to do this.
Calibre seems to use epubcfi, location, references etc. KOReader stores this information roughly in a statistics.sqlite3 database (pages read, total pages), and as a percentage read/xpointer in metadata.epub.lua (the latter being in the folder of a given epub. Not sure about other document types).
Converting between the two doesn't seem easy. You'd probably have to reverse engineer the xpointer piece so you can translate it back and fourth between epubcfi.
Edit: To add to this, I've just realised Cool Reader 3 is used with this project, and it seems the function CR3View::goToXPointer in that project might hold the answer.
Rough unsorted notes
Koreader sync progress whisper sync
fastdigest appears to be partial md5sum and used as document key. partial_md5_checksum
Koreader can (md5) hash filename instead. NOTE filename (not directory) and includes file extension.
The md5 hash is calculated only the first time book is opened, and then it's stored in bookname.sdr/metadata.lua. As long as the md5 hash in that file doesn't change, the progress will sync, even if the file's hash changes.
When viewing a book (not the book/library browser) under the tools/settings menu here is a "Progress sync" sub menu.
Config defaults to "Binary. Only identical files will be kept in sync." (versus" Filename. Files with matching names will be kept in...")
Resources and notes
API
API - Hashing
password is ran run plain md5sum.
Parts of ebook file content are ran through plain md5sum (default, "Binary" option) OR filename ran through md5 (non-default, "Filename" Progress Sync option) is used as document key:
Binary option - partial file contents, https://github.com/koreader/koreader/blob/master/frontend/apps/reader/readerui.lua look for
util.partialMD5()
which is then stored in meta data for document/book.filepartial_md5_checksum
in KoReader.https://github.com/koreader/koreader/blob/master/frontend/util.lua has code implementation for
partialMD5()
, code unchanged for a while, snapshot from 2024-08-03:API - details
All requests to API endpoints require the following headers:
API - doc refs
Worth a refresher read https://blog.stoplight.io/api-keys-best-practices-to-authenticate-apis
API - examples
API - get progress
Storage Model
Consider initial implementation using https://github.com/imbolc/sqlite_dbm for storage.
Implementations
https://github.com/relkochta/koreader-sync/blob/main/backend/sqlite.py
https://github.com/yeeac/kosyncsrv/blob/main/handledb.go
https://github.com/aremmiw/ksync/blob/main/db.c
https://github.com/pborzenkov/koreader-syncd/blob/master/migrations/01_init.sql
Other progress information
KoReader also stores in local files (see rough notes below, SDR).
From comment janeczku/calibre-web#2122 (comment) SomeOtherDev wrote:
Rough unsorted notes
Koreader sync progress whisper sync
fastdigest appears to be partial md5sum and used as document key. partial_md5_checksum
Koreader can (md5) hash filename instead. NOTE filename (not directory) and includes file extension.
The md5 hash is calculated only the first time book is opened, and then it's stored in bookname.sdr/metadata.lua. As long as the md5 hash in that file doesn't change, the progress will sync, even if the file's hash changes.
SiDe caR files.
sdr files have partial md5sum an page progress
https://git.sr.ht/~harmtemolder/koreader-to-markdown
slpp.py load lua dict into python
Sync servers
https://github.com/koreader/koreader/blob/master/plugins/statistics.koplugin/main.lua
The text was updated successfully, but these errors were encountered: