Version 3 (modified by andar, 14 years ago) (diff)



When considering to write a plugin for Deluge, one must first understand the basic design of Deluge. Deluge is split in two, the core and the user-interface of which there could be many. When writing your plugin you will be writing a Core portion and, perhaps, many different UI portions. This may sound complicated and at times it can be, but once you get the hang of it, it becomes second-hand.

Skill Checklist

This is a list of recommended skills or knowledge that you may need to successfully write a plugin. This is by no means required, but can serve as a starting point if you're not sure what you need to know. It may also be a good idea to read How To Write a Client first, to give you some idea of how a UI would interact with the Core.

  • Python
  • Twisted, specifically Deferreds
  • GTK and possibly Glade
  • Javascript for the WebUI portions

Designing Your Plugin

Deluge has the ability to function in a headless environment with only the daemon (Core) portion running. Various user-interfaces will connect from time to time and view or modify the session, but may not be connected all the time, so the "smarts" of your plugin should reside in the core. You should also be aware that multiple UIs may be connected at the same time and they will need to behave correctly in terms of your plugin. Typically, the best place to start writing your plugin is in the Core portion since it will contain most of the plugin logic, with the UI portions typically responsible for displaying and modifying plugin configuration or providing the user with status updates.

Conceptually you'll want to view your plugin as a collection of separate programs with your UI programs interfacing with your Core program through an RPC interface. They do not share the same space in memory and may in fact be run on different computers, so information from the Core will need to be accessible to the clients through it's RPC exported functions -- and you can't send any object over this interface, only the basic types.

Getting Started

The easiest way to get started is to use the script in the appropriate branch in our SvnRepo?. Alternatively, you can use other plugins as a template for your own if you prefer.

Running the script:

$ python --name MyPlugin --basepath . --author-name "Your Name" --author-email ""

This should create a directory called myplugin under which should be a collection of directories and files which will form the base of your plugin.

The file structure should look like this (perhaps a bit more since it does a build right away):

|-- myplugin
|   |--
|   |--
|   |--
|   |-- data
|   |   `--
|   |--
|   |-- template
|   |   `-- default.html
|   `--

Modifying Metadata

You may want to change or add some stuff to your plugin's metadata, such as the description or perhaps a URL for your project. To do this, navigate to your myplugin directory and open up the file. You will see a few different properties and modifying them should be self-explanatory, but you should refrain from changing the plugin name.

Building The Plugin

Whenever you want to test out your plugin in Deluge, you will need to build it into an egg.

First off, navigate to your myplugin base directory, you should see a file in there. Next, run the following command:

$ python bdist_egg

It's as simple as that. You can also use this method to create an egg for distribution to other Deluge users. The egg will be located in the dist directory.