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 %}