mirror of
https://github.com/nikdoof/flexget-plugins.git
synced 2025-12-13 05:12:15 +00:00
Started rtorrent output plugin
This commit is contained in:
6
README
6
README
@@ -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
51
output_rtorrent.py
Normal 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)
|
||||
Reference in New Issue
Block a user