Added support for labels on the rtorrent downloader.

This commit is contained in:
Dean Gardiner committed 2013-08-12 15:32:10 +12:00
1 parent bf62653531
commit 38e204dfe8
2 files changed
+19 -7

No files matched your search

@@ -33,7 +33,7 @@ config = [{
}, },
{ {
'name': 'label', 'name': 'label',
'description': 'Label to add torrent as.', 'description': 'Label to apply on added torrents.',
}, },
{ {
'name': 'paused', 'name': 'paused',
+18 -6
View File
@@ -25,11 +25,14 @@ class rTorrent(Downloader):
rtorrent_api = None rtorrent_api = None
def get_conn(self): def get_conn(self):
return RTorrent( if self.conf('username') and self.conf('password'):
self.conf('url'), return RTorrent(
self.conf('username'), self.conf('url'),
self.conf('password') self.conf('username'),
) self.conf('password')
)
return RTorrent(self.conf('url'))
def download(self, data, movie, filedata=None): def download(self, data, movie, filedata=None):
log.debug('Sending "%s" (%s) to rTorrent.', (data.get('name'), data.get('type'))) log.debug('Sending "%s" (%s) to rTorrent.', (data.get('name'), data.get('type')))
@@ -59,7 +62,16 @@ class rTorrent(Downloader):
if not self.rtorrent_api: if not self.rtorrent_api:
self.rtorrent_api = self.get_conn() self.rtorrent_api = self.get_conn()
torrent = self.rtorrent_api.load_torrent(filedata, not self.conf('paused', default=0)) # Send torrent to rTorrent
torrent = self.rtorrent_api.load_torrent(filedata)
# Set label
if self.conf('label'):
torrent.set_custom(1, self.conf('label'))
# Start torrent
if not self.conf('paused', default=0):
torrent.start()
return self.downloadReturnId(torrent_hash) return self.downloadReturnId(torrent_hash)
except Exception, err: except Exception, err: