Hi All
The following HOWTO was developped in another thread.
Chaley suggested to put it here as well.
Do you have a Kindle ?
Did you ever want Calibre to show "Read Status" of your books in a column ?
Automagically ?
Then the following might for you as well.
You must be running Calibre 0.7.40 or newer to use this.
Also you must use "Fetch annotations" from you Kindle.
The following example is based on the following Kindler requirements:
"What I want is a custom column to show the "Last Opened" Date if Last location read > 95%.
If the book shows >0% but < 95%, I want the column to show "Reading"
And if the book is 0%, or unopened, the column should show "Not Read".
Howto "Fetch annotations" from you Kindle:
Start Calibre,
Connect your Kindle, wait a bit,
Click on the arrow just to the right of the "Send to Device" icon,
choose "Fetch Annotations"
and the Kindle "Book status" is added to the Calibre book details, in the comments.
You should Fetch fresh Annotations everytime you connect your Kindle to get updated information.
This is just an example of what I could get with my K3:
25-12-2010
Last Page Read: Location 7365 (68%)
Location 4603 • Bookmark
Location 4942 • Bookmark
Location 4980 • Bookmark
Location 5984 • Bookmark
Location 7363 • Bookmark
The best/fastest way, but hardest way, to get the needed information into a custom column, is to use Python Template functions.
Sounds scary, but don't worry. Copy/paste is your helper
Simply do as follows:
1) go to Preferences -> Advanced -> Template Functions.
2) in the Function box type: kindle_read_status
3) in the Arg count box type: 4
4) in the Documentation box, paste the following:
Code:
Check if the associated field contains a kindle annotation for percent read.
If not, return no_page_read_str.
If annotations are found, then compare that percent against is_read_pct.
If the val is larger, then return date,
if the val is >0 and < is_read_pct return is_reading_str.
Otherwise return is_not_read_str.
One usage: {comments:kindle_read_status(95,Not Read,Reading)}
( use the above when defining your custom column )
95 goes into variable is_read_pct
Not Read goes into variable no_page_read_str
Reading goes into variable is_reading_str
Feel free to change the %, the test strings to suit your needs.
Do this in the custom column definition.
5) In the Program Code box, paste the following:
Code:
def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct,
is_reading_str, no_page_read_str):
try:
test_val = int(is_read_pct)
except:
return 'is_read_pct is not a number'
import re
mg = re.match('.*\s(\d+[-/]\d+[-/]\d+).*?Last Page Read: Location \d+ \((\d+)%\)', val, re.I + re.DOTALL);
if mg is None:
return no_page_read_str
date = mg.group(1)
pct = mg.group(2)
try:
f = int(pct)
if f > test_val:
return date
elif f > 0:
return is_reading_str + ': ' + pct + '%'
except:
pass
return no_page_read_str
6) press the Create button, then the Apply button.
7) Still in Preferences, Choose Add your own columns
8) Choose Add custom column bar at the bottom
9) enter the following into your custom column:
Lookup name: read_status
Column Heading: Read Status
Column type: Column built from other columns
Template:
Code:
{comments:kindle_read_status(95,Reading,Not Read)}
10) Choose Apply
11) Click Ok to the Restart Warning
12) Shutdown Calibre
13) Start Calibre
If you followed instructions minutely, you should have a new column showing the "Read Status" for your books.
If you like this functionality, please remember to send some Karma to chaley
https://www.mobileread.com/forums/rep....php?p=1351864
He has been absolutely fantastic and helpfull with this.
If this fails, please try one more time before posting to this thread.
This has been tested by several Kindlers succesfully.
Enjoy
Note: If you want a text returned instead of a date when a book is read
have a look here:
https://www.mobileread.com/forums/sho...&postcount=172