Transmission support
This commit is contained in:
1 parent
a71f84522d
commit
da63eca623
11 files changed
+1612
No files matched your search
@@ -0,0 +1,50 @@
|
||||
from .main import Transmission
|
||||
|
||||
def start():
|
||||
return Transmission()
|
||||
|
||||
config = [{
|
||||
'name': 'transmission',
|
||||
'groups': [
|
||||
{
|
||||
'tab': 'downloaders',
|
||||
'name': 'transmission',
|
||||
'label': 'Transmission',
|
||||
'description': 'Send NZBs to your NZBGet installation.',
|
||||
'options': [
|
||||
{
|
||||
'name': 'enabled',
|
||||
'default': 0,
|
||||
'type': 'enabler',
|
||||
},
|
||||
{
|
||||
'name': 'host',
|
||||
'default': 'localhost:9091',
|
||||
'description': 'Hostname with port. Usually <strong>localhost:9091</strong>',
|
||||
},
|
||||
{
|
||||
'name': 'username',
|
||||
},
|
||||
{
|
||||
'name': 'password',
|
||||
},
|
||||
{
|
||||
'name': 'paused',
|
||||
'type': 'bool',
|
||||
'description': 'Add the torrent paused.',
|
||||
},
|
||||
{
|
||||
'name': 'directory',
|
||||
'type': 'directory',
|
||||
'description': 'Where should Transmission saved the downloaded files?',
|
||||
},
|
||||
{
|
||||
'name': 'ratio',
|
||||
'default': 10,
|
||||
'advanced': True,
|
||||
'description': 'Stop transfer when reaching ratio',
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
}]
|
||||
@@ -0,0 +1,52 @@
|
||||
from couchpotato.core.downloaders.base import Downloader
|
||||
from couchpotato.core.helpers.encoding import isInt
|
||||
from couchpotato.core.logger import CPLog
|
||||
from libs import transmissionrpc
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Transmission(Downloader):
|
||||
|
||||
type = ['torrent']
|
||||
|
||||
def download(self, data = {}, movie = {}):
|
||||
|
||||
if self.isDisabled() or not self.isCorrectType(data.get('type')):
|
||||
return
|
||||
|
||||
log.info('Sending "%s" to Transmission.' % data.get('name'))
|
||||
|
||||
|
||||
# Load host from config and split out port.
|
||||
host = self.conf('host').split(':')
|
||||
if not isInt(host[1]):
|
||||
log.error("Config properties are not filled in correctly, port is missing.")
|
||||
return False
|
||||
|
||||
# Set parameters for Transmission
|
||||
params = {
|
||||
'paused': self.conf('paused', 0),
|
||||
'download_dir': self.conf('directory', None)
|
||||
}
|
||||
change_params = {
|
||||
'seedRatioLimit': self.conf('ratio'),
|
||||
'seedRatioMode': 1 if self.conf('ratio') else 0
|
||||
}
|
||||
|
||||
try:
|
||||
tc = transmissionrpc.Client(host[0], port = host[1], user = self.conf('username'), password = self.conf('password'))
|
||||
tr_id = tc.add_uri(data.get('url'), **params)
|
||||
|
||||
# Change settings of added torrents
|
||||
for item in tr_id:
|
||||
try:
|
||||
tc.change(item, timeout = None, **change_params)
|
||||
except transmissionrpc.TransmissionError, e:
|
||||
log.error('Failed to change settings for transfer in transmission: %s' % e)
|
||||
|
||||
return True
|
||||
|
||||
except transmissionrpc.TransmissionError, e:
|
||||
log.error('Failed to send link to transmission: %s' % e)
|
||||
return False
|
||||
Reference in new issue
Block a user