From 806801bd6179073e4a2137ab10eb088066dc13c0 Mon Sep 17 00:00:00 2001 From: David Bartley Date: Wed, 16 Jan 2008 14:23:50 -0500 Subject: [PATCH] Add make-torrents script --- make-torrents | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 make-torrents diff --git a/make-torrents b/make-torrents new file mode 100755 index 0000000..34a23bd --- /dev/null +++ b/make-torrents @@ -0,0 +1,31 @@ +#!/usr/bin/python +import os.path + +base = '/users/www/files' +htbase = 'http://csclub.uwaterloo.ca/media/files' +announce = 'http://bittorrent.csclub.uwaterloo.ca/announce' +scpto = 'bittorrent.csclub:/var/lib/bnbt/torrents/' +comment = 'Produced by the University of Waterloo Computer Science Club (http://csclub.uwaterloo.ca/)' +minsize = 10*1024*1024 # 10 MiB + +btmake = '/usr/bin/btmakemetafile.bittornado' +scp = '/usr/bin/scp' + +mediafiles = [ file for file in os.listdir(base) if + not file.endswith('.torrent') and + not os.path.basename(file).startswith('.') and + not os.path.isdir(base + '/' + file) and + os.path.getsize(base + '/' + file) > minsize +] + +for file in mediafiles: + path = base + '/' + file + torrentpath = path + '.torrent' + htpath = htbase + '/' + file + if not os.path.exists(torrentpath): + print "Making torrent for %s..." % torrentpath + os.spawnl(os.P_WAIT, btmake, btmake, announce, path, + '--comment', comment, '--target', torrentpath, + '--httpseeds', htpath) + os.spawnl(os.P_WAIT, scp, scp, torrentpath, scpto) +print "The bittorrent tracker will begin tracking new torrents within five minutes."