This commit is contained in:
dave 2019-08-17 15:09:32 -07:00
parent e6ea486b56
commit 4a28090c76
4 changed files with 26 additions and 12 deletions

View File

@ -48,4 +48,5 @@ todo
* more options than just hard linking (soft link, copy) * more options than just hard linking (soft link, copy)
* support sorting season torrents * support sorting season torrents
* support multiple deluge instances - need a pathmap per instance * support multiple deluge instances - need a pathmap per instance
* make UI pretty * make UI pretty
* support post-sort webhooks e.g. to tell plex to rescan when we add something

View File

@ -181,7 +181,7 @@ class MediaWeb(object):
self.execute_move(torrent, self.rpc.data.moves[thash]) self.execute_move(torrent, self.rpc.data.moves[thash])
self.rpc.refresh() self.rpc.refresh()
# TODO summary display # TODO summary display of results
return f"autosorted: {repr(torrents)}" 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" 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(): def main():
import argparse import argparse
import signal import signal
@ -243,8 +247,7 @@ def main():
tpl_dir = os.path.join(APPROOT, "templates") tpl_dir = os.path.join(APPROOT, "templates")
tpl = Environment(loader=FileSystemLoader(tpl_dir), tpl = Environment(loader=FileSystemLoader(tpl_dir),
autoescape=select_autoescape(['html', 'xml'])) autoescape=select_autoescape(['html', 'xml']))
# self.tpl.filters.update(basename=os.path.basename, tpl.filters.update(tsortbyname=tsortbyname)
# ceil=math.ceil
def validate_password(realm, user, passw): def validate_password(realm, user, passw):
return user == passw # lol return user == passw # lol

View File

@ -15,18 +15,18 @@
<th></th> <th></th>
<th>hash</th> <th>hash</th>
<th>name</th> <th>name</th>
<th>path</th>
<th>show</th> <th>show</th>
<th>season</th> <th>season</th>
<th>status</th>
<th>actions</th> <th>actions</th>
</tr> </tr>
{% for torid, tor in torrents.items() %}{% if tor.is_finished %} {% for torid, tor in torrents.items()|tsortbyname %}{% if tor.is_finished %}
<tr> <tr>
<td><input type="checkbox" name="torrents" value="{{ torid }}"{% if torid in moves %} checked="checked"{% endif %}></td> <td><input type="checkbox" name="torrents" value="{{ torid }}"{% if torid in moves %} checked="checked"{% endif %}></td>
<td>{{ torid[0:6] }}</td> <td>{{ torid[0:6] }}</td>
<td>{{ tor.name }}</td> <td>
<td>{{ tor.save_path }}</td> {{ tor.name }}<br />
<span class="small">{{ tor.save_path }}</span>
</td>
{% if torid in moves %} {% if torid in moves %}
<td>{{ moves[torid].dest.dir }}</td> <td>{{ moves[torid].dest.dir }}</td>
<td>{{moves[torid].subdest}}</td> <td>{{moves[torid].subdest}}</td>
@ -34,7 +34,6 @@
<td>?</td> <td>?</td>
<td>?</td> <td>?</td>
{% endif %} {% endif %}
<td>{{ "complete" if tor.is_finished else "pending" }}</td>
<td> <td>
<a href="/move?thash={{ torid }}"><button type="button">Move</button></a> <a href="/move?thash={{ torid }}"><button type="button">Move</button></a>
<a href="/sort?thash={{ torid }}"><button type="button">Sort</button></a> <a href="/sort?thash={{ torid }}"><button type="button">Sort</button></a>
@ -42,7 +41,8 @@
</tr> </tr>
{% endif %}{% endfor %} {% endif %}{% endfor %}
</table> </table>
<input type="submit" value="Sort selected"> <br/>
<input type="submit" value="Autosort selected">
</form> </form>
<h2>Downloading</h2> <h2>Downloading</h2>
<table> <table>
@ -53,7 +53,7 @@
<th>progress</th> <th>progress</th>
<th>actions</th> <th>actions</th>
</tr> </tr>
{% for torid, tor in torrents.items() %}{% if not tor.is_finished %} {% for torid, tor in torrents.items()|tsortbyname %}{% if not tor.is_finished %}
<tr> <tr>
<td>{{ torid[0:6] }}</td> <td>{{ torid[0:6] }}</td>
<td>{{ tor.name }}</td> <td>{{ tor.name }}</td>

View File

@ -19,6 +19,16 @@
td { td {
border-bottom: 1px solid #666; border-bottom: 1px solid #666;
} }
h2 {
margin-top: 30px;
}
table {
width: 100%;
}
span.small {
font-size: 10px;
color: #999;
}
</style> </style>
</head> </head>
<body> <body>