Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 01-17-2011, 08:49 AM   #16
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, Oasis
Hi Chaley
I got ambicious. Tried to modify the function code. Want to learn.

Got a weird idea that f > 0 and f < test_val should return Reading,
tried with elif since python apparently doesn't have "case"
Calibre startup time went from 1-2 seconds to several minuttes.
Did up params from to 6, changed the column def to include Reading as last parm

code:

def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, is_read_str,
is_not_read_str, no_page_read_str, is_reading_str):
try:
test_val = int(is_read_pct)
except:
return 'is_read_pct is not a number'

import re
mg = re.match('.*last page read: location \d+ \((\d+)%\)', val, re.I + re.DOTALL);
if mg is None:
return no_page_read_str
try:
f = int(mg.group(1))
if f >= test_val:
return is_read_str
elif (f > 0) and (f < test_val):
return is_reading_str
else:

return is_not_read_str
except:
pass
return no_page_read_str


No big deal, I'm just trying to learn by doing
Cheers,

EDIT: Slow down was not caused by the edit above.
The minute I removed and other column showing the % read spead was back.
Sorry.

Last edited by pchrist7; 01-17-2011 at 09:23 AM.
pchrist7 is offline   Reply With Quote
Old 01-17-2011, 09:13 AM   #17
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 272
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
I would like to include in the comments field Last Read: Date.

How would I do this? Calibre version 7.40.
beckywc is offline   Reply With Quote
Advert
Old 01-17-2011, 09:33 AM   #18
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, Oasis
Quote:
Originally Posted by beckywc View Post
I would like to include in the comments field Last Read: Date.

How would I do this? Calibre version 7.40.
Hi Becky
Don't know for sure with the K2, but start Calibre, connect your K, wait a bit, click an the arrow just to the tight of the "Send to Device" icon, choose "Fetch Annotations" and it's automatically added to the book details, and the comments.
This is just an example of what I 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

This what you were after ?

Last edited by pchrist7; 01-17-2011 at 09:34 AM. Reason: formatting
pchrist7 is offline   Reply With Quote
Old 01-17-2011, 09:41 AM   #19
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pchrist7 View Post
Hi Chaley
I got ambicious. Tried to modify the function code. Want to learn.
I know that feeling. That is why I did the function in the first place
Quote:
Got a weird idea that f > 0 and f < test_val should return Reading,
tried with elif since python apparently doesn't have "case"
...
code:

def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, is_read_str,
is_not_read_str, no_page_read_str, is_reading_str):
The only difference between your code and mine is that yours returns a different string if the value == 0.

The re.match only succeeds when an annotation is found. That means that the % will be a valid number. Your change returns 'is_reading_str' if that number is > 0 (you know that), and is_not_read_str if that number == 0.

My question: can the number ever be zero? That would imply that the book had been opened but no pages had been turned?
chaley is offline   Reply With Quote
Old 01-17-2011, 10:00 AM   #20
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
As long as I am commenting.

Code:
		f = int(mg.group(1))
		if f >= test_val:
			return is_read_str
		elif (f > 0) and (f < test_val):
			return is_reading_str
		else:	
			return is_not_read_str
The line you added could be
Code:
		elif f > 0:
			return is_reading_str
		else:
because the if above has already removed all the cases that the clause after the 'and' would catch.
chaley is offline   Reply With Quote
Advert
Old 01-17-2011, 10:07 AM   #21
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, Oasis
Quote:
Originally Posted by chaley View Post
I know that feeling.
My question: can the number ever be zero? That would imply that the book had been opened but no pages had been turned?
Yes: the number will be 0 if I open a book, but don't turn any pages.
( well, 1 or 2 pages might still show as 0 depending on the number of locations/pages in the book)
An .mbp file is created on the K3 as soon as a book is opened, and mantained during reading etc.

Last edited by pchrist7; 01-17-2011 at 10:22 AM. Reason: more info
pchrist7 is offline   Reply With Quote
Old 01-17-2011, 10:11 AM   #22
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pchrist7 View Post
Maybe you/we could put this somewhere as a sticky or something ?
Other Kindlers might love this besides me.
Subject could be something like: Automagically mark books read
I would be happy to add this to the Plugboard, template, and custom composite column recipes sticky. However, not having a kindle, I don't feel confident with writing the rationale or the instructions.

If you would be so kind as to post something on that thread explaining what problem you are solving, how to get the kindle annotations, any other instructions (including better instructions for creating the function), then I will add the right bits in the 'kindle' section of the first post. Thanks in advance!
chaley is offline   Reply With Quote
Old 01-17-2011, 10:18 AM   #23
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, Oasis
Quote:
Originally Posted by chaley View Post
As long as I am commenting.

The line you added could be
Code:
		elif f > 0:
			return is_reading_str
		else:
because the if above has already removed all the cases that the clause after the 'and' would catch.
You're right.
Just do that compare once, sigh ...
Works like a charm
pchrist7 is offline   Reply With Quote
Old 01-17-2011, 10:29 AM   #24
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, Oasis
Sure thing

Quote:
Originally Posted by chaley View Post
I would be happy to add this to the Plugboard, template, and custom composite column recipes sticky. However, not having a kindle, I don't feel confident with writing the rationale or the instructions.

If you would be so kind as to post something on that thread explaining what problem you are solving, how to get the kindle annotations, any other instructions (including better instructions for creating the function), then I will add the right bits in the 'kindle' section of the first post. Thanks in advance!
Hi chaley
Sure - I'll try my hand at this
Want to let this simmer in my head for a day or 2, before I try to explain to others.
Hope to have something during the weekend,

