Hi pein2k4,
This is what I have in my template: (it is working fine for my Kindle DX and my wife's Paper White under Calibre 2.12.0)
Function: kindle_read_status
Arg Count: 5
Documentation:
Check if the associated field contains a kindle annotation for percent read.
If not, return no_page_read_str.
If so, then compare that percent against is_read_pct.
If the val is larger, then return is_read_str,
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(90,Read,Reading,Not Read)}
( use the above when defining your custom column )
90 goes into variable is_read_pct. IF pct_read > 90 the book is "read" The text returned is
Read goes into the variable is_read_str. This ex. returns the text Read
Reading goes into variable is_reading_str. IF pct_read >0 book the text "Reading" is shown with the percentage shown as well.
Not Read goes into variable no_page_read_str. IF none of the above catch, then "Not Read" is shown.
Feel free to change the %, the text strings to suit your needs.
Remember: Do this in the custom column definition.
Program Code:
Code:
def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, is_read_str,
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 is_read_str
elif f > 0:
return is_reading_str + ': ' + pct + '%'
except:
pass
return no_page_read_str
Do a copy and paste of all of the above to the required fields and it should work.
Good Luck
Ps: Don't forget to select
Fetch Annotations fron the menu once your device is connected to Calibre.