Keep track of newly added torrents in the SessionProxy
This commit is contained in:
parent
76de427b96
commit
2956a7db54
|
@ -68,6 +68,7 @@ class SessionProxy(component.Component):
|
||||||
|
|
||||||
client.register_event_handler("TorrentStateChangedEvent", self.on_torrent_state_changed)
|
client.register_event_handler("TorrentStateChangedEvent", self.on_torrent_state_changed)
|
||||||
client.register_event_handler("TorrentRemovedEvent", self.on_torrent_removed)
|
client.register_event_handler("TorrentRemovedEvent", self.on_torrent_removed)
|
||||||
|
client.register_event_handler("TorrentAddedEvent", self.on_torrent_added)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
def on_torrent_status(status):
|
def on_torrent_status(status):
|
||||||
|
@ -223,5 +224,11 @@ class SessionProxy(component.Component):
|
||||||
def on_torrent_state_changed(self, torrent_id, state):
|
def on_torrent_state_changed(self, torrent_id, state):
|
||||||
self.torrents[torrent_id][1]["state"] = state
|
self.torrents[torrent_id][1]["state"] = state
|
||||||
|
|
||||||
|
def on_torrent_added(self, torrent_id):
|
||||||
|
self.torrents[torrent_id] = [time.time() - self.cache_time - 1, {}]
|
||||||
|
def on_status(status):
|
||||||
|
self.torrents[torrent_id][1].update(status)
|
||||||
|
client.core.get_torrent_status(torrent_id, []).addCallback(on_status)
|
||||||
|
|
||||||
def on_torrent_removed(self, torrent_id):
|
def on_torrent_removed(self, torrent_id):
|
||||||
del self.torrents[torrent_id]
|
del self.torrents[torrent_id]
|
||||||
|
|
Loading…
Reference in New Issue