Only request needed torrent ids from deluge.
This commit is contained in:
1 parent
fb9d52c2b9
commit
99b99a992d
1 file changed
+32
-33
@@ -95,7 +95,7 @@ class Deluge(Downloader):
|
|||||||
|
|
||||||
release_downloads = ReleaseDownloadList(self)
|
release_downloads = ReleaseDownloadList(self)
|
||||||
|
|
||||||
queue = self.drpc.get_alltorrents()
|
queue = self.drpc.get_alltorrents(ids)
|
||||||
|
|
||||||
if not queue:
|
if not queue:
|
||||||
log.debug('Nothing in queue or error')
|
log.debug('Nothing in queue or error')
|
||||||
@@ -103,39 +103,38 @@ class Deluge(Downloader):
|
|||||||
|
|
||||||
for torrent_id in queue:
|
for torrent_id in queue:
|
||||||
torrent = queue[torrent_id]
|
torrent = queue[torrent_id]
|
||||||
if torrent['hash'] in ids:
|
log.debug('name=%s / id=%s / save_path=%s / move_completed_path=%s / hash=%s / progress=%s / state=%s / eta=%s / ratio=%s / stop_ratio=%s / is_seed=%s / is_finished=%s / paused=%s', (torrent['name'], torrent['hash'], torrent['save_path'], torrent['move_completed_path'], torrent['hash'], torrent['progress'], torrent['state'], torrent['eta'], torrent['ratio'], torrent['stop_ratio'], torrent['is_seed'], torrent['is_finished'], torrent['paused']))
|
||||||
log.debug('name=%s / id=%s / save_path=%s / move_completed_path=%s / hash=%s / progress=%s / state=%s / eta=%s / ratio=%s / stop_ratio=%s / is_seed=%s / is_finished=%s / paused=%s', (torrent['name'], torrent['hash'], torrent['save_path'], torrent['move_completed_path'], torrent['hash'], torrent['progress'], torrent['state'], torrent['eta'], torrent['ratio'], torrent['stop_ratio'], torrent['is_seed'], torrent['is_finished'], torrent['paused']))
|
|
||||||
|
|
||||||
# Deluge has no easy way to work out if a torrent is stalled or failing.
|
# Deluge has no easy way to work out if a torrent is stalled or failing.
|
||||||
#status = 'failed'
|
#status = 'failed'
|
||||||
status = 'busy'
|
status = 'busy'
|
||||||
if torrent['is_seed'] and tryFloat(torrent['ratio']) < tryFloat(torrent['stop_ratio']):
|
if torrent['is_seed'] and tryFloat(torrent['ratio']) < tryFloat(torrent['stop_ratio']):
|
||||||
# We have torrent['seeding_time'] to work out what the seeding time is, but we do not
|
# We have torrent['seeding_time'] to work out what the seeding time is, but we do not
|
||||||
# have access to the downloader seed_time, as with deluge we have no way to pass it
|
# have access to the downloader seed_time, as with deluge we have no way to pass it
|
||||||
# when the torrent is added. So Deluge will only look at the ratio.
|
# when the torrent is added. So Deluge will only look at the ratio.
|
||||||
# See above comment in download().
|
# See above comment in download().
|
||||||
status = 'seeding'
|
status = 'seeding'
|
||||||
elif torrent['is_seed'] and torrent['is_finished'] and torrent['paused'] and torrent['state'] == 'Paused':
|
elif torrent['is_seed'] and torrent['is_finished'] and torrent['paused'] and torrent['state'] == 'Paused':
|
||||||
status = 'completed'
|
status = 'completed'
|
||||||
|
|
||||||
|
download_dir = sp(torrent['save_path'])
|
||||||
|
if torrent['move_on_completed']:
|
||||||
|
download_dir = torrent['move_completed_path']
|
||||||
|
|
||||||
download_dir = sp(torrent['save_path'])
|
torrent_files = []
|
||||||
if torrent['move_on_completed']:
|
for file_item in torrent['files']:
|
||||||
download_dir = torrent['move_completed_path']
|
torrent_files.append(sp(os.path.join(download_dir, file_item['path'])))
|
||||||
|
|
||||||
torrent_files = []
|
release_downloads.append({
|
||||||
for file_item in torrent['files']:
|
'id': torrent['hash'],
|
||||||
torrent_files.append(sp(os.path.join(download_dir, file_item['path'])))
|
'name': torrent['name'],
|
||||||
|
'status': status,
|
||||||
release_downloads.append({
|
'original_status': torrent['state'],
|
||||||
'id': torrent['hash'],
|
'seed_ratio': torrent['ratio'],
|
||||||
'name': torrent['name'],
|
'timeleft': str(timedelta(seconds = torrent['eta'])),
|
||||||
'status': status,
|
'folder': sp(download_dir if len(torrent_files) == 1 else os.path.join(download_dir, torrent['name'])),
|
||||||
'original_status': torrent['state'],
|
'files': '|'.join(torrent_files),
|
||||||
'seed_ratio': torrent['ratio'],
|
})
|
||||||
'timeleft': str(timedelta(seconds = torrent['eta'])),
|
|
||||||
'folder': sp(download_dir if len(torrent_files) == 1 else os.path.join(download_dir, torrent['name'])),
|
|
||||||
'files': '|'.join(torrent_files),
|
|
||||||
})
|
|
||||||
|
|
||||||
return release_downloads
|
return release_downloads
|
||||||
|
|
||||||
@@ -209,11 +208,11 @@ class DelugeRPC(object):
|
|||||||
|
|
||||||
return torrent_id
|
return torrent_id
|
||||||
|
|
||||||
def get_alltorrents(self):
|
def get_alltorrents(self, ids):
|
||||||
ret = False
|
ret = False
|
||||||
try:
|
try:
|
||||||
self.connect()
|
self.connect()
|
||||||
ret = self.client.core.get_torrents_status({}, {}).get()
|
ret = self.client.core.get_torrents_status({'id': ids}, {}).get()
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
log.error('Failed to get all torrents: %s %s', (err, traceback.format_exc()))
|
log.error('Failed to get all torrents: %s %s', (err, traceback.format_exc()))
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in new issue
Block a user