Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 02-13-2023, 03:33 PM   #1
siebert
Developer
siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.
 
Posts: 155
Karma: 280
Join Date: Nov 2010
Device: Kindle 3 (Keyboard) 3G / iPad 9 WiFi / Google Pixel 6a (Android)
FileTypePlugin postimport() not called after conversion?

Hi,

I want to write a plugin based on FileTypePlugin which implements postimport(), but I noticed that the method is only executed if I add a new ebook to Calibre (i.e. drag and drop a file), but not when I convert an existing ebook into a new format.

Is there any way to have Calibre run the method also in this case?
siebert is offline   Reply With Quote
Old 02-13-2023, 11:50 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,017
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
No conversion is not considered an import. If you can tell us a bit more about your actual use case, what you want your plugin to do I might be able to suggest a solution.
kovidgoyal is offline   Reply With Quote
Old 02-14-2023, 03:03 PM   #3
siebert
Developer
siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.
 
Posts: 155
Karma: 280
Join Date: Nov 2010
Device: Kindle 3 (Keyboard) 3G / iPad 9 WiFi / Google Pixel 6a (Android)
When I manage my ebooks in calibre, I want to keep track which files/formats are the original files I added to calibre and which ones are converted by calibre from the original file, to ensure that I never lose my original files.

I can recognize a book created by calibre from the creator metadata, so I want to automatically create a tag "Converted EPUB" if a .epub file created by calibre is added to my library/created by conversion (and similar tags for the other formats).

I also need a way to automatically remove the "Converted <format>" tag if the corresponding format is deleted from the database.
siebert is offline   Reply With Quote
Old 02-14-2023, 04:54 PM   #4
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,677
Karma: 26966376
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@siebert - have you considered using the Actions Chain plugin ==>> Index of plugins

BR
BetterRed is offline   Reply With Quote
Old 02-14-2023, 05:03 PM   #5
siebert
Developer
siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.
 
Posts: 155
Karma: 280
Join Date: Nov 2010
Device: Kindle 3 (Keyboard) 3G / iPad 9 WiFi / Google Pixel 6a (Android)
Quote:
Originally Posted by BetterRed View Post
@siebert - have you considered using the Actions Chain plugin
No, I haven't. It seems to be a rather complex plugin, and I can't really figure out from the description how I could achieve my goal with it. Could you be more specific how to actually use it for my purpose?
siebert is offline   Reply With Quote
Old 02-14-2023, 06:17 PM   #6
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,677
Karma: 26966376
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by siebert View Post
No, I haven't. It seems to be a rather complex plugin, and I can't really figure out from the description how I could achieve my goal with it. Could you be more specific how to actually use it for my purpose?
I suggest you ask in the Action Chain thread with reference to this thread, the author is very responsive as are the folks who use the PI. There's also a thread of AC scripts, that should be linked into post #1 of the AC plugin thread.

The AC plugin didn't exist when I started using calibre, when I could have used it for a high volume proof of concept project. But my usage of calibre today is low volume so I have no need for it. I wouldn't spend more an hour a month on managing my calibre libraries.

BR
BetterRed is offline   Reply With Quote
Old 02-14-2023, 09:34 PM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,017
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You will never lose source format with default calibre settings since doing an epub to epub conversion will preserve the original as original_epub. So what is it you are actually trying to guard against?
kovidgoyal is offline   Reply With Quote
Old 02-15-2023, 12:50 PM   #8
siebert
Developer
siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.
 
Posts: 155
Karma: 280
Join Date: Nov 2010
Device: Kindle 3 (Keyboard) 3G / iPad 9 WiFi / Google Pixel 6a (Android)
It's not about converting one format to itself, it's about converting between formats.

I usually have my ebooks stored in Calibre as epub and mobi. Most of my ebooks I got as original epub and converted them to mobi, but some I got as original mobi and converted these to epub, and some other ebooks were originally available both as epub and mobi, so no conversion was needed at all in this case.

I have no problems to delete and convert again formats which were created in the past by converting, but I don't want to lose my original formats.

These automatically created and deleted tags allow me to easily distinguish the original files from the converted ones.

I already use this scheme successfully for years, but it's rather annoying to maintain my necessary patches to Calibre every time I upgrade Calibre and as a result I do upgrades very seldom.

I would like to achieve the same result via a plugin, so I can use an unmodified Calibre and update more easily/more often.

From my perspective, all I would need are two small additions to the FileTypePlugin interface: an additional variable which lets postimport() be executed also after a conversion and a new method (e.g. postdelete()) with the same signature as postimport(), which is executed when a format is deleted.
siebert is offline   Reply With Quote
Old 02-15-2023, 09:31 PM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,017
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You are welcome to send a PR to add on_postconvert and on_postdelete event types to the filetype plugin.
kovidgoyal is offline   Reply With Quote
Old 02-16-2023, 03:50 AM   #10
siebert
Developer
siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.
 
Posts: 155
Karma: 280
Join Date: Nov 2010
Device: Kindle 3 (Keyboard) 3G / iPad 9 WiFi / Google Pixel 6a (Android)
Quote:
Originally Posted by kovidgoyal View Post
You are welcome to send a PR to add on_postconvert and on_postdelete event types to the filetype plugin.
Ok, I'll give that a try.

Can you give me some hints where these new methods need to be called and where postimport() is currently called in calibre for reference?
siebert is offline   Reply With Quote
Old 02-16-2023, 05:23 AM   #11
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,017
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
see customize/ui.py and db/cache.py
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cancel book import from inside a FileTypePlugin Leseratte_10 Development 2 09-04-2021 10:10 PM
Error question from conversion formatter called epub bugs? yourvirtualwizar Writers' Corner 15 03-24-2015 11:57 AM
FileTypePlugin, config_widget, JSONConfig and Cancel Apprentice Alf Development 3 02-28-2013 12:41 PM
What is it called? Crusader Writers' Corner 18 07-25-2011 04:04 AM
What is it called? crutledge Workshop 3 05-04-2009 02:12 PM


All times are GMT -4. The time now is 05:42 AM.


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