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 return d
@export @export
def add_torrent_magnets(self, uris, options): def add_torrent_magnet(self, uri, options):
for uri in uris: """
log.debug("Attempting to add by magnet uri: %s", uri) Adds a torrent from a magnet link.
try:
option = options[uris.index(uri)]
except IndexError:
option = None
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 @export
def remove_torrent(self, torrent_ids, remove_data): def remove_torrent(self, torrent_ids, remove_data):

View File

@ -751,7 +751,8 @@ class AddTorrentDialog(component.Component):
base64.encodestring(open(f, "rb").read()), base64.encodestring(open(f, "rb").read()),
torrent_options[i]) torrent_options[i])
if torrent_magnets: 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) client.force_call(False)
self.hide() self.hide()

View File

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