From ae81a28e6b0ea8bc9756941ac573c47b28a57034 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sun, 28 Oct 2007 06:30:02 +0000 Subject: [PATCH] Add 'files' key to torrent status. --- deluge/core/torrent.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 6c1b9f903..ff3ebcb4e 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -94,7 +94,19 @@ class Torrent: return 0.0 return ratio - + + def get_files(self): + """Returns a list of files this torrent contains""" + ret = [] + files = self.handle.torrent_info().files() + for file in files: + ret.append({ + 'path': file.path, + 'size': file.size, + 'offset': file.offset + }) + return ret + def get_status(self, keys): """Returns the status of the torrent based on the keys provided""" # Create the full dictionary @@ -150,7 +162,8 @@ class Torrent: "ratio": self.get_ratio(), "tracker": status.current_tracker, "tracker_status": self.tracker_status, - "save_path": self.save_path + "save_path": self.save_path, + "files": self.get_files() } # Create the desired status dictionary and return it