wiki:Developers
Last modified 4 weeks ago Last modified on 04/28/13 02:00:05

Developer related material

API is not yet stabilized. Expect some changes to happen. Yes, documentation is not very good at the moment.

Technologies used

  • Core
    • SQLAlchemy
    • BeautifulSoup
    • FeedParser
    • Python-Requests
    • PyNzb
    • Jinja2
    • PyYaml
    • Some smaller misc libraries
  • WebUI
    • Flask
    • Jinja2
    • Cherrypy

Resources

Resources, autogenerated from wiki

ListTagged(developers)?

Contributing

Making custom plugins should be easy for anyone with some python experience.

If you're working on good re-usable plugin we're be more than happy to include it in official distribution. See Contribute for more information.

Plugins

Plugins are registered by calling register_plugin method.

register_plugin(<class name>, '<keyword>', [parameters])

You can also pass some optional named arguments

Optional arguments:
    builtin     - set to True if plugin should be executed always
    group       - group name this plugin belongs to
    groups      - list of group names this plugin belongs to

Example:

register_plugin(FilterRegexp, 'regexp')

Phase methods

Listed in order of execution.

  • on_task_start(self, task, config)
  • on_task_input(self, task, config)
  • on_task_metainfo(self, task, config)
  • on_task_filter(self, task, config)
  • on_task_download(self, task, config)
  • on_task_modify(self, task, config)
  • on_task_output(self, task, config)
  • on_task_exit(self, task, config)

When multiple plugins of same phase type are enabled for a task, the priority decorator can be used to define execution order. Default is 128. Larger number, higher priority. e.g.

@priority(120)
on_task_filter(self, task, config):
    pass

Task execution UML

Only most important phases shown.

Other phases

  • on_task_abort(self, task, config)

Application phases

  • on_process_start(self, task, config)
  • on_process_end(self, task, config)

These are triggered on startup and shutdown, not between tasks.

Registering custom phases

Plugins may create new task phases, signature is on_task_<name>(self, task, ....) (parameters depend on api version).

Adding commandline parameters

You can also add more commandline parameters. Check existing plugins. See Optik homepage for documentation.

Unit testing

FlexGet has over 200 unit tests so changes are that if your modifications pass the tests nothing major has been broken. We also have CI at http://ci.flexget.com.

Install tools

You can install needed testing tools with:

bin/paver install_tools

Run tests

bin/paver test

Argument --online can be used to enable online tests

Run a single test

# NOTE: don't use the pathname for the file, e.g. tests/test_file.py
bin/nosetests test_file

Running IPython inside FlexGet

First install IPython

bin/easy_install ipython

And then place this where you wish to hack:

import IPython; IPython.embed()

Thanks to JetBrains for the free open source PyCharm license!

Attachments