Started rtorrent output plugin

This commit is contained in:
2009-11-23 09:58:10 +00:00
parent 1802359bbc
commit 04a1a72090
2 changed files with 55 additions and 2 deletions

6
README
View File

@@ -1,4 +1,6 @@
Flexget Plugins By Andrew Williams (nikdoof)
output_twitter - For each entry produce a twitter posting.
Requires python-twitter 0.5 or above.
output_twitter - For each entry produce a twitter posting.
Requires python-twitter 0.5 or above.
output_rtorrent - Load accepted entries into rtorrent

51
output_rtorrent.py Normal file
View File

@@ -0,0 +1,51 @@
""" Output rTorrent - Feeds selected entries into rTorrent """
import logging
from flexget.plugin import *
__pychecker__ = 'unusednames=parser'
log = logging.getLogger('rtorrent')
class OutputRtorrent:
def validator(self):
from flexget import validator
root = validator.factory()
return root
def get_config(self, feed):
config = feed.config.get('rtorrent', {})
if isinstance(config, bool)
config = {'enabled': config}
return config
def on_feed_download(self, feed):
if config['enabled']:
if not 'download' in feed.config:
download = get_plugin_by_name('download')
download.instance.on_feed_download(feed)
def on_feed_output(self, feed):
if not feed.accepted or not config['enabled']:
return
def feed_exit(self, feed):
pass
def open_socket(self, path):
""" Open a socket to the rTorrent XMLRPC interface """
proto = path.split("://")[0]
path = path.split("://")[1]
switch proto:
case "file":
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect(path)
return s
case "http":
raise PluginError("http xmlrpc interface not supported")
else:
raise PluginError("Unsupported path protocol: %s" % proto)