Implement #368 add torrents by infohash/magnet uri (trackerless
torrents)
This commit is contained in:
parent
87f3e1e3b8
commit
26b872dee9
|
@ -5,7 +5,7 @@ Deluge 1.1.0 - "" (In Development)
|
||||||
* Add per-torrent move on completed settings
|
* Add per-torrent move on completed settings
|
||||||
* Implement #414 use async save_resume_data method
|
* Implement #414 use async save_resume_data method
|
||||||
* FilterManager with torrent filtering in get_torrents_status , for sidebar and plugins.
|
* FilterManager with torrent filtering in get_torrents_status , for sidebar and plugins.
|
||||||
|
* Implement #368 add torrents by infohash/magnet uri (trackerless torrents)
|
||||||
|
|
||||||
GtkUI:
|
GtkUI:
|
||||||
* Add peer progress to the peers tab
|
* Add peer progress to the peers tab
|
||||||
|
|
|
@ -107,7 +107,7 @@ class TorrentOptions(dict):
|
||||||
class Torrent:
|
class Torrent:
|
||||||
"""Torrent holds information about torrents added to the libtorrent session.
|
"""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()))
|
log.debug("Creating torrent object %s", str(handle.info_hash()))
|
||||||
# Get the core config
|
# Get the core config
|
||||||
self.config = ConfigManager("core.conf")
|
self.config = ConfigManager("core.conf")
|
||||||
|
@ -129,6 +129,9 @@ class Torrent:
|
||||||
|
|
||||||
self.filename = filename
|
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
|
# Holds status info so that we don't need to keep getting it from lt
|
||||||
self.status = self.handle.status()
|
self.status = self.handle.status()
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,8 @@ class TorrentState:
|
||||||
is_finished=False,
|
is_finished=False,
|
||||||
stop_ratio=2.00,
|
stop_ratio=2.00,
|
||||||
stop_at_ratio=False,
|
stop_at_ratio=False,
|
||||||
remove_at_ratio=False
|
remove_at_ratio=False,
|
||||||
|
magnet=None
|
||||||
):
|
):
|
||||||
self.torrent_id = torrent_id
|
self.torrent_id = torrent_id
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
|
@ -79,6 +80,7 @@ class TorrentState:
|
||||||
self.trackers = trackers
|
self.trackers = trackers
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
self.is_finished = is_finished
|
self.is_finished = is_finished
|
||||||
|
self.magnet = magnet
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
self.compact = compact
|
self.compact = compact
|
||||||
|
@ -287,12 +289,16 @@ class TorrentManager(component.Component):
|
||||||
options["auto_managed"] = state.auto_managed
|
options["auto_managed"] = state.auto_managed
|
||||||
options["add_paused"] = state.paused
|
options["add_paused"] = state.paused
|
||||||
|
|
||||||
|
if not state.magnet:
|
||||||
add_torrent_params["ti"] =\
|
add_torrent_params["ti"] =\
|
||||||
self.get_torrent_info_from_file(
|
self.get_torrent_info_from_file(
|
||||||
os.path.join(self.config["state_location"], state.torrent_id + ".torrent"))
|
os.path.join(self.config["state_location"], state.torrent_id + ".torrent"))
|
||||||
|
|
||||||
if not add_torrent_params["ti"]:
|
if not add_torrent_params["ti"]:
|
||||||
log.error("Unable to add torrent!")
|
log.error("Unable to add torrent!")
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
magnet = state.magnet
|
||||||
|
|
||||||
add_torrent_params["resume_data"] = self.get_resume_data_from_file(state.torrent_id)
|
add_torrent_params["resume_data"] = self.get_resume_data_from_file(state.torrent_id)
|
||||||
else:
|
else:
|
||||||
|
@ -348,7 +354,7 @@ class TorrentManager(component.Component):
|
||||||
# Set auto_managed to False because the torrent is paused
|
# Set auto_managed to False because the torrent is paused
|
||||||
handle.auto_managed(False)
|
handle.auto_managed(False)
|
||||||
# Create a Torrent object
|
# Create a Torrent object
|
||||||
torrent = Torrent(handle, options, state, filename)
|
torrent = Torrent(handle, options, state, filename, magnet)
|
||||||
# Add the torrent object to the dictionary
|
# Add the torrent object to the dictionary
|
||||||
self.torrents[torrent.torrent_id] = torrent
|
self.torrents[torrent.torrent_id] = torrent
|
||||||
if self.config["queue_new_to_top"]:
|
if self.config["queue_new_to_top"]:
|
||||||
|
@ -525,7 +531,8 @@ class TorrentManager(component.Component):
|
||||||
torrent.is_finished,
|
torrent.is_finished,
|
||||||
torrent.options["stop_ratio"],
|
torrent.options["stop_ratio"],
|
||||||
torrent.options["stop_at_ratio"],
|
torrent.options["stop_at_ratio"],
|
||||||
torrent.options["remove_at_ratio"]
|
torrent.options["remove_at_ratio"],
|
||||||
|
torrent.magnet
|
||||||
)
|
)
|
||||||
state.torrents.append(torrent_state)
|
state.torrents.append(torrent_state)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue