示例#1
0
    def relog(self):

        api = pgoapi.PGoApi()
        api.activate_signature(
            "/home/nate/spyder workspace/pgo_unofficial/pgoapi/libencrypt.so")
        api.set_authentication(provider="ptc",
                               username=self.user,
                               password=self.passw)
        self.player = api
        #self.__init__(api,self.latitude,self.longitude,self.ID,self.user,self.passw,self.plt)
        time.sleep(15)
        wait = 0
        success = False
        while success == False:
            success = self.player.login(
                "ptc",  # returns true if a success
                self.user,
                self.passw,
                self.latitude,
                self.longitude,
                0,
                False)
            wait = wait + 5
            time.sleep(wait)
        return True
示例#2
0
    def load(self, accountID, lat, long):
        with open('csvdata/accounts.csv', 'r') as f:
            lines = f.readlines()
            f.close()

        line = lines[accountID]

        lineData = []
        chunk = ""

        line = line[:len(line) - 3]
        for i in line:
            if i == ",":
                lineData.append(chunk)
                chunk = ""
            else:
                chunk = chunk + i
        lineData.append(chunk)
        api = pgoapi.PGoApi()
        api.activate_signature(
            "/home/nate/spyder workspace/pgo_unofficial/pgoapi/libencrypt.so")
        api.set_authentication(provider="ptc",
                               username=lineData[0],
                               password=lineData[1])

        # in CSV file, format is:
        # user,pass,lat,long
        turt = turtle.turtle(api, float(lineData[2]), float(lineData[3]),
                             accountID, lineData[0], lineData[1], plt)
        time.sleep(1)
        turt.latitude = lat
        turt.longitude = long
        turt.player.set_position(lat, long, 0)
        self.turtles.append(turt)
示例#3
0
文件: pokecli.py 项目: rnadna1/fsd
def main():
    # log settings
    # log format
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
    # log level for http request class
    logging.getLogger("requests").setLevel(logging.WARNING)
    # log level for main pgoapi class
    logging.getLogger("pgoapi").setLevel(logging.INFO)
    # log level for internal pgoapi class
    logging.getLogger("rpc_api").setLevel(logging.INFO)

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    # parse position
    position = util.get_pos_by_name(config.location)
    if not position:
        log.error('Your given location could not be found by name')
        return
    elif config.test:
        return

    # set player position on the earth
    api.set_position(*position)

    if not api.login(config.auth_service,
                     config.username,
                     config.password,
                     app_simulation=True):
        return

    # get player profile call (single command example)
    # ----------------------
    response_dict = api.get_player()
    print('Response dictionary (get_player): \n\r{}'.format(
        pprint.PrettyPrinter(indent=4).pformat(response_dict)))

    # sleep due to server-side throttling
    time.sleep(0.2)

    # get player profile + inventory call (thread-safe/chaining example)
    # ----------------------
    req = api.create_request()
    req.get_player()
    req.get_inventory()
    response_dict = req.call()
    print('Response dictionary (get_player + get_inventory): \n\r{}'.format(
        pprint.PrettyPrinter(indent=4).pformat(response_dict)))
示例#4
0
def main():
    # log settings
    # log format
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
    # log level for http request class
    logging.getLogger("requests").setLevel(logging.WARNING)
    # log level for main pgoapi class
    logging.getLogger("pgoapi").setLevel(logging.INFO)
    # log level for internal pgoapi class
    logging.getLogger("rpc_api").setLevel(logging.INFO)

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    # set player position on the earth
    api.set_position(0.0, 0.0, 0.0)

    if not api.login(config.auth_service,
                     config.username,
                     config.password,
                     app_simulation=True):
        return

    # get player profile call (single command example)
    # ----------------------


#    response_dict = api.get_player()
#    print('Response dictionary (get_player): \n\r{}'.format(pprint.PrettyPrinter(indent=4).pformat(response_dict)))

# sleep 200ms due to server-side throttling
#    time.sleep(0.2)

# get player profile + inventory call (thread-safe/chaining example)
# ----------------------
    req = api.create_request()
    #    req.get_player()
    req.get_inventory()
    response_dict = req.call(
    )['responses']['GET_INVENTORY']['inventory_delta']['inventory_items']
    print(
        json.dumps(
            map(
                lambda i: i['inventory_item_data']['pokemon_data'],
                filter(
                    lambda i: i['inventory_item_data'].has_key('pokemon_data')
                    and not i['inventory_item_data']['pokemon_data'].has_key(
                        'is_egg'), response_dict))))
