added eta
This commit is contained in:
parent
450a8d6a06
commit
2536a4825a
28
rtorrent.py
28
rtorrent.py
|
@ -37,6 +37,16 @@ class Torrent:
|
||||||
self.total_size = raw[8]
|
self.total_size = raw[8]
|
||||||
self.total_size_str = size_units(self.total_size)
|
self.total_size_str = size_units(self.total_size)
|
||||||
self.down_percent = round((self.down_total / self.total_size) * 100, 2)
|
self.down_percent = round((self.down_total / self.total_size) * 100, 2)
|
||||||
|
if self.state == "leeching":
|
||||||
|
if self.downrate:
|
||||||
|
self.eta = (self.total_size - self.down_total) / self.downrate
|
||||||
|
self.eta_str = time_units(self.eta)
|
||||||
|
else:
|
||||||
|
self.eta = float("inf")
|
||||||
|
self.eta_str = "∞"
|
||||||
|
else:
|
||||||
|
self.eta = 0
|
||||||
|
self.eta_str = ""
|
||||||
|
|
||||||
|
|
||||||
class Watch(threading.Thread):
|
class Watch(threading.Thread):
|
||||||
|
@ -76,6 +86,24 @@ def size_units(rate):
|
||||||
rate = round(rate, 1)
|
rate = round(rate, 1)
|
||||||
return str(rate) + unit
|
return str(rate) + unit
|
||||||
|
|
||||||
|
def time_units(seconds):
|
||||||
|
"""Helper to convert seconds into more useful units."""
|
||||||
|
if seconds > (24*60*60):
|
||||||
|
days = seconds // (24*60*60)
|
||||||
|
hours = (seconds % (24*60*60)) // (60*60)
|
||||||
|
eta = f"{days}d{hours}h"
|
||||||
|
elif seconds > (60*60):
|
||||||
|
hours = seconds // (60*60)
|
||||||
|
minutes = (seconds % (60*60)) // 60
|
||||||
|
eta = f"{hours}h{minutes}m"
|
||||||
|
elif seconds > 60:
|
||||||
|
minutes = seconds // 60
|
||||||
|
seconds = seconds % 60
|
||||||
|
eta = f"{minutes}m{seconds}s"
|
||||||
|
else:
|
||||||
|
eta = f"{seconds}s"
|
||||||
|
return eta
|
||||||
|
|
||||||
def get_tracker(path):
|
def get_tracker(path):
|
||||||
"""
|
"""
|
||||||
At present I don't have an efficient way to get the tracker url
|
At present I don't have an efficient way to get the tracker url
|
||||||
|
|
|
@ -14,11 +14,11 @@ tr {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#name {
|
.name {
|
||||||
padding-left: 1em;
|
padding-left: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.totalSize, .state, .downrate, .downPercent, .uprate, .tracker {
|
.totalSize, .state, .downrate, .downPercent, .eta, .uprate, .tracker {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 10%;
|
width: 10%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ function get_active_torrents() {
|
||||||
html_str += '<td class="state">' + torrents[i].state + '</td>';
|
html_str += '<td class="state">' + torrents[i].state + '</td>';
|
||||||
html_str += '<td class="downrate">' + torrents[i].downrate_str + '</td>';
|
html_str += '<td class="downrate">' + torrents[i].downrate_str + '</td>';
|
||||||
html_str += '<td class="downPercent">' + torrents[i].down_percent + '</td>';
|
html_str += '<td class="downPercent">' + torrents[i].down_percent + '</td>';
|
||||||
|
html_str += '<td class="eta">' + torrents[i].eta_str + '</td>';
|
||||||
html_str += '<td class="uprate">' + torrents[i].uprate_str + '</td>';
|
html_str += '<td class="uprate">' + torrents[i].uprate_str + '</td>';
|
||||||
html_str += '<td class="tracker">' + torrents[i].tracker + '</td>';
|
html_str += '<td class="tracker">' + torrents[i].tracker + '</td>';
|
||||||
html_str += '</tr>';
|
html_str += '</tr>';
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<th class="state">State</th>
|
<th class="state">State</th>
|
||||||
<th class="downrate">DL</th>
|
<th class="downrate">DL</th>
|
||||||
<th class="downPercent">%</th>
|
<th class="downPercent">%</th>
|
||||||
|
<th class="eta">ETA</th>
|
||||||
<th class="uprate">UL</th>
|
<th class="uprate">UL</th>
|
||||||
<th class="tracker">Tracker</th>
|
<th class="tracker">Tracker</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -30,12 +31,14 @@
|
||||||
<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="downPercent">{{ torrent.down_percent }}</td>
|
<td class="downPercent">{{ torrent.down_percent }}</td>
|
||||||
|
<td class="eta">{{ torrent.eta_str }}</td>
|
||||||
<td class="uprate">{{ torrent.uprate_str }}</td>
|
<td class="uprate">{{ torrent.uprate_str }}</td>
|
||||||
<td class="tracker">{{ torrent.tracker }}</td>
|
<td class="tracker">{{ torrent.tracker }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<br>
|
||||||
<table id="tracker_stats">
|
<table id="tracker_stats">
|
||||||
{% for tracker, count in tracker_stats.items() %}
|
{% for tracker, count in tracker_stats.items() %}
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user