sys.exit(-1) characters[char['name']] = char # Import the list of raids (if available) json_raids = load_json_file(os.path.join(script_path, 'data/raids.json'), None) if json_raids is not None: json_data['raids'] = map(lambda x: { 'name': x['name'], 'wings': x['wings'] }, json_raids) # Setup the connection Connection.setup(locale=settings.LOCALE) # Complete the data for (region, server, name, specs) in settings.CHARACTER_NAMES: print ("Retrieving '%s (%s - %s)'..." % (name, server, region)).encode('utf-8') try: character = Character(region, server, name, fields=[Character.ITEMS, Character.TALENTS]) except: # 2nd try... print ("Retrieving '%s (%s - %s)'..." % (name, server, region)).encode('utf-8') try: character = Character(region, server, name, fields=[Character.ITEMS, Character.TALENTS]) except:
print 'Duplicate character: %s' % char['name'].encode('utf-8') sys.exit(-1) characters[char['name']] = char # Import the list of raids (if available) json_raids = load_json_file(os.path.join(script_path, 'data/raids.json'), None) if json_raids is not None: json_data['raids'] = map( lambda x: { 'name': x['name'], 'wings': x['wings'] }, json_raids) # Setup the connection Connection.setup(locale=settings.LOCALE) # Complete the data for (region, server, name, specs) in settings.CHARACTER_NAMES: print("Retrieving '%s (%s - %s)'..." % (name, server, region)).encode('utf-8') try: character = Character(region, server, name, fields=[Character.ITEMS, Character.TALENTS]) except: # 2nd try... print("Retrieving '%s (%s - %s)'..." % (name, server, region)).encode('utf-8') try:
import battlenet from battlenet import Connection connection = Connection() print "wow_servers = [", for realm in connection.get_all_realms(battlenet.UNITED_STATES): print '%r,' % realm, print "]",
# -*- coding: utf-8 -*- import battlenet from battlenet import Connection if __name__ == "__main__": connection = Connection(public_key='7a09ed83ea0740e0bf284e903c8a029f', private_key='6HNxhgBdt92TrO7bUFj0bByKWywOzAtw', locale='cn') realms = connection.get_all_realms(battlenet.CHINA) print(realms) # import hmac # secret_key1 = b'This is my secret key' # message1 = b'Hello world' # hex_res1 = hmac.new(secret_key1, message1, digestmod="MD5").hexdigest() # print(hex_res1) # b8908a20bd70f465330b434e18441d3b
def get_char(name, server, target_region=battlenet.UNITED_STATES): Connection.setup(api_key=API_KEY, locale='us') try: character = Character(target_region, server, name, fields=[ Character.GUILD, Character.ITEMS, Character.PROGRESSION, Character.ACHIEVEMENTS ]) except Exception as e: raise e return_string = "" return_string += "**%s** - **%s(%s)** - **%s %s**\n" % ( character.name, character.get_realm_name(), character.region.upper(), character.level, character.get_class_name()) return_string += "Last Modified: {}\n".format( character.last_modified.strftime("%x - %I:%M:%S %p")) armory_url = "http://{}.battle.net/wow/en/character/{}/{}/advanced".format( target_region, character.get_realm_name().replace(' ', '%20'), character.name) # Raid Progression en_progress = get_raid_progression(character.progression, 8025) # the emarld nightmare tov_progress = get_raid_progression(character.progression, 8440) # trial of valor mythic_progress = get_mythic_progression(character) sockets = get_sockets(character.equipment) enchants = get_enchants(character.equipment) return_string += "<{}>\n".format(armory_url) return_string += "```CSS\n" # start Markdown # iLvL return_string += "Equipped Item Level: %s\n" % character.equipment.average_item_level_equipped # Mythic Progression return_string += "Mythics: +2: %s, +5: %s, +10: %s\n" % ( mythic_progress["plus_two"], mythic_progress["plus_five"], mythic_progress["plus_ten"]) return_string += "EN: {1}/{0} (N), {2}/{0} (H), {3}/{0} (M)\n".format( en_progress["total_bosses"], en_progress["normal"], en_progress["heroic"], en_progress["mythic"]) return_string += "TOV: {1}/{0} (N), {2}/{0} (H), {3}/{0} (M)\n".format( tov_progress["total_bosses"], tov_progress["normal"], tov_progress["heroic"], tov_progress["mythic"]) # Gems return_string += "Gems Equipped: %s/%s\n" % (sockets["equipped_gems"], sockets["total_sockets"]) # Enchants return_string += "Enchants: %s/%s\n" % (enchants["enchantable_slots"] - enchants["total_missing"], enchants["enchantable_slots"]) if enchants["total_missing"] > 0: return_string += "Missing Enchants: {0}".format(", ".join( enchants["missing_slots"])) return_string += "```" # end Markdown return return_string
region.addItem("Europe", QVariant(battlenet.EUROPE)) region.addItem("United States", QVariant(battlenet.UNITED_STATES)) region.addItem("Korea", QVariant(battlenet.KOREA)) region.addItem("Taiwan", QVariant(battlenet.TAIWAN)) self.connect(region, QtCore.SIGNAL("QtSig()"), self.updateRegion) groupLayout.addWidget(QLabel("Your region")) groupLayout.addWidget(region) """Realm select""" def updateRegion(self): pass if __name__ == "__main__": conn = Connection() region = battlenet.EUROPE app = QApplication(sys.argv) main = Main() main.show() #my_realms = ["Shadowsong", "Skullcrusher"] my_realms = [] if len(my_realms) == 0: for realm in conn.get_all_realms(region): main.add_realm(realm) else: for realm in conn.get_realms(region, my_realms): main.add_realm(realm)