Exemplo n.º 1
0
def main():
    api = PiousAcademic()
    
    #Meta requests
    #I'd recommend storing all of this data locally and updating it every once in a while to be sure your
    #metadata is up-to-date.
    #Note that the information used for game_variants_by_id is obtained from game_base_variants. The same
    #follows for maps_variants_by_id and maps.
    campaign_missions = api.get_campaign_missions()
    commendations = api.get_commendations()
    csr_designations = api.get_csr_designations()
    enemies = api.get_enemies()
    flexible_stats = api.get_flexible_stats()
    game_base_variants = api.get_game_base_variants()
    game_variants_by_id = api.get_game_variants_by_id('1571fdac-e0b4-4ebc-a73a-6e13001b71d3')
    impulses = api.get_impulses()
    maps_variants_by_id = api.get_maps_variants_by_id('cb251c51-f206-11e4-8541-24be05e24f7e')
    maps = api.get_maps()
    medals = api.get_medals()
    playlists = api.get_playlists()
    skulls = api.get_skulls()
    spartan_ranks = api.get_spartan_ranks()
    team_colors = api.get_team_colors()
    vehicles = api.get_vehicles()
    weapons = api.get_weapons()
    
    #These two calls are, as of now, just demos. There is currently no endpoint that allows you to obtain a list of the
    #ids of all req packs and req items. This test data is just to confirm the integrity of the request itself, and was obtained
    #from the developer forums.
    #Moral of the story: Use the developer forums! There are helpful people there waiting to answer any and all questions.
    reqpacks = api.get_requisition_packs_by_id('3a1614d9-20a4-4817-a189-88cb781e9152')
    req = api.get_requisition_by_id('e4f549b2-90af-4dab-b2bc-11a46ea44103')    
    
    #Stat requests
    #Note that I'm too lazy to write out demos for requests of similar nature. So in the case of all service record requests,
    #the format is that exact same as the history constant I defined below. The same follows for all post-game carnage
    #report requests, they follow the format that arena_match_by_id uses.
    history = api.get_arena_servicerecord_for_players('ROFL A WET SOCK,ScorchedAbyss')
    playermatches1 = api.get_matches_for_player('ROFL A WET SOCK')
    playermatches2 = api.get_matches_for_player('ROFL A WET SOCK','warzone')
    arena_match_by_id = api.get_warzone_match_by_id('2568c24a-7604-4a55-9fac-201f03f3b813')
Exemplo n.º 2
0
def main():
    api = PiousAcademic()
    
    campaign_missions = api.get_campaign_missions()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\campaignmissions.json', 'w') as fp:
        json.dump(campaign_missions, fp)    
            
    commendations = api.get_commendations()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\commendations.json', 'w') as fp:
        json.dump( commendations, fp)
                            
    csr_designations = api.get_csr_designations()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\CSRdesignations.json', 'w') as fp:
        json.dump(csr_designations, fp)    
                            
    enemies = api.get_enemies()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\enemies.json', 'w') as fp:
        json.dump(enemies, fp)    
                            
    flexible_stats = api.get_flexible_stats()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\flexiblestats.json', 'w') as fp:
        json.dump(flexible_stats, fp)        
        
    game_base_variants = api.get_game_base_variants()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\gamebasevariants.json', 'w') as fp:
        json.dump(game_base_variants, fp)        
                            
    impulses = api.get_impulses()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\impulses.json', 'w') as fp:
        json.dump(impulses, fp)  
                            
    maps = api.get_maps()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\maps.json', 'w') as fp:
        json.dump(maps, fp)  
                            
    medals = api.get_medals()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\medals.json', 'w') as fp:
        json.dump(medals, fp)       
                            
    playlists = api.get_playlists()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\playlists.json', 'w') as fp:
        json.dump(playlists, fp)  
                            
    skulls = api.get_skulls()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\skulls.json', 'w') as fp:
        json.dump(skulls, fp)       
                            
    spartan_ranks = api.get_spartan_ranks()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\spartanranks.json', 'w') as fp:
        json.dump(spartan_ranks, fp)      
                            
    team_colors = api.get_team_colors()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\teamcolors.json', 'w') as fp:
        json.dump(team_colors, fp)     
                            
    vehicles = api.get_vehicles()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\vehicles.json', 'w') as fp:
        json.dump(vehicles, fp)    
                            
    weapons = api.get_weapons()
    time.sleep(1)
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\weapons.json', 'w') as fp:
        json.dump(weapons, fp)    
    
    #now use the above static data to execute the variant meta requests
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\maps.json') as data_file:
        mapfile = json.load(data_file)
    mapvariants = {}
    for item in mapfile:
        while True:
            try:
                mapid = item['id']
                variantinfo = api.get_maps_variants_by_id(mapid)
                mapvariants[mapid] = variantinfo
            except:
                time.sleep(9)
                continue
            break
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\mapvariants.json', 'w') as fp:
        json.dump(mapvariants, fp)
        
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\gamebasevariants.json') as data_file:
        gamefile = json.load(data_file)
    gamevariants = {}
    for item in gamefile:
        while True:
            try:
                gameid = item['id']
                variantinfo = api.get_game_variants_by_id(gameid)
                gamevariants[gameid] = variantinfo
            except:
                time.sleep(9)
                continue
            break
    with open(r'C:\Users\David\Documents\Github\16807-Pious-Academic\Metadata\gamevariants.json', 'w') as fp:
        json.dump(gamevariants, fp)