示例#5
0
def main():
    # log settings
    # log format
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
    # log level for http request class
    logging.getLogger("requests").setLevel(logging.WARNING)
    # log level for main pgoapi class
    logging.getLogger("pgoapi").setLevel(logging.INFO)
    # log level for internal pgoapi class
    logging.getLogger("rpc_api").setLevel(logging.INFO)

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    # parse position
    position = util.get_pos_by_name(config.location)
    if not position:
        log.error('Your given location could not be found by name')
        return
    elif config.test:
        return

    # Load pokemon
    pokemon_list = []
    pokemon_dict = json.load(open('examples/pogo-optimizer/data/pokemon.json'))

    # set player position on the earth
    api.set_position(*position)

    if not api.login(config.auth_service,
                     config.username,
                     config.password,
                     app_simulation=True):
        return

    lat, lng, x = api.get_position()
    origin = LatLng.from_degrees(lat, lng)
    parent = CellId.from_lat_lng(LatLng.from_degrees(lat, lng)).parent(15)

    # get player profile call (single command example)
    # ----------------------
    response_dict = api.get_player()
    print('Response dictionary (get_player): \n\r{}'.format(
        pprint.PrettyPrinter(indent=4).pformat(response_dict)))

    # sleep due to server-side throttling
    time.sleep(0.2)
示例#6
0
def accept_tos(username, password):
    api = pgoapi.PGoApi()
    api.set_position(0.0, 0.0, 0.0)
    api.login(config['auth_service'], username, password)
    time.sleep(2)
    req = api.create_request()
    req.mark_tutorial_complete(tutorials_completed=0,
                               send_marketing_emails=False,
                               send_push_notifications=False)
    response = req.call()
示例#7
0
文件: pokecli.py 项目: Brenza/pgoapi
def main():
    # log settings
    # log format
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
    # log level for http request class
    logging.getLogger("requests").setLevel(logging.WARNING)
    # log level for main pgoapi class
    logging.getLogger("pgoapi").setLevel(logging.INFO)
    # log level for internal pgoapi class
    logging.getLogger("rpc_api").setLevel(logging.INFO)

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    # parse position
    position = util.get_pos_by_name(config.location)
    if not position:
        log.error('Your given location could not be found by name')
        return
    elif config.test:
        return

    # set player position on the earth
    api.set_position(*position)

    # new authentication initialitation
    api.set_authentication(provider=config.auth_service,
                           username=config.username,
                           password=config.password)

    # provide the path for your encrypt dll
    api.activate_signature("encrypt.dll")

    # print get maps object
    cell_ids = util.get_cell_ids(position[0], position[1])
    timestamps = [
        0,
    ] * len(cell_ids)
    response_dict = api.get_map_objects(latitude=position[0],
                                        longitude=position[1],
                                        since_timestamp_ms=timestamps,
                                        cell_id=cell_ids)
    print('Response dictionary (get_player): \n\r{}'.format(
        pprint.PrettyPrinter(indent=4).pformat(response_dict)))
示例#8
0
def get_location(user, psswd, location, pokeOnly):
    splitloc = location.split(",")
    position = (float(splitloc[0]), float(splitloc[1]), 0)
    # instantiate pgoapi
    api = pgoapi.PGoApi()

    # provide player position on the earth
    api.set_position(*position)

    if not api.login('ptc', user, psswd):
        return

    # chain subrequests (methods) into one RPC call

    # get player profile call
    # ----------------------
    #api.get_player()

    # get inventory call
    # ----------------------
    #api.get_inventory()

    # get map objects call
    # repeated fields (e.g. cell_id and since_timestamp_ms in get_map_objects) can be provided over a list
    # ----------------------
    cell_ids = get_cell_ids(position[0], position[1])
    timestamps = [
        0,
    ] * len(cell_ids)
    api.get_map_objects(latitude=util.f2i(position[0]),
                        longitude=util.f2i(position[1]),
                        since_timestamp_ms=timestamps,
                        cell_id=cell_ids)

    # spin a fort
    # ----------------------
    #fortid = '<your fortid>'
    #lng = <your longitude>
    #lat = <your latitude>
    #api.fort_search(fort_id=fortid, fort_latitude=lat, fort_longitude=lng, player_latitude=f2i(position[0]), player_longitude=f2i(position[1]))

    # release/transfer a pokemon and get candy for it
    # ----------------------
    #api.release_pokemon(pokemon_id = <your pokemonid>)

    # get download settings call
    # ----------------------
    #api.download_settings(hash="05daf51635c82611d1aac95c0b051d3ec088a930")

    # execute the RPC call
    response_dict = api.call()
    handleMapResp(response_dict["responses"]["GET_MAP_OBJECTS"], pokeOnly)
