tracker stats added

This commit is contained in:
iou1name 2019-02-18 10:32:19 -05:00
parent e013d79e6e
commit b80d3b989a
3 changed files with 17 additions and 0 deletions

View File

@ -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/<path:path>")

View File

@ -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

View File

@ -32,5 +32,13 @@
{% endfor %}
</tbody>
</table>
<table id="tracker_stats">
{% for tracker, count in tracker_stats.items() %}
<tr>
<td>{{ tracker }}</td>
<td>{{ count }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>