#! /usr/bin/env python import sys import bencode torrentIn = sys.argv[1] tracker = sys.argv[2] torrentOut = sys.argv[3] with open(torrentIn, 'rb') as f: bencoded = f.read() data = bencode.bdecode(bencoded) data['announce'] = tracker bencoded = bencode.bencode(data) with open(torrentOut, 'wb') as f: f.write(bencoded)