示例#9
0
def main(request):
    api = pgoapi.PGoApi()

    mail = request.POST["mail"]
    passwd = request.POST["pass"]

    api.set_position(35.6602577, 139.6899648, 0)
    if not api.login("google", mail, passwd, app_simulation=True):
        return
    response_dict = [api.get_inventory(), api.get_player()]

    return HttpResponse(json.dumps(response_dict),
                        content_type="application/json")
def main():
    enable_led(LED_PIN1, False)
    enable_led(LED_PIN2, False)
    enable_led(LED_PIN3, False)
    # log format
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
    # log level for http request class
    logging.getLogger("requests").setLevel(logging.WARNING)
    # log level for main pgoapi class
    logging.getLogger("pgoapi").setLevel(logging.INFO)
    # log level for internal pgoapi class
    logging.getLogger("rpc_api").setLevel(logging.INFO)

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    # parse position
    position = util.get_pos_by_name(config.location)
    if not position:
        log.error('Your given location could not be found by name')
        return
    elif config.test:
        return

    # set player position on the earth
    api.set_position(*position)

    # new authentication initialitation
    api.set_authentication(provider=config.auth_service,
                           username=config.username,
                           password=config.password)

    # provide the FULL PATH for your encrypt .so
    api.activate_signature("/home/pi/pgoapi/libencrypt.so")

    while True:
        find_poi(api, position[0], position[1])
        time.sleep(30)
示例#11
0
def worker(wid, Wstart):
    workStart = min(Wstart, len(scans) - 1)
    workStop = min(Wstart + config['stepsPerPassPerWorker'], len(scans) - 1)
    if workStart == workStop:
        return
    print 'worker {} is doing steps {} to {}'.format(wid, workStart, workStop)
    #login
    login_attempt = 1
    logged_in = False
    while not logged_in:
        api = pgoapi.PGoApi(provider=config['auth_service'],
                            username=config['users'][wid]['username'],
                            password=config['users'][wid]['password'],
                            position_lat=0,
                            position_lng=0,
                            position_alt=0)
        api.activate_signature(utils.get_encryption_lib_path())
        try:
            api.get_player()
            logged_in = True
        except NotLoggedInException:
            print('thread {} Login Error, retry {}/10').format(
                wid, login_attempt)
            login_attempt += 1
    time.sleep(0.5)
    #iterate
    for j in range(5):
        startTime = time.time()
        print 'worker {} is doing {} pass'.format(wid, num2words[j])
        for i in xrange(workStart, workStop):
            doScanp(wid, scans[i][0], scans[i][1], api)
        curTime = time.time()
        if 600 - (curTime - startTime) > 0:
            print 'worker {} took {} seconds to do {} pass, now sleeping for {}'.format(
                wid, curTime - startTime, num2words[j],
                600 - (curTime - startTime))
            time.sleep(600 - (curTime - startTime))
        else:
            print 'worker {} took {} seconds to do {} pass so not sleeping'.format(
                wid, curTime - startTime, num2words[j])
    startTime = time.time()
    print 'worker {} is doing {} pass'.format(wid, num2words[5])
    for i in xrange(workStart, workStop):
        doScanp(wid, scans[i][0], scans[i][1], api)
    curTime = time.time()
    print 'worker {} took {} seconds to do {} pass ending thread'.format(
        wid, curTime - startTime, num2words[5])
示例#12
0
    def login(self):
        self.api = pgoapi.PGoApi()

        self.get_location()

        self.logger.info('Set location - %f, %f', self.lat, self.lng)
        self.set_location(self.lat, self.lng, False)
        self.api.set_authentication(
            provider=self.config['auth_service'],
            username=self.config['username'],
            password=self.config['password'],
        )
        self.api.activate_signature(self.config['encrypt_location'])

        self.trainer_info()
        self.inventorys.check_items()
        self.inventorys.check_pokemons()
        self.dump_best_pokemons()
