Commit 2c4ce80a authored by echel0n's avatar echel0n

Fixed location issue with Transmission client.

parent d023922e
# Changelog
- * 2786e5e - 2018-11-08: Release v9.4.22
- * 0197249 - 2018-11-09: Fixed location issue with Transmission client.
- * f98b5e8 - 2018-11-08: Release v9.4.22
- * d705db2 - 2018-11-08: Fixed startup issues with systemd init script.
- * 5bb165d - 2018-11-08: Release v9.4.21
- * dc15dc2 - 2018-11-08: Fixed issues with YGGToreent provider searches.
......
......@@ -19,6 +19,7 @@
from __future__ import unicode_literals
import json
import os
from base64 import b64encode
import sickrage
......@@ -43,10 +44,10 @@ class TransmissionAPI(GenericClient):
def _get_auth(self):
self.response = self.session.post(self.url,
data=json.dumps({'method': 'session-get', }),
timeout=120,
auth=(self.username, self.password),
verify=bool(sickrage.app.config.torrent_verify_cert))
data=json.dumps({'method': 'session-get', }),
timeout=120,
auth=(self.username, self.password),
verify=bool(sickrage.app.config.torrent_verify_cert))
# get auth session header
self.auth = self.response.headers['x-transmission-session-id'] if self.response is not None else None
......@@ -65,31 +66,40 @@ class TransmissionAPI(GenericClient):
return super(TransmissionAPI, self)._request(*args, **kwargs)
def _add_torrent_uri(self, result):
arguments = {
'filename': result.url,
'paused': 1 if sickrage.app.config.torrent_paused else 0,
}
arguments = {'filename': result.url,
'paused': 1 if sickrage.app.config.torrent_paused else 0,
'download-dir': sickrage.app.config.torrent_path}
if os.path.isabs(sickrage.app.config.torrent_path):
arguments['download-dir'] = sickrage.app.config.torrent_path
post_data = json.dumps({'arguments': arguments,
'method': 'torrent-add'})
post_data = json.dumps({
'arguments': arguments,
'method': 'torrent-add'
})
if self._request(method='post', data=post_data):
return self.response.json()['result'] == "success"
def _add_torrent_file(self, result):
arguments = {
'metainfo': b64encode(result.content),
'paused': 1 if sickrage.app.config.torrent_paused else 0
}
arguments = {'metainfo': b64encode(result.content),
'paused': 1 if sickrage.app.config.torrent_paused else 0,
'download-dir': sickrage.app.config.torrent_path}
if os.path.isabs(sickrage.app.config.torrent_path):
arguments['download-dir'] = sickrage.app.config.torrent_path
post_data = json.dumps({'arguments': arguments,
'method': 'torrent-add'})
post_data = json.dumps({
'arguments': arguments,
'method': 'torrent-add'
})
if self._request(method='post', data=post_data):
return self.response.json()['result'] == "success"
def _set_torrent_ratio(self, result):
ratio = None
if isinstance(result.ratio, (int, long)):
ratio = result.ratio
......@@ -103,26 +113,33 @@ class TransmissionAPI(GenericClient):
ratio = float(ratio)
mode = 1 # Stop seeding at seedRatioLimit
arguments = {'ids': [result.hash],
'seedRatioLimit': ratio,
'seedRatioMode': mode}
arguments = {
'ids': [result.hash],
'seedRatioLimit': ratio,
'seedRatioMode': mode
}
post_data = json.dumps({'arguments': arguments,
'method': 'torrent-set'})
post_data = json.dumps({
'arguments': arguments,
'method': 'torrent-set'
})
if self._request(method='post', data=post_data):
return self.response.json()['result'] == "success"
def _set_torrent_seed_time(self, result):
if sickrage.app.config.torrent_seed_time and sickrage.app.config.torrent_seed_time != -1:
time = int(60 * float(sickrage.app.config.torrent_seed_time))
arguments = {'ids': [result.hash],
'seedIdleLimit': time,
'seedIdleMode': 1}
arguments = {
'ids': [result.hash],
'seedIdleLimit': time,
'seedIdleMode': 1
}
post_data = json.dumps({'arguments': arguments,
'method': 'torrent-set'})
post_data = json.dumps({
'arguments': arguments,
'method': 'torrent-set'
})
if self._request(method='post', data=post_data):
return self.response.json()['result'] == "success"
......@@ -130,7 +147,6 @@ class TransmissionAPI(GenericClient):
return True
def _set_torrent_priority(self, result):
arguments = {'ids': [result.hash]}
if result.priority == -1:
......@@ -145,8 +161,24 @@ class TransmissionAPI(GenericClient):
else:
arguments['priority-normal'] = []
post_data = json.dumps({'arguments': arguments,
'method': 'torrent-set'})
post_data = json.dumps({
'arguments': arguments,
'method': 'torrent-set'
})
if self._request(method='post', data=post_data):
return self.response.json()['result'] == "success"
def remove_torrent(self, info_hash):
arguments = {
'ids': [info_hash],
'delete-local-data': 1,
}
post_data = json.dumps({
'arguments': arguments,
'method': 'torrent-remove',
})
if self._request(method='post', data=post_data):
return self.response.json()['result'] == "success"
......
......@@ -975,7 +975,7 @@
<label for="torrent_path">
${_('where the torrent client will save downloaded files (blank for client default)')}
<br/>
<b>${_('NOTE:')}</b> ${_('the destination has to be a shared folder for Synology DS')}
<b>${_('NOTE:')}</b> ${_('the destination has to be a shared folder for Synology DS devices')}
</label>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment