speed display and better sort score filtering

This commit is contained in:
dave 2019-08-17 22:22:40 -07:00
parent 862584875d
commit c067278f03
5 changed files with 41 additions and 17 deletions

View File

@ -71,7 +71,7 @@ class ClientCache(object):
def timer(self):
while True:
self.refresh()
logging.info("sleeping...")
logging.info("scheduling next loop")
sleep(300) # TODO configurable task interval
def build_torrentindex(self):
@ -168,7 +168,7 @@ class MediaWeb(object):
return self.render("moveform.html", torrent=torrent, tkey=tkey)
@cherrypy.expose
def sort(self, tkey, thresh=65, dest=None):
def sort(self, tkey, score=65, dest=None):
thash, client = self.cache.client(tkey)
torrent = client.rpc.core.get_torrent_status(thash, [])
@ -176,8 +176,8 @@ class MediaWeb(object):
fname = get_fname(torrent)
# find candidate dest locations
thresh = int(thresh)
matches = shows.match_episode(fname, self.cache.data.shows, thresh=thresh)
score = int(score)
matches = shows.match_episode(fname, self.cache.data.shows, minscore=score)
if cherrypy.request.method == "POST" and dest:
# pick the candidate dest the user specified
@ -193,7 +193,7 @@ class MediaWeb(object):
# TODO summary display
return "OK"
return self.render("sortform.html", torrent=torrent, matches=matches, tkey=tkey, thresh=thresh)
return self.render("sortform.html", torrent=torrent, matches=matches, tkey=tkey, score=score)
def execute_move(self, tkey, torrent, match):
# resolve the pathmap
@ -239,6 +239,18 @@ class MediaWeb(object):
return f"autosorted: {repr(tkeys)}"
@cherrypy.expose
def modify(self, action, tkey):
thash, client = self.cache.client(tkey)
if action == "Resume":
client.rpc.core.resume_torrent([thash])
elif action == "Pause":
client.rpc.core.pause_torrent([thash])
else:
raise cherrypy.HTTPError(404)
self.cache.refresh()
raise cherrypy.HTTPRedirect("/")
def get_fname(torrent):
finfo = None

View File

@ -199,7 +199,7 @@ def sub_bucket_name(show, major, minor, extra):
return ''
def match_episode(fname, shows, thresh=65):
def match_episode(fname, shows, minscore=65):
"""
Given a filename and a show library, determine which show and season is the best place to sort it to
"""
@ -214,7 +214,7 @@ def match_episode(fname, shows, thresh=65):
# Find a show from the library best matching this episode
for show in shows:
value = fuzz.token_set_ratio(show.name.lower(), item.lower()) #TODO add algorithm swap arg for snakeoil
if value >= thresh:
if value >= minscore:
matches.append(
MatchedEpisode(fname, epinfo, show,
sub_bucket_name(show, epinfo.major, epinfo.minor, epinfo.extra),

View File

@ -5,8 +5,8 @@
{% if inflight %}update in progress...{% else %}<input name="action" type="submit" value="update">{% endif %}
</form>
{% endblock %}
{% block body %}
{% block body %}
<div class="torrents">
<h2>Completed</h2>
<form action="/autosort" method="post">
@ -50,17 +50,28 @@
<th>hash</th>
<th>name</th>
<th>path</th>
<th>status</th>
<th>progress</th>
<th>actions</th>
</tr>
{% for torid, tor in torrents.items()|tsortbyname %}{% if not tor.is_finished %}
{% for tkey, tor in torrents.items()|tsortbyname %}{% if not tor.is_finished %}
<tr>
<td>{{ torid[0:6] }}</td>
<td>{{ tkey[0:8] }}</td>
<td>{{ tor.name }}</td>
<td>{{ tor.save_path }}</td>
<td>{{ tor.progress }}%</td>
<td>{% if tor.paused %}paused
{% else %}downloading @ {{ tor.peers | sum(attribute='down_speed') }} B/s ({{ tor.eta or "?" }}s)
{% endif %}</td>
<td>{{ tor.progress|round(2) }}%</td>
<td>
<a href="/foo"><button type="button">Resume</button></a>
<form action="/modify" method="post">
<input type="hidden" name="tkey" value="{{ tkey }}" />
{% if tor.paused %}
<input name="action" type="submit" name="action" value="Resume" />
{% else %}
<input name="action" type="submit" name="action" value="Pause" />
{% endif %}
</form>
</td>
</tr>
{% endif %}{% endfor %}
@ -85,5 +96,4 @@
</details>
</div>
</div>
{% endblock %}
{% endblock %}

View File

@ -47,5 +47,6 @@
</div>
{% block body %}{% endblock %}
</div>
<a name="bottom" />
</body>
</html>
</html>

View File

@ -2,6 +2,7 @@
{% block toolbar %}
<a href="/"><button type="button">Back</button></a>
{% endblock %}
{% block body %}
<div class="sortform">
<h2>Sort {{ torrent.name }} </h2>
@ -44,8 +45,8 @@
</table>
<br />
<input type="submit" value="Sort">
<a href="/sort?tkey=0:302f87797ba08777d90b1b0e80976d715a231979&thresh={{ thresh // 2 }}" class="right">show more</a>
{% if score > 0 %}<a href="/sort?tkey={{ tkey }}&score={{ score // 2 }}#bottom" class="right">show more (S={{ score }}%)</a>{% endif %}
</fieldset>
</form>
</div>
{% endblock %}
{% endblock %}