Change add_torrent_magnets to add_torrent_magnet

Have add_torrent_magnet return a torrent_id on successful add
This commit is contained in:
Andrew Resch 2009-07-05 00:09:49 +00:00
parent 054ab20402
commit 2ced8ad189
3 changed files with 13 additions and 10 deletions

View File

@ -293,15 +293,17 @@ class Core(component.Component):
return d
@export
def add_torrent_magnets(self, uris, options):
for uri in uris:
log.debug("Attempting to add by magnet uri: %s", uri)
try:
option = options[uris.index(uri)]
except IndexError:
option = None
def add_torrent_magnet(self, uri, options):
"""
Adds a torrent from a magnet link.
torrent_id = self.torrentmanager.add(magnet=uri, options=option)
:param uri: str, the magnet link
:param options: dict, the options to apply to the torrent on add
"""
log.debug("Attempting to add by magnet uri: %s", uri)
return self.torrentmanager.add(magnet=uri, options=options)
@export
def remove_torrent(self, torrent_ids, remove_data):

View File

@ -751,7 +751,8 @@ class AddTorrentDialog(component.Component):
base64.encodestring(open(f, "rb").read()),
torrent_options[i])
if torrent_magnets:
client.core.add_torrent_magnets(torrent_magnets, torrent_magnet_options)
for i, m in enumerate(torrent_magnets):
client.core.add_torrent_magnet(m, torrent_magnet_options[i])
client.force_call(False)
self.hide()

View File

@ -152,7 +152,7 @@ def process_args(args):
component.get("AddTorrentDialog").add_from_magnets([arg])
component.get("AddTorrentDialog").show(config["focus_add_dialog"])
else:
client.core.add_torrent_magnets([arg], [])
client.core.add_torrent_magnet(arg, {})
else:
# Just a file
log.debug("Attempting to add %s from external source..",