示例#13
0
def start(config, login=False):
    # -- dictionaries for pokedex, families, and evolution prices
    with open(os.path.normpath(os.path.join(root, 'pgoapi','pokemon.json'))) as f:
        pokemonInfo = json.load(f)
        
    with open(os.path.normpath(os.path.join(root, 'pgoapi','moves.json'))) as f:
        moveInfo = json.load(f)
        
    with open(os.path.normpath(os.path.join(root, 'pgoapi','types.json'))) as f:
        types = json.load(f)
    
    with open('german-names.tsv') as f:
        f.readline()
        german = dict(csv.reader(f, delimiter='\t'))    
        
    with open('families.tsv') as f:
        f.readline()
        family = dict(csv.reader(f, delimiter='\t'))    
        
    with open('evolves.tsv') as f:
        f.readline()
        cost = dict(csv.reader(f, delimiter='\t'))
        
    pokedex = dict([(int(p["Number"]),p["Name"]) for p in pokemonInfo])
    moves = dict([(int(m["id"]),{"type":m["type"],"name":m["name"]}) for m in moveInfo])
    
    # -- change language if selected -->
    if config["language"] is not None and config["language"].lower() == 'german':
        for k,v in pokedex.items():
            pokedex[k] = german[str(k)];
            
    
    # instantiate pgoapi
    api = pgoapi.PGoApi()
    
    data = PokemonData(pokedex, moves, types, family, cost, config, api, login)
    
    main_window = tk.Tk()
    
    main_window.style = ttk.Style()
    main_window.style.theme_use("classic")
    
    app = PokeIVWindow(config,data,master=main_window)
    app.mainloop()
def main():

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    # parse position
    position = util.get_pos_by_name(config.location)
    if not position:
        log.error('Your given location could not be found by name')
        return
    elif config.test:
        return

    # set player position on the earth
    api.set_position(*position)

    if not api.login(config.auth_service,
                     config.username,
                     config.password,
                     app_simulation=True):
        return

    # get player profile + inventory call (thread-safe/chaining example)
    # ----------------------
    req = api.create_request()
    req.get_player()
    req.get_inventory()
    response_dict = req.call()
    print json.dumps(response_dict)
示例#15
0
def main():
    # log settings
    # log format
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
    # log level for http request class
    logging.getLogger("requests").setLevel(logging.WARNING)
    # log level for main pgoapi class
    logging.getLogger("pgoapi").setLevel(logging.INFO)
    # log level for internal pgoapi class
    logging.getLogger("rpc_api").setLevel(logging.INFO)

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    position = get_pos_by_name(config.location)
    if config.test:
        return

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    # provide player position on the earth
    api.set_position(*position)

    if not api.login(config.auth_service, config.username, config.password):
        return

    # chain subrequests (methods) into one RPC call

    # get player profile call
    # ----------------------
    #api.get_player()

    # get inventory call
    # ----------------------
    #api.get_inventory()

    # get map objects call
    # repeated fields (e.g. cell_id and since_timestamp_ms in get_map_objects) can be provided over a list
    # ----------------------
    cell_ids = get_cell_ids(position[0], position[1])
    timestamps = [
        0,
    ] * len(cell_ids)
    api.get_map_objects(latitude=util.f2i(position[0]),
                        longitude=util.f2i(position[1]),
                        since_timestamp_ms=timestamps,
                        cell_id=cell_ids)

    # spin a fort
    # ----------------------
    #fortid = '<your fortid>'
    #lng = <your longitude>
    #lat = <your latitude>
    #api.fort_search(fort_id=fortid, fort_latitude=lat, fort_longitude=lng, player_latitude=f2i(position[0]), player_longitude=f2i(position[1]))

    # release/transfer a pokemon and get candy for it
    # ----------------------
    #api.release_pokemon(pokemon_id = <your pokemonid>)

    # evolve a pokemon if you have enough candies
    # ----------------------
    #api.evolve_pokemon(pokemon_id = <your pokemonid>)

    # get download settings call
    # ----------------------
    #api.download_settings(hash="05daf51635c82611d1aac95c0b051d3ec088a930")

    # execute the RPC call
    response_dict = api.call()
    print(response_dict)
    print("END_OF_RESPONSE")
