forked from iambus/xunlei-lixian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lixian_help.py
300 lines (237 loc) · 9.94 KB
/
lixian_help.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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
basic_commands = [
('help', "try this help..."),
('login', "login Xunlei cloud"),
('download', "download tasks from Xunlei cloud"),
('list', "list tasks on Xunlei cloud"),
('add', "add tasks to Xunlei cloud"),
('delete', "delete tasks from Xunlei cloud"),
('pause', "pause tasks on Xunlei cloud"),
('restart', "restart tasks on Xunlei cloud"),
('rename', "rename task"),
('readd', "re-add tasks"),
('config', "save configuration so you don't have to repeat it"),
('info', "print user id, internal user id, and gdriveid"),
('logout', "logout from Xunlei cloud"),
]
def join_commands(commands):
n = max(len(x[0]) for x in commands)
n = max(n, 10)
return ''.join(' %%-%ds %%s\n' % n % (k, h) for (k, h) in commands)
basic_usage = '''python lixian_cli.py <command> [<args>]
Basic commands:
''' + join_commands(basic_commands)
extended_usage = ''
# lx
def usage():
return basic_usage + '''
Use 'python lixian_cli.py help' for details.
Use 'python lixian_cli.py help <command>' for more information on a specific command.
Check https://github.com/iambus/xunlei-lixian for detailed (and Chinese) doc.'''
# lx xxx
# lx help help
help_help = '''Get helps:
python lixian_cli.py help help
python lixian_cli.py help examples
python lixian_cli.py help readme
python lixian_cli.py help <command>'''
# lx xxx
# lx help help
help = help_help
# lx help
# lx -h
def welcome_help():
return '''Python script for Xunlei cloud.
Basic usage:
''' + basic_usage + extended_usage + '\n' + help_help
def examples():
return '''python lixian_cli.py login "Your Xunlei account" "Your password"
python lixian_cli.py login "Your password"
python lixian_cli.py login
python lixian_cli.py config username "Your Xunlei account"
python lixian_cli.py config password "Your password"
python lixian_cli.py list
python lixian_cli.py list --completed
python lixian_cli.py list --completed --name --original-url --download-url --no-status --no-id
python lixian_cli.py list --deleted
python lixian_cli.py list --expired
python lixian_cli.py list id1 id2
python lixian_cli.py list zip rar
python lixian_cli.py list 2012.04.04 2012.04.05
python lixian_cli.py download task-id
python lixian_cli.py download ed2k-url
python lixian_cli.py download --tool=wget ed2k-url
python lixian_cli.py download --tool=asyn ed2k-url
python lixian_cli.py download ed2k-url --output "file to save"
python lixian_cli.py download id1 id2 id3
python lixian_cli.py download url1 url2 url3
python lixian_cli.py download --input download-urls-file
python lixian_cli.py download --input download-urls-file --delete
python lixian_cli.py download --input download-urls-file --output-dir root-dir-to-save-files
python lixian_cli.py download bt://torrent-info-hash
python lixian_cli.py download 1.torrent
python lixian_cli.py download torrent-info-hash
python lixian_cli.py download --bt http://xxx/xxx.torrent
python lixian_cli.py download bt-task-id/file-id
python lixian_cli.py download --all
python lixian_cli.py download mkv
python lixian_cli.py download 2012.04.04
python lixian_cli.py download 0 1 2
python lixian_cli.py download 0-2
python lixian_cli.py add url
python lixian_cli.py add 1.torrent
python lixian_cli.py add torrent-info-hash
python lixian_cli.py add --bt http://xxx/xxx.torrent
python lixian_cli.py delete task-id
python lixian_cli.py delete url
python lixian_cli.py delete file-name-on-cloud-to-delete
python lixian_cli.py pause id
python lixian_cli.py restart id
python lixian_cli.py rename id name
python lixian_cli.py logout
Please check https://github.com/iambus/xunlei-lixian for detailed (and Chinese) doc.
'''
def readme():
import sys
import os.path
doc = os.path.join(sys.path[0], 'README.md')
with open(doc) as txt:
return txt.read().decode('utf-8')
login = '''python lixian_cli.py login <username> <password>
login Xunlei cloud
Examples:
python lixian_cli.py login "Your Xunlei account" "Your password"
python lixian_cli.py login "Your password"
python lixian_cli.py login
'''
download = '''python lixian_cli.py download [options] [id|url]...
download tasks from Xunlei cloud
Options:
--input=[file] -i Download URLs found in file.
--output=[file] -o Download task to file.
--output-dir=[dir] Download task to dir.
--tool=[wget|asyn|aria2|curl] Choose download tool.
Default: wget
--continue -c Continue downloading a partially downloaded file.
Default: false.
--overwrite Overwrite partially downloaded file.
Default: false.
--delete Delete task from Xunlei cloud after download is finished.
Default: false.
--torrent --bt Treat URLs as torrent files
Default: false.
--all Download all tasks. This option will be ignored if specific download URLs or task ids can be found.
Default: false.
--hash When this option is false (--no-hash), never do full hash, but a minimal hash will be performed (supposed to be very fast).
Default: true.
--mini-hash If the target file already exists, and the file size is complete, do a minimal hash (instead of full hash, which would be much more expensive). This is useful when you are resuming a batch download, in this case the previously downloaded and verified files won't be re-verified.
Default: false.
Examples:
python lixian_cli.py download task-id
python lixian_cli.py download ed2k-url
python lixian_cli.py download --tool=wget ed2k-url
python lixian_cli.py download --tool=asyn ed2k-url
python lixian_cli.py download ed2k-url --output "file to save"
python lixian_cli.py download id1 id2 id3
python lixian_cli.py download url1 url2 url3
python lixian_cli.py download --input download-urls-file
python lixian_cli.py download --input download-urls-file --delete
python lixian_cli.py download --input download-urls-file --output-dir root-dir-to-save-files
python lixian_cli.py download bt://torrent-info-hash
python lixian_cli.py download 1.torrent
python lixian_cli.py download torrent-info-hash
python lixian_cli.py download --bt http://xxx/xxx.torrent
python lixian_cli.py download bt-task-id/file-id
python lixian_cli.py download --all
python lixian_cli.py download mkv
python lixian_cli.py download 2012.04.04
python lixian_cli.py download 0 1 2
python lixian_cli.py download 0-2
'''
list = '''python lixian_cli.py list
list tasks on Xunlei cloud
Options:
--completed Print only completed tasks. Default: no
--deleted Print only deleted tasks. Default: no
--expired Print only expired tasks. Default: no
--[no]-n Print task sequence number. Default: no
--[no]-id Print task id. Default: yes
--[no]-name Print task name. Default: yes
--[no]-status Print task status. Default: yes
--[no]-size Print task size. Default: no
--[no]-progress Print task progress (in percent). Default: no
--[no]-speed Print task speed. Default: no
--[no]-date Print the date task added. Default: no
--[no]-original-url Print the original URL. Default: no
--[no]-download-url Print the download URL used to download from Xunlei cloud. Default: no
--[no]-format-size Print file size in human readable format. Default: no
--[no]-colors Colorful output. Default: yes
Examples:
python lixian_cli.py list
python lixian_cli.py list id
python lixian_cli.py list bt-task-id/
python lixian_cli.py list --completed
python lixian_cli.py list --completed --name --original-url --download-url --no-status --no-id
python lixian_cli.py list --deleted
python lixian_cli.py list --expired
python lixian_cli.py list id1 id2
python lixian_cli.py list zip rar
python lixian_cli.py list 2012.04.04 2012.04.05
'''
add = '''python lixian_cli.py add [options] url...
add tasks to Xunlei cloud
Options:
--input=[file] Download URLs found in file.
--torrent --bt Treat all arguments as torrent files (e.g. local torrent file, torrent http url, torrent info hash)
Default: false.
Examples:
python lixian_cli.py add url
python lixian_cli.py add 1.torrent
python lixian_cli.py add torrent-info-hash
python lixian_cli.py add --bt http://xxx/xxx.torrent
'''
delete = '''python lixian_cli.py delete [options] [id|url|filename|keyword|date]...
delete tasks from Xunlei cloud
Options:
-i prompt before delete
--all delete all tasks if there are multiple matches
Examples:
python lixian_cli.py delete task-id
python lixian_cli.py delete url
python lixian_cli.py delete file-name-on-cloud-to-delete
'''
pause = '''python lixian_cli.py pause [options] [id|url|filename|keyword|date]...
pause tasks on Xunlei cloud
Options:
-i prompt before pausing tasks
--all pause all tasks if there are multiple matches
'''
restart = '''python lixian_cli.py restart [id|url|filename|keyword|date]...
restart tasks on Xunlei cloud
Options:
-i prompt before restart
--all restart all tasks if there are multiple matches
'''
rename = '''python lixian_cli.py rename task-id task-name
rename task
'''
readd = '''python lixian_cli.py readd [--deleted|--expired] task-id...
re-add deleted/expired tasks
Options:
--deleted re-add deleted tasks
--expired re-add expired tasks
'''
config = '''python lixian_cli.py config key [value]
save configuration so you don't have to repeat it
Examples:
python lixian_cli.py config username "your xunlei id"
python lixian_cli.py config password "your xunlei password"
python lixian_cli.py config continue
'''
info = '''python lixian_cli.py info
print user id, internal user id, and gdriveid
Options:
--id -i print user id only
'''
logout = '''python lixian_cli.py logout
logout from Xunlei cloud
'''