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:
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:
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