Last edited by pchrist7; 01-17-2011 at 10:37 AM.
pchrist7 is offline   Reply With Quote
Old 01-17-2011, 10:56 AM   #25
gweminence
Fat Guy
gweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notes
 
Posts: 408
Karma: 24165
Join Date: Jun 2010
Device: Kindle Voyage
Fantastic work guys, I love this. Question:

Is it possible to make the 'yes' and 'no' the red 'no' x-mark and the green 'yes' checkmark that you'd get from making a yes/no column?

Oh, and for the record, chaley, you could pretty much cut and paste that post, and the directions are good enough. Worked for me. I'd only add pchrist7's post about how to get the annotations.

One possible idea for a modification (I have no idea how to do it myself, sorry, not a coder): have the column, rather than say 'unopened' for EVERY book in your library that's not even on the kindle, say rather, 'Not loaded', or something similar. So that only books actually on the device would show 'unopened'.

So basically (I imagine), a test for if it's on the device or not.

Last edited by gweminence; 01-17-2011 at 11:07 AM.
gweminence is offline   Reply With Quote
Old 01-17-2011, 11:26 AM   #26
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,782
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by gweminence View Post
Fantastic work guys, I love this. Question:

Is it possible to make the 'yes' and 'no' the red 'no' x-mark and the green 'yes' checkmark that you'd get from making a yes/no column?

Oh, and for the record, chaley, you could pretty much cut and paste that post, and the directions are good enough. Worked for me. I'd only add pchrist7's post about how to get the annotations.

One possible idea for a modification (I have no idea how to do it myself, sorry, not a coder): have the column, rather than say 'unopened' for EVERY book in your library that's not even on the kindle, say rather, 'Not loaded', or something similar. So that only books actually on the device would show 'unopened'.

So basically (I imagine), a test for if it's on the device or not.
Those same Icons are used everywhere in Calibre (read the FAQ on custom Icons on how to change from a supplied one). Any change applies to all Green ticks(ok.png), Red dot plus(list_remove.png)
theducks is offline   Reply With Quote
Old 01-17-2011, 11:32 AM   #27
gweminence
Fat Guy
gweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notes
 
Posts: 408
Karma: 24165
Join Date: Jun 2010
Device: Kindle Voyage
Thanks, theducks, but the current column, as written, uses text to simply say 'yes' or 'no'. No icons at all.

By the way, does your name refer to Oregon? Just curious. I'm from there.
gweminence is offline   Reply With Quote
Old 01-17-2011, 11:51 AM   #28
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,782
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by gweminence View Post
Thanks, theducks, but the current column, as written, uses text to simply say 'yes' or 'no'. No icons at all.
AH. I use a Logical Tri-state field Tick, the red X and blank

Quote:
By the way, does your name refer to Oregon? Just curious. I'm from there.
Nope, but I have heard of them

We used to run a SCA merchants booth with "duck" in its name. "go see the ducks" (a collective name for my wife and myself) was a common phrase back then.
theducks is offline   Reply With Quote
Old 01-17-2011, 11:57 AM   #29
gweminence
Fat Guy
gweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notesgweminence can name that song in three notes
 
Posts: 408
Karma: 24165
Join Date: Jun 2010
Device: Kindle Voyage
Quote:
Originally Posted by theducks View Post
AH. I use a Logical Tri-state field Tick, the red X and blank
I have a separate 'Read' column that uses that. I was wondering if it'd be possible to implement it in the column that's the subject of this thread.


Quote:
Nope, but I have heard of them

We used to run a SCA merchants booth with "duck" in its name. "go see the ducks" (a collective name for my wife and myself) was a common phrase back then.
Ah, neat.
gweminence is offline   Reply With Quote
Old 01-17-2011, 02:00 PM   #30
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by gweminence View Post
Is it possible to make the 'yes' and 'no' the red 'no' x-mark and the green 'yes' checkmark that you'd get from making a yes/no column?
Nope.
Quote:
Oh, and for the record, chaley, you could pretty much cut and paste that post, and the directions are good enough. Worked for me. I'd only add pchrist7's post about how to get the annotations.
My thinking is that pchrist7 will have more of an idea what a user needs to know than I do, as I both don't have a kindle and do have a rather intimate knowledge of calibre's code. But that shouldn't stop people.
Quote:
One possible idea for a modification (I have no idea how to do it myself, sorry, not a coder): have the column, rather than say 'unopened' for EVERY book in your library that's not even on the kindle, say rather, 'Not loaded', or something similar. So that only books actually on the device would show 'unopened'.

So basically (I imagine), a test for if it's on the device or not.
Can't do with on-device information. The on-device information is available only while the device is plugged in, which means that the information

However, I think that what you want is that nothing (blank) be displayed if there is no annotation. You can do that with what you have today. Change the custom column template to be
Code:
{comments:kindle_read_percent(95,Yes,No,)}
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"integrity error column book is not unique" Atiajar Calibre 4 12-21-2010 11:22 PM
Can Comments be "saved to disk" for reading? sailingpeanut Recipes 1 10-10-2010 10:06 AM
(2 books) in "On Device" column Sony Reader phenomshel Calibre 23 09-19-2010 05:43 PM
Bug? "Insert metadata as page at start of book" doesnt encode Comments field properly rollercoaster Calibre 2 04-24-2010 10:40 PM


All times are GMT -4. The time now is 04:45 PM.


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