| 40 | |
| 41 | = Plugin Core Code = |
| 42 | core.py: |
| 43 | {{{ |
| 44 | # |
| 45 | # a simple plugin with memory-loss |
| 46 | # adds a status-field,does not remember settings after restart of daemon. |
| 47 | |
| 48 | from deluge.log import LOG as log |
| 49 | from deluge.plugins.corepluginbase import CorePluginBase |
| 50 | |
| 51 | class Core(CorePluginBase): |
| 52 | def enable(self): |
| 53 | log.debug("*** START , HI!!!***") |
| 54 | self.labels = {} |
| 55 | # Register the 'label' status field |
| 56 | self.plugin.register_status_field("label", self._get_label) |
| 57 | log.debug("Label plugin enabled..") |
| 58 | |
| 59 | def disable(self): |
| 60 | # De-register the label field |
| 61 | self.plugin.deregister_status_field("label") |
| 62 | |
| 63 | def update(self): |
| 64 | pass |
| 65 | |
| 66 | ## Status field function ## |
| 67 | def _get_label(self, torrent_id): |
| 68 | #return label or empty string. |
| 69 | return self.labels.get(torrent_id, '') |
| 70 | |
| 71 | ## Setter ## |
| 72 | def export_set_label(self, torrent_id, label): |
| 73 | log.debug("set label %s=%s" % (torrent_id, label)) |
| 74 | self.labels[torrent_id] = str(label) |
| 75 | }}} |
| 76 | |
| 77 | = Notes = |
| 78 | |
| 79 | * all methods starting with export_ are available in s/aclient. |
| 80 | * self.plugin.register_status_field/self.plugin.register_status_field add fields to s/aclient.get_torrent_status. |
| 81 | * the enable, disable and update methods are called by the core. |
| 82 | |
106 | | from deluge.log import LOG as log |
107 | | from deluge.plugins.corepluginbase import CorePluginBase |
108 | | |
109 | | class Core(CorePluginBase): |
110 | | def enable(self): |
111 | | log.debug("*** START , HI!!!***") |
112 | | self.labels = {} |
113 | | # Register the 'label' status field |
114 | | self.plugin.register_status_field("label", self._get_label) |
115 | | log.debug("Label plugin enabled..") |
116 | | |
117 | | def disable(self): |
118 | | # De-register the label field |
119 | | self.plugin.deregister_status_field("label") |
120 | | |
121 | | def update(self): |
122 | | pass |
123 | | |
124 | | ## Status field function ## |
125 | | def _get_label(self, torrent_id): |
126 | | #return label or empty string. |
127 | | return self.labels.get(torrent_id, '') |
128 | | |
129 | | ## Setter ## |
130 | | def export_set_label(self, torrent_id, label): |
131 | | log.debug("set label %s=%s" % (torrent_id, label)) |
132 | | self.labels[torrent_id] = str(label) |
133 | | }}} |
134 | | |
135 | | = Notes = |
136 | | |
137 | | * all methods starting with export_ are available in s/aclient. |
138 | | * self.plugin.register_status_field/self.plugin.register_status_field add fields to s/aclient.get_torrent_status. |
139 | | * the enable, disable and update methods are called by the core. |
140 | | |
141 | | |