View Single Post
Old 06-09-2023, 09:50 PM   #21
tomsem
Grand Sorcerer
tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.tomsem ought to be getting tired of karma fortunes by now.
 
Posts: 6,959
Karma: 27060153
Join Date: Apr 2009
Location: USA
Device: iPhone 15PM, Kindle Scribe, iPad mini 6, PocketBook InkPad Color 3
I was able to fix it up to handle the two new annotation types (subject to code review).

Main changes:

Code:
    ANNOT_CLASS_NAMES = {
        0: "annotation.personal.bookmark",
        1: "annotation.personal.highlight",
        2: "annotation.personal.note",
        3: "annotation.personal.clip_article",  # value not verified
        10: "annotation.personal.handwritten_note",
        11: "annotation.personal.sticky_note",
    }
Added 10 & 11.
(made this a class attribute to consolidate duplicated strings)
Code:
        elif name in self.ANNOT_CLASS_NAMES.values():
            obj["startPosition"] = self.decode_position(val.pop(0))
            obj["endPosition"] = self.decode_position(val.pop(0))
            obj["creationTime"] = datetime.datetime.fromtimestamp(val.pop(0) / 1000.0).isoformat()
            obj["lastModificationTime"] = datetime.datetime.fromtimestamp(val.pop(0) / 1000.0).isoformat()
            obj["template"] = val.pop(0)

            if name == "annotation.personal.note":
                obj["note"] = val.pop(0)
            elif name == "annotation.personal.handwritten_note":
                obj["handwritten_note_nbk_ref"] = val.pop(0)
            elif name == "annotation.personal.sticky_note":
                obj["sticky_note_nbk_ref"] = val.pop(0)
Added handwritten_note_nbk_ref property. I verified that these match to a symbol in ion_symbol_table in the nbk with the pen annotations for a page of the Print Replica document.

I also could not keep myself from fixing linter complaints about 'unreferenced variable i' (by replacing with '_').

Scribe also seems to have another piece of data in font_prefs structure (value 0). I added 'unknown2' to absorb it. I checked another Kindle and it does not have this.
Code:
    "font.prefs": {
        "typeface": "_INVALID_,und:bookerly",
        "lineSp": 1,
        "size": 3,
        "align": 0,
        "insetTop": 64,
        "insetLeft": 200,
        "insetBottom": 8,
        "insetRight": 200,
        "unknown1": -1,
        "bold": 1,
        "userSideloadableFont": "",
        "customFontIndex": -1,
        "mobi7SystemFont": "",
        "mobi7RestoreFont": false,
        "readingPresetSelected": "",
        "unknown2": 0
    },
Maybe is page animation flag? I'll do some more checking.

Not sure what I'm going to do with this, but excited to have discovered it. Thanks @jhowell & @j.p.s.!
Attached Files
File Type: zip krds.py.zip (4.3 KB, 752 views)

Last edited by tomsem; 06-10-2023 at 12:42 AM.
tomsem is offline   Reply With Quote