| 1 |
.. _plugins: |
| 2 |
|
| 3 |
API documentation for plugins |
| 4 |
=============================== |
| 5 |
|
| 6 |
.. module:: calibre.customize |
| 7 |
:synopsis: Defines various abstract base classes that can be subclassed to create plugins. |
| 8 |
|
| 9 |
Defines various abstract base classes that can be subclassed to create powerful plugins. The useful |
| 10 |
classes are: |
| 11 |
|
| 12 |
.. contents:: |
| 13 |
:depth: 1 |
| 14 |
:local: |
| 15 |
|
| 16 |
.. _pluginsPlugin: |
| 17 |
|
| 18 |
Plugin |
| 19 |
----------------- |
| 20 |
|
| 21 |
.. autoclass:: Plugin |
| 22 |
:members: |
| 23 |
:member-order: bysource |
| 24 |
|
| 25 |
.. _pluginsFTPlugin: |
| 26 |
|
| 27 |
FileTypePlugin |
| 28 |
----------------- |
| 29 |
|
| 30 |
.. autoclass:: FileTypePlugin |
| 31 |
:show-inheritance: |
| 32 |
:members: |
| 33 |
:member-order: bysource |
| 34 |
|
| 35 |
.. _pluginsMetadataPlugin: |
| 36 |
|
| 37 |
|
| 38 |
Metadata plugins |
| 39 |
------------------- |
| 40 |
|
| 41 |
.. autoclass:: MetadataReaderPlugin |
| 42 |
:show-inheritance: |
| 43 |
:members: |
| 44 |
:member-order: bysource |
| 45 |
|
| 46 |
|
| 47 |
.. autoclass:: MetadataWriterPlugin |
| 48 |
:show-inheritance: |
| 49 |
:members: |
| 50 |
:member-order: bysource |
| 51 |
|
| 52 |
|
| 53 |
Catalog plugins |
| 54 |
---------------- |
| 55 |
|
| 56 |
.. autoclass:: CatalogPlugin |
| 57 |
:show-inheritance: |
| 58 |
:members: |
| 59 |
:member-order: bysource |
| 60 |
|
| 61 |
.. _pluginsMetadataSource: |
| 62 |
|
| 63 |
Metadata download plugins |
| 64 |
-------------------------- |
| 65 |
|
| 66 |
.. module:: calibre.ebooks.metadata.sources.base |
| 67 |
|
| 68 |
.. autoclass:: Source |
| 69 |
:show-inheritance: |
| 70 |
:members: |
| 71 |
:member-order: bysource |
| 72 |
|
| 73 |
.. autoclass:: InternalMetadataCompareKeyGen |
| 74 |
|
| 75 |
Conversion plugins |
| 76 |
-------------------- |
| 77 |
|
| 78 |
.. module:: calibre.customize.conversion |
| 79 |
|
| 80 |
.. autoclass:: InputFormatPlugin |
| 81 |
:show-inheritance: |
| 82 |
:members: |
| 83 |
:member-order: bysource |
| 84 |
|
| 85 |
.. autoclass:: OutputFormatPlugin |
| 86 |
:show-inheritance: |
| 87 |
:members: |
| 88 |
:member-order: bysource |
| 89 |
|
| 90 |
Device drivers |
| 91 |
----------------- |
| 92 |
|
| 93 |
.. module:: calibre.devices.interface |
| 94 |
|
| 95 |
The base class for all device drivers is :class:`DevicePlugin`. However, if your device exposes itself as a USBMS drive to the operating system, |
| 96 |
you should use the USBMS class instead as it implements all the logic needed to support these kinds of devices. |
| 97 |
|
| 98 |
.. autoclass:: DevicePlugin |
| 99 |
:show-inheritance: |
| 100 |
:members: |
| 101 |
:member-order: bysource |
| 102 |
|
| 103 |
.. autoclass:: BookList |
| 104 |
:show-inheritance: |
| 105 |
:members: |
| 106 |
:member-order: bysource |
| 107 |
|
| 108 |
|
| 109 |
USB Mass Storage based devices |
| 110 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 111 |
|
| 112 |
The base class for such devices is :class:`calibre.devices.usbms.driver.USBMS`. This class in turn inherits some of its functionality |
| 113 |
from its bases, documented below. A typical basic USBMS based driver looks like this: |
| 114 |
|
| 115 |
.. code-block:: python |
| 116 |
|
| 117 |
from calibre.devices.usbms.driver import USBMS |
| 118 |
|
| 119 |
class PDNOVEL(USBMS): |
| 120 |
name = 'Pandigital Novel device interface' |
| 121 |
gui_name = 'PD Novel' |
| 122 |
description = _('Communicate with the Pandigital Novel') |
| 123 |
author = 'Kovid Goyal' |
| 124 |
supported_platforms = ['windows', 'linux', 'osx'] |
| 125 |
FORMATS = ['epub', 'pdf'] |
| 126 |
|
| 127 |
VENDOR_ID = [0x18d1] |
| 128 |
PRODUCT_ID = [0xb004] |
| 129 |
BCD = [0x224] |
| 130 |
|
| 131 |
THUMBNAIL_HEIGHT = 144 |
| 132 |
|
| 133 |
EBOOK_DIR_MAIN = 'eBooks' |
| 134 |
SUPPORTS_SUB_DIRS = False |
| 135 |
|
| 136 |
def upload_cover(self, path, filename, metadata): |
| 137 |
coverdata = getattr(metadata, 'thumbnail', None) |
| 138 |
if coverdata and coverdata[2]: |
| 139 |
with open('%s.jpg' % os.path.join(path, filename), 'wb') as coverfile: |
| 140 |
coverfile.write(coverdata[2]) |
| 141 |
|
| 142 |
.. autoclass:: calibre.devices.usbms.device.Device |
| 143 |
:show-inheritance: |
| 144 |
:members: |
| 145 |
:member-order: bysource |
| 146 |
|
| 147 |
.. autoclass:: calibre.devices.usbms.cli.CLI |
| 148 |
:members: |
| 149 |
:member-order: bysource |
| 150 |
|
| 151 |
.. autoclass:: calibre.devices.usbms.driver.USBMS |
| 152 |
:show-inheritance: |
| 153 |
:members: |
| 154 |
:member-order: bysource |
| 155 |
|
| 156 |
User interface actions |
| 157 |
-------------------------- |
| 158 |
|
| 159 |
If you are adding your own plugin in a ZIP file, you should subclass both InterfaceActionBase and InterfaceAction. The |
| 160 |
:meth:`load_actual_plugin` method of your InterfaceActionBase subclass must return an instantiated object of your InterfaceAction subclass. |
| 161 |
|
| 162 |
|
| 163 |
.. autoclass:: calibre.gui2.actions.InterfaceAction |
| 164 |
:show-inheritance: |
| 165 |
:members: |
| 166 |
:member-order: bysource |
| 167 |
|
| 168 |
.. autoclass:: calibre.customize.InterfaceActionBase |
| 169 |
:show-inheritance: |
| 170 |
:members: |
| 171 |
:member-order: bysource |
| 172 |
|
| 173 |
|
| 174 |
Preferences plugins |
| 175 |
-------------------------- |
| 176 |
|
| 177 |
.. autoclass:: calibre.customize.PreferencesPlugin |
| 178 |
:show-inheritance: |
| 179 |
:members: |
| 180 |
:member-order: bysource |
| 181 |
|
| 182 |
.. autoclass:: calibre.gui2.preferences.ConfigWidgetInterface |
| 183 |
:members: |
| 184 |
:member-order: bysource |
| 185 |
|
| 186 |
.. autoclass:: calibre.gui2.preferences.ConfigWidgetBase |
| 187 |
:members: |
| 188 |
:member-order: bysource |