-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransmission.py
executable file
·97 lines (91 loc) · 2.13 KB
/
transmission.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/python
from markdownTable import markdownTable
from transmission_rpc import Client
movies = Client(
username="ervin",
password="4663",
host="ervinpopescu.ddns.net",
port=9091,
)
shows = Client(
username="ervin",
password="4663",
host="ervinpopescu.ddns.net",
port=9092,
)
l = list({})
movies_session = movies.get_session()
movies_torrents = movies.get_torrents()
movies_torrents.sort(key=lambda f: f.name)
shows_session = shows.get_session()
shows_torrents = shows.get_torrents()
shows_torrents.sort(key=lambda f: f.name)
for movie in movies_torrents:
eta = movie.format_eta()
if eta == "not available":
eta = "n/a"
if eta == "unknown":
eta = "unk"
status = movie.status
if status == "downloading":
status = "down"
if status == "seeding":
status = "up"
l.append(
{
"NAME": f" {movie.name[:26]} ",
"STAT": status,
"PROG": f" {str(movie.progress)} ",
"DOWN": f" {str(movie.rateDownload / 1000000.0)} ",
"ETA": f" {eta} ",
}
)
table = (
markdownTable(l)
.setParams(
row_sep="markdown",
quote=False,
padding_weight="center",
# multiline=True,
)
.getMarkdown()
)
print(table)
print("")
print("")
l = []
for show in shows_torrents:
eta = show.format_eta()
if eta == "not available":
eta = "n/a"
if eta == "unknown":
eta = "unk"
status = show.status
if status == "downloading":
status = "down"
if status == "seeding":
status = "up"
l.append(
{
"NAME": f" {show.name[:26]} ",
"STAT": status,
"PROG": f" {str(show.progress)} ",
"DOWN": f" {str(show.rateDownload / 1000000.0)} ",
"ETA": f" {eta} ",
}
)
table = (
markdownTable(l)
.setParams(
row_sep="markdown",
quote=False,
padding_weight="center",
# multiline=True,
)
.getMarkdown()
)
print(table)
# outfile = open("/home/ervin/torrent_status.md", "w")
# outfile.write(table)
# outfile.write("\n")
# outfile.close()