# in the current directory ("./" means this directory) # (e.g. the first chunk's filename would be "./chunk1" # and the second "./chunk2" etc.) ChunkNamer("./"), # Write each chunk to disc under this name WholeFileWriter(), # Make a .torrent (BitTorrent metadata) file from each chunk file TorrentMaker(trackerannounceurl), ), # send the .torrent file to the website that will host them and to # a TorrentPatron which will then upload the associated chunks # to peers (users that want to download the stream) split=fanout(["toHTTP-POSTer", "toTorrentPatron"]), # fileupload uploads each message it receives to a script on a webserver. fileupload=pipeline( # convert messages received to HTTP POST requests # for the URL trackerpostuploader # (with the contents of the message as the payload/request body) HTTPMakePostRequest(trackerpostuploader), # SimpleHTTPClient then makes these requests # (connecting to the server given in the URL and sending the # POST request in an HTTP request format) # the result of which is (assuming a suitable upload script on the # webserver) .torrent files sent to this pipeline as messages # are uploaded to the webserver SimpleHTTPClient()),
pipeline( ConsoleReader(), OnDemandIntrospector(), ConsoleEchoer(), ).activate() Graphline( streamin=pipeline( IcecastClient("http://127.0.0.1:1234/"), # a stream's address IcecastDemux(), IcecastStreamRemoveMetadata(), Chunkifier(500000), ChunkDistributor("./"), WholeFileWriter(), TorrentMaker("http://192.168.1.5:6969/announce"), ), split=fanout(["toMetaUploader", "toSharer"]), fileupload=pipeline(ChunkDistributor("./torrents/", ".torrent"), WholeFileWriter(), PureTransformer(lambda x: x + "\n"), SimpleFileWriter("filelist.txt")), #WholeFileWriter() #HTTPMakePostRequest("http://192.168.1.15/torrentupload.php"), #SimpleHTTPClient() # uploader still to write bt=TorrentPatron(), linkages={ ("streamin", "outbox"): ("split", "inbox"), ("split", "toMetaUploader"): ("fileupload", "inbox"), ("split", "toSharer"): ("bt", "inbox"),
# in the current directory ("./" means this directory) # (e.g. the first chunk's filename would be "./chunk1" # and the second "./chunk2" etc.) ChunkNamer("./"), # Write each chunk to disc under this name WholeFileWriter(), # Make a .torrent (BitTorrent metadata) file from each chunk file TorrentMaker(trackerannounceurl), ), # send the .torrent file to the website that will host them and to # a TorrentPatron which will then upload the associated chunks # to peers (users that want to download the stream) split = fanout(["toHTTP-POSTer", "toTorrentPatron"]), # fileupload uploads each message it receives to a script on a webserver. fileupload = pipeline( # convert messages received to HTTP POST requests # for the URL trackerpostuploader # (with the contents of the message as the payload/request body) HTTPMakePostRequest(trackerpostuploader), # SimpleHTTPClient then makes these requests # (connecting to the server given in the URL and sending the # POST request in an HTTP request format) # the result of which is (assuming a suitable upload script on the # webserver) .torrent files sent to this pipeline as messages # are uploaded to the webserver SimpleHTTPClient()
return self.pause() if __name__ == '__main__': # The 'announce' URL of the BitTorrent tracker to use # e.g. "http://192.168.1.5:6969/announce" trackerannounceurl = raw_input("Tracker Announce URL: ") Graphline( filenamereader = ConsoleReader(">>> ", ""), # send the filename entered by the user to both the .torrent # maker and to the file writer to use as part of the filename # (so that it knows what to save the metadata as) filenamesplitter = fanout(["toNamer", "toTorrentMaker"]), # makes the .torrent file (BitTorrent metadata) torrentmaker = TorrentMaker(trackerannounceurl), # saves the .torrent file filewriter = WholeFileWriter(), # does the seeding (uploading) of the file torrentpatron = TorrentPatron(), # puts a name to the .torrent file torrentnamer = TwoSourceListifier(), # send the .torrent file data to both the seeder and the saver torrentmetasplitter = fanout(["toTorrentPatron", "toNamer"]),
def suffixMatchOnly(x): if x[:len(urlprefix)] == urlprefix: return x class ListSplit(component): def main(self): while 1: yield 1 while self.dataReady("inbox"): msg = self.recv("inbox") for m in msg: self.send(m, "outbox") self.pause() Graphline(usersuppliedurls=ConsoleReader(eol=""), splitter=fanout(["toHTTPClient", "toCorrectRelativeLinks"]), splittertwo=fanout(["toSplitterOne", "toEchoer"]), newlinesuffixadder=PureTransformer(lambda x: x + "\n"), httpclient=SimpleHTTPClient(), htmlprocessor=HTMLProcess(), linkextractor=ExtractLinks(), linkcorrector=CorrectRelativeLinks(), listsplitter=ListSplit(), prefixmatcher=PureTransformer(suffixMatchOnly), newurlechoer=ConsoleEchoer(), unseenonly=UnseenOnly(), linkages={ ("usersuppliedurls", "outbox"): ("unseenonly", "inbox"), ("newurlechoer", "outbox"): ("splitter", "inbox"), ("splitter", "toHTTPClient"): ("httpclient", "inbox"), ("splitter", "toCorrectRelativeLinks"):
ConsoleReader(), OnDemandIntrospector(), ConsoleEchoer(), ).activate() Graphline( streamin = pipeline( IcecastClient("http://127.0.0.1:1234/"), # a stream's address IcecastDemux(), IcecastStreamRemoveMetadata(), Chunkifier(500000), ChunkDistributor("./"), WholeFileWriter(), TorrentMaker("http://192.168.1.5:6969/announce"), ), split = fanout(["toMetaUploader", "toSharer"]), fileupload = pipeline( ChunkDistributor("./torrents/", ".torrent"), WholeFileWriter(), PureTransformer(lambda x : x + "\n"), SimpleFileWriter("filelist.txt") ), #WholeFileWriter() #HTTPMakePostRequest("http://192.168.1.15/torrentupload.php"), #SimpleHTTPClient() # uploader still to write bt = TorrentPatron(), linkages = {
if x[:len(urlprefix)] == urlprefix: return x class ListSplit(component): def main(self): while 1: yield 1 while self.dataReady("inbox"): msg = self.recv("inbox") for m in msg: self.send(m, "outbox") self.pause() Graphline( usersuppliedurls = ConsoleReader(eol=""), splitter = fanout(["toHTTPClient", "toCorrectRelativeLinks"]), splittertwo = fanout(["toSplitterOne", "toEchoer"]), newlinesuffixadder = PureTransformer(lambda x : x + "\n"), httpclient = SimpleHTTPClient(), htmlprocessor = HTMLProcess(), linkextractor = ExtractLinks(), linkcorrector = CorrectRelativeLinks(), listsplitter = ListSplit(), prefixmatcher = PureTransformer(suffixMatchOnly), newurlechoer = ConsoleEchoer(), unseenonly = UnseenOnly(), linkages = { ("usersuppliedurls", "outbox") : ("unseenonly", "inbox"), ("newurlechoer", "outbox") : ("splitter", "inbox"),
self.pause() if __name__ == '__main__': # The 'announce' URL of the BitTorrent tracker to use # e.g. "http://192.168.1.5:6969/announce" trackerannounceurl = raw_input("Tracker Announce URL: ") Graphline( filenamereader=ConsoleReader(">>> ", ""), # send the filename entered by the user to both the .torrent # maker and to the file writer to use as part of the filename # (so that it knows what to save the metadata as) filenamesplitter=fanout(["toNamer", "toTorrentMaker"]), # makes the .torrent file (BitTorrent metadata) torrentmaker=TorrentMaker(trackerannounceurl), # saves the .torrent file filewriter=WholeFileWriter(), # does the seeding (uploading) of the file torrentpatron=TorrentPatron(), # puts a name to the .torrent file torrentnamer=TwoSourceListifier(), # send the .torrent file data to both the seeder and the saver torrentmetasplitter=fanout(["toTorrentPatron", "toNamer"]),