Steven Smith revised this gist . Go to revision
1 file changed, 25 insertions
deluge-downloading.py(file created)
| @@ -0,0 +1,25 @@ | |||
| 1 | + | #!/usr/bin/env python3 | |
| 2 | + | def sec(s): | |
| 3 | + | m,s = divmod(int(s), 60) | |
| 4 | + | h,m = divmod(m,60) | |
| 5 | + | return "%d:%02d:%02d" % (h,m,s) | |
| 6 | + | ||
| 7 | + | def convert(data): | |
| 8 | + | if isinstance(data, bytes): return data.decode('ascii') | |
| 9 | + | if isinstance(data, dict): return dict(map(convert, data.items())) | |
| 10 | + | if isinstance(data, tuple): return map(convert, data) | |
| 11 | + | return data | |
| 12 | + | ||
| 13 | + | from hurry.filesize import size | |
| 14 | + | from deluge_client import DelugeRPCClient | |
| 15 | + | client = DelugeRPCClient("127.0.0.1", 58846, "me", "you") | |
| 16 | + | client.connect() | |
| 17 | + | torrents = client.call("core.get_torrents_status", {"state": "Downloading"}, []) | |
| 18 | + | if not torrents: | |
| 19 | + | print("Nothing going at the moment") | |
| 20 | + | else: | |
| 21 | + | torrents = convert(torrents) | |
| 22 | + | for torrent, data in torrents.items(): | |
| 23 | + | data["until"] = sec(data["eta"]) | |
| 24 | + | data["dlrate"] = size(data["download_payload_rate"]) | |
| 25 | + | print("{progress:.0f}% {until} {dlrate}/s: {name}".format(**data)) | |
Newer
Older