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 08-26-2022, 06:45 AM   #1
igorius
Zealot
igorius began at the beginning.
 
Posts: 117
Karma: 34
Join Date: Jun 2015
Device: ipad & inkpad X
Writing plugins extended howto

Hello,
I want to change some plugins to make them meet better my wishes, but to be clear, i dont have any knowledge in programming python, documentation inside the plugins is mostly not available, some code i dont find mentioned anywhere in the calibre docs (example: notifications.put()), code sometimes is not readable for me (everywhere i get told "Python is easyly to understand due to the easy way of programming").
I have read the documentation to write plugins but mostly i dont understand because to what i read it seems to be only a brief start and then the docu jumps to other section (all reading the plugins section), and before mentioned variables change completely, say i dont find a line to understand the whole thing.
So if anyone says "go away and learn basics", thats ok, but i want to understand!
So if anyone can tell me how to start, which IDE to use, whatever book to read or which site will tell the basics, tell me!
Thanks much in advance for any answer!
igorius is offline   Reply With Quote
Old 09-15-2022, 04:56 AM   #2
feuille
Connoisseur
feuille will become famous soon enoughfeuille will become famous soon enoughfeuille will become famous soon enoughfeuille will become famous soon enoughfeuille will become famous soon enoughfeuille will become famous soon enough
 
Posts: 55
Karma: 666
Join Date: May 2020
Location: Germany
Device: android smartphone + tablet
Plugins HowTo

I faced the same problem two years ago. Personally, I started developing a metadata plugin while learning Python (but already knew a dozen other programming languages).

As IDE I use the community version of PyCharm.

For a metadata plugin, the __init__.py file with a class called "PluginName(Source)" is sufficient. At least the Calibre function "identify(self, log, result_queue, abort, title=None, authors=None, identifiers={}, timeout=30)" has to be implemented in it. The author and title are passed and the scraping for the metadata has to be coded. Finally the downloaded metadata is to put in the "mi"-queue structure to pass over to Calibre.

If you also want to download cover images, you also implement "download_cover(self, log, result_queue, abort, title=None, authors=None, identifiers={}, timeout=30, get_best_cover=True)".

That's all.

Of course, you can also distribute the code over several files (then you also need an empty file "plugin-import-name-PluginName.txt") and use workers for parallel tasks, as some plugins do, doing translations...

Then you can control the program flow with custom parameters by implementing a data structure called "options = (}" (see base.py - the Calibre source code on GitHub is really helpful!).

I am developing on a Windows machine. To integrate the plugin locally into Calibre, I use a "plugin_install.bat": "calibre-customize -b .
Test outputs are produced with "log.info()". They are then displayed in the log.

The development of GUI plugins is of course more complex.

I hope this helps!
feuille is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Systemwide installation of plugins / Discovery of installed plugins via pkg_resources t-8ch Development 8 11-14-2020 09:25 AM
Writing within writing: Italics vs Quotations E.M.DuBois Writers' Corner 25 06-16-2019 02:56 PM
Newcomer's thoughts about writing calibre plugins Marco77 Development 1 01-01-2017 09:13 PM
Getting PyCharm code completion while writing Calibre plugins trying Development 6 03-30-2014 05:47 AM
update howto m-s-s iRex 5 07-01-2007 03:52 PM


All times are GMT -4. The time now is 04:46 AM.


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