10-11-2012, 04:00 AM | #1 |
Zealot
Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
|
Getting last added books
Is there a way to get the ids for the last added books after using the gui.iactions['Add Books']?
I know I can get last modified book from iactions using db.last_modified(). But... what about last added book(s)? |
10-11-2012, 04:37 AM | #2 |
creator of calibre
Posts: 43,771
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Not directly, but you can simply get all ids before and after the operation. As long as no other jobs are running in the interim that is reliable, or you can directly use the db interface to add books instead of using the iaction.
|
Advert | |
|
10-11-2012, 05:03 AM | #3 |
Zealot
Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
|
Thanks, kovidgoyal. The method of get ids before and after the iaction was already my "second solution".
The use of iaction instead of the db is because this way I don't need to create any user interface window (iaction has it own user interface). |
10-11-2012, 06:11 AM | #4 |
Zealot
Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
|
I have another problem: I read book ids in library, then I lauch iaction for adding books, after that I read again for ids in library.... and I get same ids list than before!
I know that it's because iaction for adding books uses an Adder object that uses a "worker" to make the job and returns control to main function. So when I read ids for second time, the worker is still working, and I get no new ids. Any way to solve this? |
10-11-2012, 06:13 AM | #5 |
creator of calibre
Posts: 43,771
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use a timer an keep polling till you have the new ids. Or you can be sophisticated and monkey patch the callback function on the iaction object so that your callback is called instead. Just remeber to retore the original function after you are done.
|
Advert | |
|
10-11-2012, 07:19 AM | #6 | |
Zealot
Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
|
This is not a good solution, because the user may cancel the iaction, and we never will get new ids.
Quote:
I monkey patch the "_files_added" function at the iaction to make its work, and then to call my own function to get the ids. And works OK. Thank you again for your help, kovidgoyal, you're the king! Last edited by Pepin33; 10-11-2012 at 01:02 PM. |
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Books added by Calibre | eLDiaNo | Devices | 5 | 10-08-2012 12:32 PM |
Title language of added books | panovvladislav | Calibre | 2 | 03-25-2012 06:50 AM |
books do not show on device after being added | vague_hit | Calibre | 3 | 02-09-2012 08:30 AM |
After aborting, are books still added to library? | vitalichka | Calibre | 4 | 01-15-2011 11:15 AM |
Added personal books to the EB1150 | =X= | Fictionwise eBookwise | 8 | 08-15-2008 10:51 PM |