4 base = '/mirror/root/csclub'
5 htbase = 'http://csclub.uwaterloo.ca/media/files'
6 announce = 'http://bittorrent.csclub.uwaterloo.ca/announce'
7 scpto = 'bittorrent.csclub:/var/lib/bnbt/torrents/'
8 comment = 'Produced by the University of Waterloo Computer Science Club (http://csclub.uwaterloo.ca/)'
9 minsize = 10*1024*1024 # 10 MiB
11 btmake = '/usr/bin/btmakemetafile.bittornado'
14 mediafiles = [ file for file in os.listdir(base) if
15 not file.endswith('.torrent') and
16 not os.path.basename(file).startswith('.') and
17 not os.path.isdir(base + '/' + file) and
18 os.path.getsize(base + '/' + file) > minsize
21 for file in mediafiles:
22 path = base + '/' + file
23 torrentpath = path + '.torrent'
24 htpath = htbase + '/' + file
25 if not os.path.exists(torrentpath):
26 print "Making torrent for %s..." % torrentpath
27 os.spawnl(os.P_WAIT, btmake, btmake, announce, path,
28 '--comment', comment, '--target', torrentpath,
29 '--httpseeds', htpath)
30 os.spawnl(os.P_WAIT, scp, scp, torrentpath, scpto)
31 print "The bittorrent tracker will begin tracking new torrents within five minutes."