12-29-2018, 09:22 AM | #1 |
Junior Member
Posts: 5
Karma: 10
Join Date: Dec 2018
Device: Kindle
|
Deleting book from database
Hi all,
I'm trying to write a plugin and could use a bit of help. Given a path for an ebook, I would like to delete that book from the database. I can delete the file from my computer using normal python methods but I can't seem to find a way to remove it from calibre. Apologies if this is super obvious. I searched through the API docs and was only able to find functions to remove a book from a device. Bonus question: Is there any way to automatically trigger a plug in to run whenever the metadata for a book is changed? Thanks so much in advance! |
12-29-2018, 10:14 AM | #2 |
Well trained by Cats
Posts: 29,807
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Look at the commandline interface section of the users guide
https://manual.calibre-ebook.com/gen...db.html#remove BTW NEVER make changes to the filesystem using anything other than Calibre (tools), you will break things BAD |
12-29-2018, 11:03 AM | #3 |
Grand Sorcerer
Posts: 6,497
Karma: 84420419
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
|
The database API documentation is here. See remove_books if you want to remove a book record entirely or remove_formats if you want to eliminate just the e-book content.
|
12-29-2018, 01:04 PM | #4 |
Junior Member
Posts: 5
Karma: 10
Join Date: Dec 2018
Device: Kindle
|
Thanks for the help!
remove_formats is working for the most part. The only issue I'm having is that it is successfully deleting the ebook from the filesystem but the deleted format is still listed as available in the Calibre interface. Is there some command I need to run in order to have this change reflected in the Calibre interface? Thanks again |
12-29-2018, 03:27 PM | #5 | |
Well trained by Cats
Posts: 29,807
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:
You are using the wrong call. Remove, does EVERYTING |
|
12-29-2018, 03:44 PM | #6 |
Junior Member
Posts: 5
Karma: 10
Join Date: Dec 2018
Device: Kindle
|
|
12-29-2018, 04:37 PM | #7 | |
null operator (he/him)
Posts: 20,572
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
If you restart calibre after running your plugin, is the removed format still showing in Book Details. If not, that would indicate you need to refresh the Book Details panel after doing the remove_formats. If it is - BR |
|
12-29-2018, 05:05 PM | #8 |
Junior Member
Posts: 5
Karma: 10
Join Date: Dec 2018
Device: Kindle
|
Bingo! I just need to refresh the panel. Can I force a refresh or does the program need to be restarted?
|
12-29-2018, 05:13 PM | #9 |
null operator (he/him)
Posts: 20,572
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
dunno - I am a logician not a coder. I would be very surprised if there's not a refresh function available, but I've no idea where it is.
BR |
12-29-2018, 09:18 PM | #10 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you are doing this in a GUI plugin then dont use the db API directly, instead use the existing remove books action which will take care of refreshing the GUI for you automatically. Something like:
Code:
self.gui.iactions['Remove Books'].remove_format_by_id(book_id, fmt) |
12-30-2018, 08:25 AM | #11 | |
Junior Member
Posts: 5
Karma: 10
Join Date: Dec 2018
Device: Kindle
|
Quote:
I was not planning on making this a GUI plugin so I will look into re-implementing the function myself. Thanks for the suggestion and for making such an amazing program! |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Deleting book | filipexim | Development | 6 | 05-27-2012 12:36 PM |
deleting a book | StickMaker | Amazon Kindle | 9 | 09-18-2011 03:40 PM |
Deleting book from sig | joycedb | Feedback | 19 | 09-12-2011 09:47 AM |
Deleting a Book..?? | Cpl Punishment | Nook Color & Nook Tablet | 2 | 01-30-2011 08:48 PM |
Deleting books from a database | candide | Calibre | 6 | 10-26-2010 03:04 PM |