centered columns, added tracker column

This commit is contained in:
iou1name 2019-02-15 07:33:55 -05:00
parent 1d81c7fb63
commit 2580294cbf
4 changed files with 25 additions and 19 deletions

View File

@ -11,6 +11,3 @@ Python packages: `flask gunicorn`
## Usage ## Usage
`gunicorn -b localhost:5250 -e SCRIPT_NAME=/aberrant aberrant:app` `gunicorn -b localhost:5250 -e SCRIPT_NAME=/aberrant aberrant:app`
## What's with the name?
Picked a random word from the dictionary desu.

View File

@ -31,6 +31,8 @@ class Torrent:
self.uprate = raw[5] self.uprate = raw[5]
self.uprate_str = speedrate(self.uprate) self.uprate_str = speedrate(self.uprate)
self.tracker = get_tracker(raw[6])
class Watch(threading.Thread): class Watch(threading.Thread):
"""A thread class that continously queries the rTorrent instances.""" """A thread class that continously queries the rTorrent instances."""
@ -66,6 +68,14 @@ def speedrate(rate):
rate = round(rate, 1) rate = round(rate, 1)
return str(rate) + unit return str(rate) + unit
def get_tracker(path):
"""
At present I don't have an efficient way to get the tracker url
with the d.multicall2() function, so we parse it from the
directory path.
"""
return path.split('/')[4]
def all_torrents(): def all_torrents():
"""Helper that returns a list of all torrents.""" """Helper that returns a list of all torrents."""
res = [] res = []
@ -89,6 +99,7 @@ def get_all(n):
'd.complete=', 'd.complete=',
'd.down.rate=', 'd.down.rate=',
'd.up.rate=', 'd.up.rate=',
'd.directory=',
) )
return [Torrent(raw) for raw in res] return [Torrent(raw) for raw in res]

View File

@ -1,3 +1,9 @@
body {
background-color: #FAFAFA;
color: #111111;
font-family: Tahoma, Helvetica, sans-serif;
}
#torrents { #torrents {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
@ -8,21 +14,11 @@ tr {
border: 1px solid #ccc; border: 1px solid #ccc;
} }
.name { #name {
padding-left: 1em; padding-left: 1em;
} }
.state { .state, .downrate, .uprate, .tracker {
text-align: center;
width: 10%;
}
.downrate {
text-align: center;
width: 10%;
}
.uprate {
text-align: center; text-align: center;
width: 10%; width: 10%;
} }

View File

@ -8,10 +8,11 @@
<table id="torrents"> <table id="torrents">
<thead> <thead>
<tr> <tr>
<th>Name</th> <th class="name">Name</th>
<th>State</th> <th class="state">State</th>
<th>DL</th> <th class="downrate">DL</th>
<th>UL</th> <th class="uprate">UL</th>
<th class="tracker">Tracker</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -21,6 +22,7 @@
<td class="state">{{ torrent.state }}</td> <td class="state">{{ torrent.state }}</td>
<td class="downrate">{{ torrent.downrate_str }}</td> <td class="downrate">{{ torrent.downrate_str }}</td>
<td class="uprate">{{ torrent.uprate_str }}</td> <td class="uprate">{{ torrent.uprate_str }}</td>
<td class="tracker">{{ torrent.tracker }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>