Implement #368 add torrents by infohash/magnet uri (trackerless

torrents)
This commit is contained in:
Andrew Resch 2008-09-30 19:07:10 +00:00
parent 87f3e1e3b8
commit 26b872dee9
3 changed files with 22 additions and 12 deletions

View File

@ -5,7 +5,7 @@ Deluge 1.1.0 - "" (In Development)
* Add per-torrent move on completed settings
* Implement #414 use async save_resume_data method
* FilterManager with torrent filtering in get_torrents_status , for sidebar and plugins.
* Implement #368 add torrents by infohash/magnet uri (trackerless torrents)
GtkUI:
* Add peer progress to the peers tab

View File

@ -107,7 +107,7 @@ class TorrentOptions(dict):
class Torrent:
"""Torrent holds information about torrents added to the libtorrent session.
"""
def __init__(self, handle, options, state=None, filename=None):
def __init__(self, handle, options, state=None, filename=None, magnet=None):
log.debug("Creating torrent object %s", str(handle.info_hash()))
# Get the core config
self.config = ConfigManager("core.conf")
@ -129,6 +129,9 @@ class Torrent:
self.filename = filename
# Store the magnet uri used to add this torrent if available
self.magnet = magnet
# Holds status info so that we don't need to keep getting it from lt
self.status = self.handle.status()

View File

@ -71,7 +71,8 @@ class TorrentState:
is_finished=False,
stop_ratio=2.00,
stop_at_ratio=False,
remove_at_ratio=False
remove_at_ratio=False,
magnet=None
):
self.torrent_id = torrent_id
self.filename = filename
@ -79,6 +80,7 @@ class TorrentState:
self.trackers = trackers
self.queue = queue
self.is_finished = is_finished
self.magnet = magnet
# Options
self.compact = compact
@ -287,12 +289,16 @@ class TorrentManager(component.Component):
options["auto_managed"] = state.auto_managed
options["add_paused"] = state.paused
if not state.magnet:
add_torrent_params["ti"] =\
self.get_torrent_info_from_file(
os.path.join(self.config["state_location"], state.torrent_id + ".torrent"))
if not add_torrent_params["ti"]:
log.error("Unable to add torrent!")
return
else:
magnet = state.magnet
add_torrent_params["resume_data"] = self.get_resume_data_from_file(state.torrent_id)
else:
@ -348,7 +354,7 @@ class TorrentManager(component.Component):
# Set auto_managed to False because the torrent is paused
handle.auto_managed(False)
# Create a Torrent object
torrent = Torrent(handle, options, state, filename)
torrent = Torrent(handle, options, state, filename, magnet)
# Add the torrent object to the dictionary
self.torrents[torrent.torrent_id] = torrent
if self.config["queue_new_to_top"]:
@ -525,7 +531,8 @@ class TorrentManager(component.Component):
torrent.is_finished,
torrent.options["stop_ratio"],
torrent.options["stop_at_ratio"],
torrent.options["remove_at_ratio"]
torrent.options["remove_at_ratio"],
torrent.magnet
)
state.torrents.append(torrent_state)