Advertisement
cyla

Blizzard downloader torrent extractor

May 8th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import os, re, struct
  4.  
  5. def get_torrent(data):
  6.     start = data.find("d8:")
  7.     end = data[start:].find("PSER")
  8.     return data[start:start+end]
  9.  
  10. if __name__ == '__main__':
  11.     for fname in os.listdir('.'):
  12.         if re.search('^Downloader_.*.exe$', fname):
  13.             tname = re.sub('^Downloader_(.*).exe$', '\\1.torrent', fname)
  14.             try:
  15.                 fdata = open(fname).read()
  16.                 tdata = get_torrent(fdata)
  17.                 f = open(tname, 'wb')
  18.                 f.write(tdata)
  19.                 f.close()
  20.                 print "Extracted torrent from '%s' to '%s'" % (fname, tname)
  21.             except Exception, e:
  22.                 print "Could not extract torrent from '%s': %s" % (fname, e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement