forked from effigies/BitTornado
-
Notifications
You must be signed in to change notification settings - Fork 1
/
btmakemetafile.py
executable file
·37 lines (27 loc) · 1.01 KB
/
btmakemetafile.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
#!/usr/bin/env python
# Written by Bram Cohen
# multitracker extensions by John Hoffman
# see LICENSE.txt for license information
import sys
import os
from BitTornado.BT1.makemetafile import make_meta_file, defaults, \
announcelist_details
from BitTornado.parseargs import parseargs, formatDefinitions
def prog(amount):
print '%.1f%% complete\r' % (amount * 100),
def main(argv):
program, ext = os.path.splitext(os.path.basename(argv[0]))
usage = "Usage: %s <trackerurl> <file> [file...] [params...]" % program
if len(argv) < 3:
print "{}\n\n{}{}".format(usage, formatDefinitions(defaults, 80),
announcelist_details)
return 2
try:
config, args = parseargs(argv[1:], defaults, 2, None)
for file in args[1:]:
make_meta_file(file, args[0], config.copy(), progress=prog)
except ValueError as e:
print 'error: ' + str(e)
print 'run with no args for parameter explanations'
return 0
sys.exit(main(sys.argv))