Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 02-22-2022, 06:59 AM   #1
olof-ynwa
Junior Member
olof-ynwa began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jan 2022
Device: Kindle Paperwhite 5
Kindle locations

I'm currently working on a annotations parser that parses the kindle annotations and then pairs them into note-highlight pairs. (Everytime a note is created in your kindle a highlight is created at the same place). The note is then parsed into list of commands that govern if the highlight should be changed (adding text with metadata to it, search and replace, basic formatting), and where it should be written (add to line/header in markdown file) etcetera. It works fine but I want to implement some extra functionality.

I want to be able to implement a command that allows the user to extract specific images, or tables from an unpacked version of the kindle file.
Whenever a image is highlighted in the kindle, the content of the saved highlight is just an empty string as such:

Note highlight pair example from MyClippings.txt:


Highlight:
Code:
==========
Nils Holgerssons underbara resa genom Sverige. 1 (Selma Lagerlöf)
- Your Highlight on page 29 | Location 431-432 | Added on Monday, January 31, 2022 12:28:12 PM
Associated note containing commands:
Code:
==========
Nils Holgerssons underbara resa genom Sverige. 1 (Selma Lagerlöf)
- Your Note on page 29 | Location 432 | Added on Monday, January 31, 2022 12:28:12 PM

x image
The x image command above says: this is an image, Extract it from the html of the unpacked version of this book by using information about the location (preferable) or page. Replace the actual highlight content with image content (markdown image embed in this case) and copy the image source file to markdown attachements folder.

The actual questions
Is it possible to do this? How does locations in kindle actually work? Is it possible to find the html associated with some location. If not, is it atleast possible to do by page?
I experimented a bit and I couldn't find any patterns between kindle locations and the html of the unpacked version.. Does the unpacking of the book actually change the html?

Thank you in advance.

Last edited by olof-ynwa; 02-22-2022 at 07:03 AM. Reason: Clarification
olof-ynwa is offline   Reply With Quote
Old 02-22-2022, 10:29 AM   #2
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,145
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Kindle is a waste of time for annotations for proof reading & editing. So I changed to using a Kobo, where it's a solved thing. Collections, Series, covers & reading back annotations per book all work perfectly with all Kobo models in free Calibre (Mac, Windows, Linux).

Having even some of those working on a PW3 needs Amazon, and even then it's poor.
Quoth is offline   Reply With Quote
Old 02-22-2022, 10:43 AM   #3
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 6,496
Karma: 84420419
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
Quote:
Originally Posted by olof-ynwa View Post
How does locations in kindle actually work?
A location is a reference an approximate location in a book. Each location represents 150 bytes of raw HTML in MOBI format. The other Kindle formats, such as KF8 (azw3) and KFX, contain a mapping table that shows where each location starts within their content. This is done so that that the same location number will refer to the same snippet of content regardless of the particular Kindle format in which the book was delivered.

(Side note: Kindle books created by calibre in AZW3 format lack the table needed to map location numbers to a corresponding MOBI.)

Quote:
Originally Posted by olof-ynwa View Post
Is it possible to find the html associated with some location.
Yes. The method for doing this varies by Kindle format. It is only a direct mapping to HTML in MOBI format.

Quote:
Originally Posted by olof-ynwa View Post
Does the unpacking of the book actually change the html?
KindleUnpack can unpack books in various ways. One of those provides the raw HTML which relates to locations.

Quote:
Originally Posted by olof-ynwa View Post
Is it possible to do this?
Yes, but there is another possible way to approach the problem. Besides the inexact "location" numbers Kindle books also use "position" numbers to refer to an exact point within the content of a book. Those are used to refer to content in the internal representation of notes and annotations.

Some MobileRead threads with more information on this are:

azw3r highlight and note extraction info
KRDS - A parser for Kindle reader data store files

(Added disclaimer: Obtaining the content corresponding to positions will not be possible for books in KFX format, the most common format for modern Kindles, due to unbreakable DRM.)

Last edited by jhowell; 02-22-2022 at 08:54 PM. Reason: typo
jhowell is offline   Reply With Quote
Old 02-22-2022, 12:41 PM   #4
olof-ynwa
Junior Member
olof-ynwa began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jan 2022
Device: Kindle Paperwhite 5
Wow, seems like KRDS is exactly what I need Thank you so much.
olof-ynwa is offline   Reply With Quote
Reply

Tags
azw3, kindle, locations, mobi


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to go to a page on Kindle??? Locations are annoying. pashlit Amazon Kindle 86 12-14-2011 01:25 PM
Storage locations for ADE and Kindle for PC Vertigo Reading and Management 10 06-19-2011 09:44 PM
Problem: kindle stopped showing locations Raheldm Amazon Kindle 37 03-10-2011 10:20 PM
Locations line not showing on Kindle Lacour Amazon Kindle 5 03-05-2011 12:28 PM
LOCATIONS ON KINDLE FOR PCHow ijbrewst Amazon Kindle 0 01-19-2011 01:13 AM


All times are GMT -4. The time now is 07:25 AM.


MobileRead.com is a privately owned, operated and funded community.