Advertisement
Guest User

wowhead vanilla talent blob to wowprovider url converter

a guest
Jan 12th, 2013
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.15 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. # This script takes the encoded blob from a vanilla wowhead talent link
  4. # and outputs a link to wowprovider
  5.  
  6. import sys
  7.  
  8. if len(sys.argv) < 2:
  9.         sys.exit("Usage: "+sys.argv[0]+" [WowHead string]");
  10.  
  11. whstr = sys.argv[1].strip()
  12.  
  13. treecounts = (
  14.         (16, 16, 15),      # druid
  15.         (16, 14, 16),      # hunter
  16.         (16, 16, 17),      # mage
  17.         (15, 15, 15),      # paladin
  18.         (15, 16, 16),      # priest
  19.         (15, 19, 17),      # rogue
  20.         (15, 16, 15),      # shaman
  21.         (17, 17, 16),      # warlock
  22.         (18, 17, 17)       # warrior
  23. );
  24.  
  25. classname = ("druid","hunter","mage","paladin","priest","rogue","shaman","warlock","warrior")
  26. classid = (11,3,8,2,5,4,7,9,1)
  27.  
  28. encrypt_string = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789Z'
  29.  
  30. classindex = int(encrypt_string.find(whstr[0]) / 3)
  31.  
  32. # fix for rogues?
  33. if classindex == 9: classindex = 5
  34.  
  35. print classname[classindex]
  36.  
  37. outstr = ""
  38. curtree = 0
  39. curstr = ""
  40.  
  41. for c in whstr[1:]:
  42.         if c == 'Z':
  43.                 curstr += "".zfill(treecounts[classindex][curtree] - len(curstr))
  44.                 outstr += curstr
  45.                 curstr = ""
  46.                 curtree += 1
  47.         else:
  48.                 in_val = int(encrypt_string.find(c))
  49.                 curstr += str(int(in_val / 6))
  50.                 if len(curstr) >= treecounts[classindex][curtree]:
  51.                         outstr += curstr
  52.                         curstr = ""
  53.                         curtree += 1
  54.                         if curtree >= 3:
  55.                                 break;
  56.                 else:
  57.                         curstr += str(in_val % 6)
  58.  
  59.         if len(curstr) >= treecounts[classindex][curtree]:
  60.                 outstr += curstr
  61.                 curstr = ""
  62.                 curtree += 1
  63.  
  64. if curstr != "":
  65.         curstr += "".zfill(treecounts[classindex][curtree] - len(curstr))
  66.         outstr += curstr
  67.  
  68. print outstr
  69.  
  70. # mangle it for wowprovider.com
  71. for i in range(26,1,-1):
  72.         outstr = outstr.replace("".zfill(i),chr(ord('a')+i),1)
  73. print "http://www.wowprovider.com/?talent=11215875_"+str(classid[classindex])+"_8"+outstr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement