diff --git a/README.md b/README.md index e86605b..8f5f392 100644 --- a/README.md +++ b/README.md @@ -48,4 +48,5 @@ todo * more options than just hard linking (soft link, copy) * support sorting season torrents * support multiple deluge instances - need a pathmap per instance -* make UI pretty \ No newline at end of file +* make UI pretty +* support post-sort webhooks e.g. to tell plex to rescan when we add something diff --git a/mediaweb/__init__.py b/mediaweb/__init__.py index 3860dfa..2584463 100644 --- a/mediaweb/__init__.py +++ b/mediaweb/__init__.py @@ -181,7 +181,7 @@ class MediaWeb(object): self.execute_move(torrent, self.rpc.data.moves[thash]) self.rpc.refresh() - # TODO summary display + # TODO summary display of results return f"autosorted: {repr(torrents)}" @@ -204,6 +204,10 @@ def get_mapped_stashdir(mapping, trackers): return urlparse(tracker["url"]).hostname.lower() if tracker else "other" +def tsortbyname(dict_items): + return sorted(dict_items, key=lambda x: x[1]["name"].lower()) + + def main(): import argparse import signal @@ -243,8 +247,7 @@ def main(): tpl_dir = os.path.join(APPROOT, "templates") tpl = Environment(loader=FileSystemLoader(tpl_dir), autoescape=select_autoescape(['html', 'xml'])) - # self.tpl.filters.update(basename=os.path.basename, - # ceil=math.ceil + tpl.filters.update(tsortbyname=tsortbyname) def validate_password(realm, user, passw): return user == passw # lol diff --git a/templates/index.html b/templates/index.html index e5d62b5..beee073 100644 --- a/templates/index.html +++ b/templates/index.html @@ -15,18 +15,18 @@ hash name - path show season - status actions - {% for torid, tor in torrents.items() %}{% if tor.is_finished %} + {% for torid, tor in torrents.items()|tsortbyname %}{% if tor.is_finished %} {{ torid[0:6] }} - {{ tor.name }} - {{ tor.save_path }} + + {{ tor.name }}
+ {{ tor.save_path }} + {% if torid in moves %} {{ moves[torid].dest.dir }} {{moves[torid].subdest}} @@ -34,7 +34,6 @@ ? ? {% endif %} - {{ "complete" if tor.is_finished else "pending" }} @@ -42,7 +41,8 @@ {% endif %}{% endfor %} - +
+

Downloading

@@ -53,7 +53,7 @@ - {% for torid, tor in torrents.items() %}{% if not tor.is_finished %} + {% for torid, tor in torrents.items()|tsortbyname %}{% if not tor.is_finished %} diff --git a/templates/page.html b/templates/page.html index bc987db..cd55510 100644 --- a/templates/page.html +++ b/templates/page.html @@ -19,6 +19,16 @@ td { border-bottom: 1px solid #666; } + h2 { + margin-top: 30px; + } + table { + width: 100%; + } + span.small { + font-size: 10px; + color: #999; + }
progress actions
{{ torid[0:6] }} {{ tor.name }}