diff --git a/mediaweb/__init__.py b/mediaweb/__init__.py index f67e072..3187262 100644 --- a/mediaweb/__init__.py +++ b/mediaweb/__init__.py @@ -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 diff --git a/mediaweb/shows.py b/mediaweb/shows.py index 73a17e6..0fbac27 100644 --- a/mediaweb/shows.py +++ b/mediaweb/shows.py @@ -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), diff --git a/templates/index.html b/templates/index.html index f929c9d..bb3dca9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,8 +5,8 @@ {% if inflight %}update in progress...{% else %}{% endif %} {% endblock %} -{% block body %} +{% block body %}

Completed

@@ -50,17 +50,28 @@ hash name path + status progress actions - {% for torid, tor in torrents.items()|tsortbyname %}{% if not tor.is_finished %} + {% for tkey, tor in torrents.items()|tsortbyname %}{% if not tor.is_finished %} - {{ torid[0:6] }} + {{ tkey[0:8] }} {{ tor.name }} {{ tor.save_path }} - {{ tor.progress }}% + {% if tor.paused %}paused + {% else %}downloading @ {{ tor.peers | sum(attribute='down_speed') }} B/s ({{ tor.eta or "?" }}s) + {% endif %} + {{ tor.progress|round(2) }}% - + + + {% if tor.paused %} + + {% else %} + + {% endif %} +
{% endif %}{% endfor %} @@ -85,5 +96,4 @@
- -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/templates/page.html b/templates/page.html index 43fc0a6..d737072 100644 --- a/templates/page.html +++ b/templates/page.html @@ -47,5 +47,6 @@ {% block body %}{% endblock %} + - \ No newline at end of file + diff --git a/templates/sortform.html b/templates/sortform.html index 1accc23..50e4120 100644 --- a/templates/sortform.html +++ b/templates/sortform.html @@ -2,6 +2,7 @@ {% block toolbar %} {% endblock %} + {% block body %}

Sort {{ torrent.name }}

@@ -44,8 +45,8 @@
- show more + {% if score > 0 %}show more (S={{ score }}%){% endif %}
-{% endblock %} \ No newline at end of file +{% endblock %}