diff --git a/aberrant.py b/aberrant.py index 7009fa2..5565d45 100644 --- a/aberrant.py +++ b/aberrant.py @@ -20,6 +20,7 @@ signal.signal(signal.SIGINT, rtorrent.stop_watch) def index(): """The index page.""" torrents = rtorrent.get_active() + tracker_stats = rtorrent.get_stats() return render_template("index.html", **locals()) @app.route("/static/") diff --git a/rtorrent.py b/rtorrent.py index 799cc80..e90e331 100644 --- a/rtorrent.py +++ b/rtorrent.py @@ -119,3 +119,11 @@ def get_active(): """Returns all actively seeding or leeching torrents.""" active = [t for t in all_torrents() if t.downrate or t.uprate] return active + +def get_stats(): + """Returns various statistical information about the torrents.""" + trackers = [t.tracker for t in all_torrents()] + tracker_stats = {tr: trackers.count(tr) for tr in set(trackers)} + tracker_stats = dict(sorted(tracker_stats.items())) + tracker_stats['total'] = len(trackers) + return tracker_stats diff --git a/templates/index.html b/templates/index.html index c919a12..4153b12 100644 --- a/templates/index.html +++ b/templates/index.html @@ -32,5 +32,13 @@ {% endfor %} + + {% for tracker, count in tracker_stats.items() %} + + + + + {% endfor %} +
{{ tracker }}{{ count }}