|
|
@ -77,6 +77,7 @@ class uTorrent(Downloader): |
|
|
|
else: |
|
|
|
info = bdecode(filedata)["info"] |
|
|
|
torrent_hash = sha1(benc(info)).hexdigest().upper() |
|
|
|
|
|
|
|
torrent_filename = self.createFileName(data, filedata, movie) |
|
|
|
|
|
|
|
if data.get('seed_ratio'): |
|
|
@ -91,11 +92,17 @@ class uTorrent(Downloader): |
|
|
|
if len(torrent_hash) == 32: |
|
|
|
torrent_hash = b16encode(b32decode(torrent_hash)) |
|
|
|
|
|
|
|
# Set download directory |
|
|
|
if self.conf('directory'): |
|
|
|
directory = self.conf('directory') |
|
|
|
else: |
|
|
|
directory = False |
|
|
|
|
|
|
|
# Send request to uTorrent |
|
|
|
if data.get('protocol') == 'torrent_magnet': |
|
|
|
self.utorrent_api.add_torrent_uri(torrent_filename, data.get('url')) |
|
|
|
self.utorrent_api.add_torrent_uri(torrent_filename, data.get('url'), directory) |
|
|
|
else: |
|
|
|
self.utorrent_api.add_torrent_file(torrent_filename, filedata) |
|
|
|
self.utorrent_api.add_torrent_file(torrent_filename, filedata, directory) |
|
|
|
|
|
|
|
# Change settings of added torrent |
|
|
|
self.utorrent_api.set_torrent(torrent_hash, torrent_params) |
|
|
@ -249,13 +256,13 @@ class uTorrentAPI(object): |
|
|
|
def add_torrent_uri(self, filename, torrent, add_folder = False): |
|
|
|
action = "action=add-url&s=%s" % urllib.quote(torrent) |
|
|
|
if add_folder: |
|
|
|
action += "&path=%s" % urllib.quote(filename) |
|
|
|
action += "&path=%s" % urllib.quote(add_folder) |
|
|
|
return self._request(action) |
|
|
|
|
|
|
|
def add_torrent_file(self, filename, filedata, add_folder = False): |
|
|
|
action = "action=add-file" |
|
|
|
if add_folder: |
|
|
|
action += "&path=%s" % urllib.quote(filename) |
|
|
|
action += "&path=%s" % urllib.quote(add_folder) |
|
|
|
return self._request(action, {"torrent_file": (ss(filename), filedata)}) |
|
|
|
|
|
|
|
def set_torrent(self, hash, params): |
|
|
|