Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Devices

Notices

Reply
 
Thread Tools Search this Thread
Old 04-02-2011, 11:02 PM   #16
PapaJohn
Member
PapaJohn began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Feb 2011
Device: Kindle DX
pchrist7
Well I just upgraded to the latest version of Calibre (0.7.53) and I guess some changes have been implemented in the code. My Read Staus Column was giving me an error... something about an invalid arg count. I then modified the template for an arg count of 4 (down from 5) and now I don't get the error message, but now in the case of a book that has been read the column shows a date instead of Read. Any ideas?

I also noticed that when I was in the plugboard that if I had my Kindle DX attached it showed "device attached Kindle_DX" and if I had my wifes K3 attached it showed "device attached Kindle2". I am not a programmer and don't have a clue, but I was wondering if Calibre is able to recognize the difference between the 2 devices if somehow that could be used to create 2 separate Read Status Columns???
PapaJohn is offline   Reply With Quote
Old 04-03-2011, 02:10 AM   #17
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi
Quote:
Originally Posted by PapaJohn View Post
pchrist7
Well I just upgraded to the latest version of Calibre (0.7.53) and I guess some changes have been implemented in the code. My Read Staus Column was giving me an error... something about an invalid arg count. I then modified the template for an arg count of 4 (down from 5) and now I don't get the error message, but now in the case of a book that has been read the column shows a date instead of Read. Any ideas?
Will test based on your original example. Please post new example of annotation, column definition incl. python template, just in case you changed something.

Quote:
I also noticed that when I was in the plugboard that if I had my Kindle DX attached it showed "device attached Kindle_DX" and if I had my wifes K3 attached it showed "device attached Kindle2". I am not a programmer and don't have a clue, but I was wondering if Calibre is able to recognize the difference between the 2 devices if somehow that could be used to create 2 separate Read Status Columns???
As said before, Calibre stores 1 set of annotations for 1 book. It's book based, not device based. IF you want to track read status of 1 book, on 2 devices, you should have 2 Calibre libraries: 1 for KDX and 1 for K3.
I might be wrong, but I think not.
Developpers ?

Last edited by pchrist7; 04-03-2011 at 02:12 AM. Reason: spelling, formats
pchrist7 is offline   Reply With Quote
Old 04-05-2011, 06:32 PM   #18
PapaJohn
Member
PapaJohn began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Feb 2011
Device: Kindle DX
Hi pchrist7
This is the code I am using:
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
And the template for the Read Status Column:
Code:
{comments:kindle_read_status(95,Reading,Not Read)}
I don't recall making any changes.
Cheers
PapaJohn is offline   Reply With Quote
Old 04-06-2011, 09:57 AM   #19
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi
Quote:
Originally Posted by PapaJohn View Post
Hi pchrist7
I don't recall making any changes.
Cheers
Hi
Some things changed since your own post #8 in this thread
http://www.mobileread.com/forums/sho...71&postcount=8
It appears you have the code from #137 and had arg count from post #172
in the old thread.
The code from #137 will return the date, if you want the Text Read returned, follow instructions in #172.
pchrist7 is offline   Reply With Quote
Old 11-14-2014, 08:40 PM   #20
pein2k4
Junior Member
pein2k4 began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Nov 2014
Location: Germany
Device: KPW2
Hi,
I have the same problem as PapaJohn. I'm already trying to get the read status in my Calibre for days now.

I have, as described, deleted and tried again many times, waited a day and always rebooted Calibre and it is still displaying "not read".

What am I doing wrong?
Does it work at all with the KPW2

I use the template kindle_read_status_2 with German text.
Kindle PW2 - Calibre 2.10 - OS X 10.9.5

Quote:
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+).*?Zuletzt gelesene Seite: Ort \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
pls
pein2k4 is offline   Reply With Quote
Old 12-15-2014, 03:17 PM   #21
PapaJohn
Member
PapaJohn began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Feb 2011
Device: Kindle DX
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:
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.

Last edited by PapaJohn; 12-15-2014 at 04:07 PM.
PapaJohn is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with this custom Column. Rie142 Library Management 2 02-20-2011 10:51 AM
Custom Composite Column silentguy Calibre 4 11-24-2010 11:28 AM
Custom column read ? pchrist7 Calibre 2 10-04-2010 03:52 AM
custom column i need a little help shinken Calibre 3 09-15-2010 04:41 AM
Custom Column Problem MSJim Calibre 7 09-08-2010 06:07 PM


All times are GMT -4. The time now is 09:47 PM.


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