示例#16
0
def main():
    setupLogger()
    log.debug('Logger set up')

    config = init_config()
    if not config:
        return

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    # -- dictionaries for pokedex, families, and evolution prices
    with open(os.path.normpath(os.path.join(root, 'pgoapi',
                                            'pokemon.json'))) as f:
        pokemonInfo = json.load(f)

    with open(os.path.normpath(os.path.join(root, 'pgoapi',
                                            'moves.json'))) as f:
        moveInfo = json.load(f)

    with open(os.path.normpath(os.path.join(root, 'pgoapi',
                                            'types.json'))) as f:
        types = json.load(f)

    with open('families.tsv') as f:
        f.readline()
        family = dict(csv.reader(f, delimiter='\t'))

    with open('evolves.tsv') as f:
        f.readline()
        cost = dict(csv.reader(f, delimiter='\t'))

    pokedex = dict([(int(p["Number"]), p["Name"]) for p in pokemonInfo])
    moves = dict([(int(m["id"]), {
        "type": m["type"],
        "name": m["name"]
    }) for m in moveInfo])

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    data = PokemonData(pokedex,
                       moves,
                       types,
                       family,
                       cost,
                       config,
                       api,
                       login=True)

    if len(data["all"]) == 0:
        print('You have no pokemon...')
        return

    #------- best pokemon
    if data["best"]:
        print_header('Highest IV Pokemon')
        print_pokemon(data["best"], data["config"]["verbose"])
    #------- transferable pokemon
    if data["transfer"]:
        print_header('May be transfered')
        print_pokemon(data["transfer"], data["config"]["verbose"])
    #------- evolve candidate pokemon
    if data["evolve"]:
        print_evolve_candidates(data)
    #------- transfer extra pokemon
    if data["config"]["transfer"] and data["transfer"]:
        transfer_pokemon(data)
    #------- evolving t1 pokemon
    if data["config"]["evolve"] and data["evolve"]:
        evolve_pokemon(data)
示例#17
0
def main():
    # log settings
    # log format
    logging.basicConfig(
        level=logging.DEBUG, format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s'
    )
    # log level for http request class
    logging.getLogger("requests").setLevel(logging.WARNING)
    # log level for main pgoapi class
    logging.getLogger("pgoapi").setLevel(logging.INFO)
    # log level for internal pgoapi class
    logging.getLogger("rpc_api").setLevel(logging.INFO)

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    position = get_pos_by_name(config.location)
    if config.test:
        return

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    if not api.login(config.auth_service, config.username, config.password):
        return

    api.download_settings(hash="05daf51635c82611d1aac95c0b051d3ec088a930")
    pokemons = []

    steps = 8
    positions = [position]

    for i in range(steps):
        for j in range(steps):
            positions.append((position[0]+(j*0.002), position[1]+(i*0.002), position[2]))
            positions.append((position[0]-(j*0.002), position[1]-(i*0.002), position[2]))
            positions.append((position[0]+(j*0.002), position[1]-(i*0.002), position[2]))
            positions.append((position[0]-(j*0.002), position[1]+(i*0.002), position[2]))

    for position in positions:
        cell_ids = get_cell_ids(position[0], position[1])

        # provide player position on the earth
        api.set_position(position[0], position[1], position[2])
        timestamps = [0, ] * len(cell_ids)

        api.get_map_objects(
            latitude=util.f2i(position[0]),
            longitude=util.f2i(position[1]),
            since_timestamp_ms=timestamps,
            cell_id=cell_ids
        )
        # execute the RPC call
        response_dict = api.call()
        pokemons.extend(get_pokemons_from_call(response_dict))

    with open('web/result.json', "w") as f:
        f.write(json.dumps(
            {
                "Latitude": position[0],
                "Longitude": position[1],
                "Pokemons": remove_duplicates(pokemons)
            },
            sort_keys=True,
            indent=2
        ))
示例#18
0
    "Geodude", "Graveler", "Golem", "Ponyta", "Rapidash", "Slowpoke",
    "Slowbro", "Magnemite", "Magneton", "Farfetch'd", "Doduo", "Dodrio",
    "Seel", "Dewgong", "Grimer", "Muk", "Shellder", "Cloyster", "Gastly",
    "Haunter", "Gengar", "Onix", "Drowzee", "Hypno", "Krabby", "Kingler",
    "Voltorb", "Electrode", "Exeggcute", "Exeggutor", "Cubone", "Marowak",
    "Hitmonlee", "Hitmonchan", "Lickitung", "Koffing", "Weezing", "Rhyhorn",
    "Rhydon", "Chansey", "Tangela", "Kangaskhan", "Horsea", "Seadra",
    "Goldeen", "Seaking", "Staryu", "Starmie", "Mr. Mime", "Scyther", "Jynx",
    "Electabuzz", "Magmar", "Pinsir", "Tauros", "Magikarp", "Gyarados",
    "Lapras", "Ditto", "Eevee", "Vaporeon", "Jolteon", "Flareon", "Porygon",
    "Omanyte", "Omastar", "Kabuto", "Kabutops", "Aerodactyl", "Snorlax",
    "Articuno", "Zapdos", "Moltres", "Dratini", "Dragonair", "Dragonite",
    "Mewtwo", "Mew"
]
log("Authorising account with Pokemon GO servers..")
pokeapi = pgoapi.PGoApi()
login_name = str(raw_input("Username: "******"Auth Type (google or ptc): "))
if not pokeapi.login(service, login_name, password):
    log("Could not login.")
    sys.exit(0)
