host, port = address.split(':', 1) except ValueError, e: host = address port = 80 port = int(port) return host, port, '/'+path def setLocalport(val): print("updated Localport to"+str(val)) global localport localport=val def getLocalport(): return localport if __name__ == '__main__': host, port, path = parse_url('http://193.204.59.68:81/test/0ccf2c94c951880cd2456f4fb2db2b9d/4_ts.m3u8') def on_connection(c): print c c.makeRequest(path) def on_data(c, data): print c, len(data) reactor.callLater(1, c.makeRequest, '/test/0ccf2c94c951880cd2456f4fb2db2b9d/4_00000.ts') c = ClientFactory(host, port) c.connect('connection-made', on_connection) c.connect('data-received', on_data) reactor.run()
debug(DEBUG+1, '%s stop', self) self.host, self.port = None, 0 if self.connector: self.connector.disconnect() self.connector = None self.client = None gc.collect() def parse_url(url): _,_, address, path = url.split('/', 3) try: host, port = address.split(':', 1) except ValueError, e: host = address port = 80 port = int(port) return host, port, '/'+path if __name__ == '__main__': host, port, path = parse_url('http://193.204.59.68:81/test/0ccf2c94c951880cd2456f4fb2db2b9d/4_ts.m3u8') def on_connection(c): print c c.makeRequest(path) def on_data(c, data): print c, len(data) reactor.callLater(1, c.makeRequest, '/test/0ccf2c94c951880cd2456f4fb2db2b9d/4_00000.ts') c = ClientFactory(host, port) c.connect('connection-made', on_connection) c.connect('data-received', on_data) reactor.run()