-
Notifications
You must be signed in to change notification settings - Fork 2
/
transmission.nu
178 lines (160 loc) · 3.75 KB
/
transmission.nu
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#transmission wrapper
export def "t help" [] {
print ([
"transmission-daemon wrapper"
"METHODS:"
"- t start"
"- t stop"
"- t reload"
"- t list"
"- t basic-stats"
"- t full-stats"
"- t ui"
"- t add"
"- t add-from-file"
"- t info"
"- t remove"
"- t remove-delete"
"- t remove-done"
"- t remove-name"
"- t start-torrent"
"- t start-all-torrents"
"- t stop-torrent"
"- t stop-all-torrents"
]
| str join "\n"
)
}
#transmission start
export def "t start" [] {
sudo service transmission-daemon start
}
#transmission stop
export def "t stop" [] {
sudo service transmission-daemon stop
}
#transmission reload
export def "t reload" [] {
sudo service transmission-daemon reload
}
#transmission list
export def "t list" [] {
transmission-remote -n 'transmission:transmission' -l | from ssv | default-table
}
#transmission basic stats
export def "t basic-stats" [] {
transmission-remote -n 'transmission:transmission' -st
}
#transmission full stats
export def "t full-stats" [] {
transmission-remote -n 'transmission:transmission' -si
}
#open transmission tui
export def "t ui" [] {
let ip = (get-ips | get internal)
tremc -c $"transmission:transmission@($ip):9091"
}
#add file to transmission download queue
export def "t add" [
down #magnetic link or torrent file
] {
transmission-remote -n 'transmission:transmission' -a $down
}
#add magnetic links from file to transmission download queue
export def "t add-from-file" [
file #text file with 1 magnetic link per line
] {
open $file
| lines
| each {|link|
transmission-remote -n 'transmission:transmission' -a $link
}
}
#get info of a torrent download
export def "t info" [
id:int #id of the torrent to http get
] {
transmission-remote -t $id -n 'transmission:transmission' -i
}
#delete torrent from download queue without deleting files
export def "t remove" [
...ids #list of ids
] {
$ids
| each {|id|
transmission-remote -t $id -n 'transmission:transmission' --remove
}
}
#delete torrent from download queue deleting files
#Examples
#t-removedelete 2 3 6 9
#t list | some filter | t-removedelete
export def "t remove-delete" [
...ids #list of ids or table
] {
let t = $in
if ($ids | is-empty) {
$t
| each {|id|
transmission-remote -t $id.ID -n 'transmission:transmission' -rad
}
} else {
$ids
| each {|id|
transmission-remote -t $id -n 'transmission:transmission' -rad
}
}
}
#delete finished torrent from download queue without deleting files
export def "t remove-done" [] {
t list
| drop 1
| where ETA =~ Done
| where Done == "100%"
| get ID
| each {|id|
transmission-remote -t $id -n 'transmission:transmission' --remove
}
}
#delete torrent from download queue that match a search without deleting files
export def "t remove-name" [
search #search term
] {
t list
| drop 1
| find -i $search
| get ID
| each {|id|
transmission-remote -t $id -n 'transmission:transmission' --remove
}
}
#start a torrent from download queue
export def "t start-torrent" [
id:int #torrent id
] {
transmission-remote -t $id -n 'transmission:transmission' -s
}
#start all torrents
export def "t start-all-torrents" [] {
t list
| drop 1
| get ID
| each {|id|
transmission-remote -t $id -n 'transmission:transmission' -s
}
}
#stop a torrent from download queue
export def "t stop-torrent" [
id:int #torrent id
] {
transmission-remote -t $id -n 'transmission:transmission' -S
}
#stop all torrents
export def "t stop-all-torrents" [] {
t list
| drop 1
| get ID
| each {|id|
transmission-remote -t $id -n 'transmission:transmission' -S
}
}