log("Authorised.")
log("Getting Inventory...")
pokeapi.get_inventory()
response = pokeapi.call()
items = response['responses']['GET_INVENTORY']['inventory_delta'][
    'inventory_items']
for item in items:
    if 'pokemon_data' in item['inventory_item_data']:
        if 'is_egg' not in item['inventory_item_data']['pokemon_data']:
示例#19
0
def main():
    # log settings
    # log format
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
    # log level for http request class
    logging.getLogger("requests").setLevel(logging.WARNING)
    # log level for main pgoapi class
    logging.getLogger("pgoapi").setLevel(logging.INFO)
    # log level for internal pgoapi class
    logging.getLogger("rpc_api").setLevel(logging.INFO)

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    device_info = {
        'device_id': uuid.uuid4().hex,
        'device_brand': 'Apple',
        'device_model': 'iPhone',
        'device_comms_model': 'iPhone8,2',
        'hardware_manufacturer': 'Apple',
        'hardware_model': 'N66AP',
        'firmware_brand': 'iPhone OS',
        'firmware_type': '9.3.3'
    }
    # instantiate pgoapi
    api = pgoapi.PGoApi(device_info=device_info)
    if config.proxy:
        api.set_proxy({'http': config.proxy, 'https': config.proxy})

    # parse position TODO
    position = util.get_pos_by_name(config.location)
    if not position:
        log.error('Your given location could not be found by name')
        return
    elif config.test:
        return

    #set player position on the earth
    api.set_position(*position)

    # new authentication initialitation
    if config.proxy:
        api.set_authentication(provider=config.auth_service,
                               username=config.username,
                               password=config.password,
                               proxy_config={
                                   'http': config.proxy,
                                   'https': config.proxy
                               })
    else:
        api.set_authentication(provider=config.auth_service,
                               username=config.username,
                               password=config.password)

    # provide the path for your encrypt dll
    api.activate_signature(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "libencrypt.so"))
    api.app_simulation_login()

    time.sleep(10)

    cell_ids = util.get_cell_ids(position[0], position[1])
    timestamps = [
        0,
    ] * len(cell_ids)
    request = api.create_request()
    request.get_map_objects(latitude=position[0],
                            longitude=position[1],
                            since_timestamp_ms=timestamps,
                            cell_id=cell_ids)
    request.check_challenge()
    #request.get_hatched_eggs()
    #request.get_inventory()
    #request.check_awarded_badges()
    #request.download_settings(hash="8631c515a4c084ef30ef4d6eee8f5f5b250db697")#old54b359c97e46900f87211ef6e6dd0b7f2a3ea1f5
    #request.get_buddy_walked()
    response_dict = request.call()
    #print('Response dictionary (map_objects): \n\r{}'.format(pprint.PrettyPrinter(indent=4).pformat(response_dict)))

    if 'status' not in response_dict['responses']['GET_MAP_OBJECTS']:
        raise ValueError("Invalid response: {}".format(
            json.dumps(response_dict, indent=2)))
    if response_dict['responses']['GET_MAP_OBJECTS']['status'] == 1:
        for cell in response_dict['responses']['GET_MAP_OBJECTS']['map_cells']:
            if 'nearby_pokemons' in cell:
                print "nearby_pokemons in cell: " + cell['s2_cell_id']
                print cell['nearby_pokemons']
            if 'wild_pokemons' in cell:
                pprint.PrettyPrinter(indent=2).pformat(cell['wild_pokemons'])

        print response_dict['responses']['CHECK_CHALLENGE']
    """
示例#20
0
def get_all_player_data(config, custom_location=None, allow_debug=True):
    # log settings
    if allow_debug:
        # log format
        logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(module)11s] [%(levelname)5s] %(message)s')
        # log level for http request class
        logging.getLogger("requests").setLevel(logging.WARNING)
        # log level for main pgoapi class
        logging.getLogger("pgoapi").setLevel(logging.INFO)
        # log level for internal pgoapi class
        logging.getLogger("rpc_api").setLevel(logging.INFO)

    if custom_location:
        config.location = custom_location

    # debug mode
    if allow_debug and config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    # get current timestamp
    now = str(int(time.time()))

    # get root dir
    app_root_dir = os.path.dirname(os.path.realpath(__file__))

    # declare output files location
    web_inventory_user = os.path.join(app_root_dir, 'web/playerdata/inventory-%s.json' % config.username)
    web_player_user = os.path.join(app_root_dir, 'web/playerdata/player-%s.json' % config.username)
    web_settings_user = os.path.join(app_root_dir, 'web/playerdata/settings-%s.json' % config.username)

    # declare output request log
    web_log_api = os.path.join(app_root_dir, 'web/playerdata/api-request.' + now + '.log')

    # instantiate pgoapi
    api = pgoapi.PGoApi()
    if config.proxy:
        api.set_proxy({'http': config.proxy, 'https': config.proxy})

    # parse position
    position = util.get_pos_by_name(config.location)
    if not position and allow_debug:
        log.error('Your given location could not be found by name')
        return
    elif config.test:
        return

    # set player position on the earth
    api.set_position(*position)

    # new authentication initialisation
    if config.proxy:
        api.set_authentication(provider=config.auth_service, username=config.username, password=config.password,
                               proxy_config={'http': config.proxy, 'https': config.proxy})
    else:
        api.set_authentication(provider=config.auth_service, username=config.username, password=config.password)

    # provide the path for your encrypt dll, see http://pgoapi.com/
    if os.path.isfile('libencrypt.dll'):
        api.activate_signature("libencrypt.dll")
    elif os.path.isfile('libencrypt.so'):
        api.activate_signature("libencrypt.so")

    # create thread-safe request
    # ----------------------
    req = api.create_request()

    # get player profile call
    # ----------------------
    req.get_player()

    # get inventory call
    # ----------------------
    req.get_inventory()

    # get download setting call
    # ----------------------
    req.download_settings()

    # execute the RPC call after 2 seconds
    time.sleep(2)
    response_dict = req.call()

    # backup latest output files
    if os.path.isfile(web_inventory_user):
        copyfile(web_inventory_user, web_inventory_user + '.' + now)
    if os.path.isfile(web_player_user):
        copyfile(web_player_user, web_player_user + '.' + now)
    if os.path.isfile(web_settings_user):
        copyfile(web_settings_user, web_settings_user + '.' + now)

    # write the output inventory file
    inventory_dict = response_dict['responses']['GET_INVENTORY']['inventory_delta']
    with open(web_inventory_user, 'w') as output_file:
        json.dump(inventory_dict, output_file, indent=2, cls=util.JSONByteEncoder)

    # write the output player file
    player_dict = response_dict['responses']['GET_PLAYER']['player_data']
    with open(web_player_user, 'w') as output_file:
        json.dump(player_dict, output_file, indent=2, cls=util.JSONByteEncoder)

    # write the output setting file
    setting_dict = response_dict['responses']['DOWNLOAD_SETTINGS']['settings']
    with open(web_settings_user, 'w') as output_file:
        json.dump(setting_dict, output_file, indent=2, cls=util.JSONByteEncoder)

    # log the request
    config.password = '******'
    with open(web_log_api, 'w') as output_file:
        output_file.write(repr(config))
示例#21
0
def main():
    # log settings
    # log format
    logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
    # log level for http request class
    logging.getLogger("requests").setLevel(logging.WARNING)
    # log level for main pgoapi class
    logging.getLogger("pgoapi").setLevel(logging.INFO)
    # log level for internal pgoapi class
    logging.getLogger("rpc_api").setLevel(logging.INFO)

    config = init_config()
    if not config:
        return

    if config.debug:
        logging.getLogger("requests").setLevel(logging.DEBUG)
        logging.getLogger("pgoapi").setLevel(logging.DEBUG)
        logging.getLogger("rpc_api").setLevel(logging.DEBUG)

    if config.test:
        return

    # instantiate pgoapi
    api = pgoapi.PGoApi()

    if not api.login(config.auth_service, config.username, config.password):
        return

    # get inventory call
    # ----------------------
    api.get_inventory()

    # execute the RPC call
    response_dict = api.call()

    approot = os.path.dirname(os.path.realpath(__file__))

    with open(os.path.join(approot, 'data/moves.json')) as data_file:
        moves = json.load(data_file)

    with open(os.path.join(approot, 'data/pokemon.json')) as data_file:
        pokemon = json.load(data_file)

    def format(i):
        i = i['inventory_item_data']['pokemon_data']
        i = {k: v for k, v in i.items() if k in ['nickname','move_1', 'move_2', 'pokemon_id', 'individual_defense', 'stamina', 'cp', 'individual_stamina', 'individual_attack']}
        i['individual_defense'] =  i.get('individual_defense', 0)
        i['individual_attack'] =  i.get('individual_attack', 0)
        i['individual_stamina'] =  i.get('individual_stamina', 0)
        i['power_quotient'] = round(((float(i['individual_defense']) + float(i['individual_attack']) + float(i['individual_stamina'])) / 45) * 100)
        i['name'] = list(filter(lambda j: int(j['Number']) == i['pokemon_id'], pokemon))[0]['Name']
        i['move_1'] = list(filter(lambda j: j['id'] == i['move_1'], moves))[0]['name']
        i['move_2'] = list(filter(lambda j: j['id'] == i['move_2'], moves))[0]['name']
        return i

    all_pokemon = filter(lambda i: 'pokemon_data' in i['inventory_item_data'] and 'is_egg' not in i['inventory_item_data']['pokemon_data'], response_dict['responses']['GET_INVENTORY']['inventory_delta']['inventory_items'])
    all_pokemon = list(map(format, all_pokemon))
    all_pokemon.sort(key=lambda x: x['power_quotient'], reverse=True)

    print(tabulate(all_pokemon, headers = "keys"))
示例#22
0
def main():
    config = init_config()
    location = Location(33.74168493949062, -118.10637474060057)
    api = pgoapi.PGoApi()

    try:
        if not api.login(config.auth_service, config.username, config.password,
                         location.latitude, location.longitude,
                         location.altitude):
            raise exceptions.AuthException('Login failed')

        request = api.create_request()
        request.get_player()
        request.get_inventory()
        response = request.call()

        enable_rawdata = False
        try:
            if int(config.rawdata) > 0:
                enable_rawdata = True
        except ValueError as e:
            pass
        if enable_rawdata:
            with open('raw_data_{}.json'.format(current_logfile),
                      'w') as fileout:
                fileout.write(pprint.PrettyPrinter(indent=4).pformat(response))

        inventory_items = response['responses']['GET_INVENTORY'][
            'inventory_delta']['inventory_items']
        player_data = response['responses']['GET_PLAYER']['player_data']
        player_stats = None

        pokemons = []
        stats = []
        egg_incubators = []
        items = []
        candies = []
        others = []

        item_count = 1

        for item in inventory_items:
            if 'pokedex_entry' in item['inventory_item_data']:
                pokemons.append(item['inventory_item_data']['pokedex_entry'])
            elif 'pokemon_data' in item['inventory_item_data']:
                stats.append(item['inventory_item_data']['pokemon_data'])
            elif 'egg_incubators' in item['inventory_item_data']:
                egg_incubators.append(
                    item['inventory_item_data']['egg_incubators'])
            elif 'item' in item['inventory_item_data']:
                items.append(item['inventory_item_data']['item'])
                item_count += item['inventory_item_data']['item'].get(
                    'count', 0)
            elif 'candy' in item['inventory_item_data']:
                candies.append(item['inventory_item_data']['candy'])
            elif 'player_stats' in item['inventory_item_data']:
                player_stats = item['inventory_item_data']['player_stats']
            else:
                others.append(item['inventory_item_data'])

        content = 'Data from Your Pokemon Go Account\n\n'
        content += player_infomation(player_stats, player_data, len(stats),
                                     item_count)
        content += pokemon_candies(candies)
        content += player_item_list(items)
        content += pokedex(pokemons, stats)

        with open('player_stats_{}.txt'.format(current_logfile),
                  'w') as fileout:
            fileout.write(content)

        pokemon_stats(stats)

        print('             Done! :)\n \
            Check all the extracted data in the PogoExtractor directory.\n{} \
            * player_stats_{}.txt\n \
            * pokemon_stats_{}.csv\n'.format(
            '             * raw_data_{}.txt\n'.format(current_logfile)
            if enable_rawdata else '', current_logfile, current_logfile))

    except exceptions.AuthException as e:
        print(e.args[0])
    except exceptions.NoPlayerPositionSetException as e:
        print('latitude, longitude, and altitude are required')
    except exceptions.NotLoggedInException as e:
        print('not logged in')
    except exceptions.EmptySubrequestChainException as e:
        print('empty request list')