async def get_wow_character_image_from_url(url): """Returns the avartar image of the given wow character url. url - https://worldofwarcraft.com/en-us/character/us/malganis/astrocamp """ blizzard_client = BlizzardApi(BLIZZARD_CLIENT, BLIZZARD_SECRET) parsed_armory_url = urlparse(url) path_parts = parsed_armory_url.path.strip("/").rsplit("/") locale, obj, region, realm_slug, character_name = path_parts resource = blizzard_client.wow.profile.get_character_media_summary( region=region, locale=locale, realm_slug=realm_slug, character_name=character_name.lower(), ) return resource["assets"][0]["value"]
def setup(self): self.api = BlizzardApi("client_id", "client_secret") self.api.diablo3.game_data._access_token = "access_token"
def setup(self): self.api = BlizzardApi("client_id", "client_secret") self.api.wow.profile._access_token = "access_token"
def setup(self): self.api = BlizzardApi("client_id", "client_secret") self.api.diablo3.community._access_token = "access_token"
#import realmlist # first realmlist execute then apiconnect !!! from blizzardapi import BlizzardApi import json import os import datetime import datainfo as d api_client = BlizzardApi(d.key, d.secretkey) # changed create new id file insted of one big downloadfile # def create_new_folder(): # """ create new folder where data from api came in""" # try: # directory = current_date()+"_Json_data" # parent_dir = "E:\serverWowApi\data" # path = os.path.join(parent_dir, directory) # os.mkdir(path) # #print('created file :'+directory) # return directory # # except FileExistsError as exc: # print("file with this name exist error :"+exc) def create_new_folder(id_server): """ create new folder where data from api came in""" try: directory = str(id_server) parent_dir = os.getcwd() +"\data" # print('make path '+ str(id_server)) path = os.path.join(parent_dir, directory) os.mkdir(path)
def setup(self): self.api = BlizzardApi("client_id", "client_secret") self.api.battlenet.oauth._access_token = "access_token"
def main(): config = configparser.ConfigParser() config.read('config.ini') client_id = config.get('DEFAULT', 'Client_ID') secret_id = config.get('DEFAULT', 'Secret_ID') api_client = BlizzardApi(client_id, secret_id) # 5 is proudmoore's connected server ID # TODO: In future support more servers response = api_client.wow.game_data.get_auctions("us", "en_US", "5") auctions = response["auctions"] ## load fish fish_list = [] ## save fish IDs here to use later ## lost sole = 173032 ## iridescent amberjack = 173033 ## silvergill pike = 173034 ## pocked bonefish = 173035 ## spinefin pirahna = 173036 ## elysian Thade = 173037 # TODO: find a better way? Each expansion different # items will want to be tracked # instantiate individual fish lists.. # storing everything for each fish # then finding lowest value to just track that # reduce noise for first release # TODO: In future, include more to see if market can # be manipulated with buys lo_so = [] ir_am = [] si_pi = [] po_bo = [] sp_pi = [] el_th = [] # declare time here instead of in loop for two reasons: # one call better than unknown amount of calls # keep all fish to the same hour for edge cases now = datetime.utcnow() # extract out only fish auctions for auction in auctions: if auction['item']['id'] == 173032: auction['fish_name'] = 'Lost Sole' auction['date'] = now.strftime("%x") auction['hour'] = now.strftime("%H") lo_so.append(auction) elif auction['item']['id'] == 173033: auction['fish_name'] = 'Iridescent Amberjack' auction['date'] = now.strftime("%x") auction['hour'] = now.strftime("%H") ir_am.append(auction) elif auction['item']['id'] == 173034: auction['fish_name'] = 'Silvergill Pike' auction['date'] = now.strftime("%x") auction['hour'] = now.strftime("%H") si_pi.append(auction) elif auction['item']['id'] == 173035: auction['fish_name'] = 'Pocked Bonefish' auction['date'] = now.strftime("%x") auction['hour'] = now.strftime("%H") po_bo.append(auction) elif auction['item']['id'] == 173036: auction['fish_name'] = 'Spinefin Pirahna' auction['date'] = now.strftime("%x") auction['hour'] = now.strftime("%H") sp_pi.append(auction) elif auction['item']['id'] == 173037: auction['fish_name'] = 'Elysian Thade' auction['date'] = now.strftime("%x") auction['hour'] = now.strftime("%H") el_th.append(auction) # set lowest value item to the list of items to store in dynamodb fish_list.append(low_val(lo_so)) fish_list.append(low_val(ir_am)) fish_list.append(low_val(si_pi)) fish_list.append(low_val(po_bo)) fish_list.append(low_val(sp_pi)) fish_list.append(low_val(el_th)) # UUID for partition key in dynamoDB for item in fish_list: item['GUID'] = str(uuid.uuid4()) # TODO: change to dynamodb set items load_table(fish_list)
def setup(self): self.api = BlizzardApi("client_id", "client_secret") self.api.hearthstone.game_data._access_token = "access_token"
from blizzardapi import BlizzardApi from pprint import pprint REGION = "us" LOCALE = "en_US" CLIENT_ID = "d49a50fe6379445ab8b8becdd8e765b7" CLIENT_SECRET = "6n9FfFswhVMfROMso1v5dF0fczMM59fG" REALM_ID = 3676 api_client = BlizzardApi(CLIENT_ID, CLIENT_SECRET) """Get the item class and its related item subclasses """ def getItemClassByID(class_id: int, region=REGION, locale=LOCALE) -> dict: item_class_resp = api_client.wow.game_data.get_item_class( region=region, locale=locale, item_class_id=class_id) # if the code key is not in the response json, the query was successful and return the # result if "code" not in item_class_resp: return item_class_resp else: return None def getItemSubclassByID(class_id: int, subclass_id: int, region=REGION, locale=LOCALE) -> dict: item_subclass_resp = api_client.wow.game_data.get_item_subclass(
import realmlist # first realmlist execute then apiconnect !!! # import wowapi import json import os import datetime from blizzardapi import BlizzardApi key = '0d7282069bad432c8cac95125523f7cf' secretkey = 'wLcGwQgP72kzpMzH81I8siD4UbZTlH2f' api_client = BlizzardApi(key, secretkey) def current_date(): """ return date m/d/y/h/m/ """ current_date = datetime.datetime.now() string_date = current_date.strftime("%m.%d.%Y_%H;%M") return string_date def save_file_json(file_to_save, id_group_server, directory): """ save downlaoded file, taking arg id_group_server """ with open('data/Json/'+directory+'/'+'ah_' + str(id_group_server) + '_' + current_date() + '.json', 'w') as json_file: print("save json file") json.dump(file_to_save, json_file,) #indent=2) def create_new_folder(id_server): """ create new folder where data from api came in""" try: directory = str(id_server) parent_dir = os.getcwd() +"\data\Json"