Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Update everything #219

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
bafdee0
improve headers, add locale
Jul 14, 2017
802f7c1
adapt auth of aiopogo
Jul 14, 2017
06dad5d
fix returning access token
Jul 14, 2017
d6845ef
readd some checks
Jul 14, 2017
d4602d0
be more informative
Jul 14, 2017
9c8ad01
fix cookie access
Jul 14, 2017
c203c1b
experimental iOS ptc login update
Jul 14, 2017
a455fd7
fix timeout exception catch
Jul 15, 2017
6876230
use variables for params and headers
Jul 20, 2017
07cfdbf
update version to 0.69.0
Jul 20, 2017
bd9cc00
Merge remote-tracking branch 'pogodevorg/develop' into aiopogo-login
Jul 21, 2017
fdd26d1
update to version 0.69.1
Aug 3, 2017
9d1074c
Ported request ID fix from Node.js pogobuf
sLoPPydrive Aug 12, 2017
e93add8
Update README.md and move license to .md (#1)
FrostTheFox Aug 12, 2017
ea5929d
yapf
sebastienvercammen Aug 13, 2017
8c76dfa
Fix request ID gen + per-instance vars.
sebastienvercammen Aug 13, 2017
1051727
update setup.py (#2)
FrostTheFox Aug 13, 2017
7c77e39
Update Travis.
sebastienvercammen Aug 13, 2017
01bf8b7
Update fields & behavior to aiopogo. (#3)
sebastienvercammen Aug 13, 2017
71cb419
Disable Travis success emails. (#4)
sebastienvercammen Aug 13, 2017
1d9105b
Merge remote-tracking branch 'sLoPPydrive/REQUEST_ID_FIX' into reques…
Aug 13, 2017
f4fb6f8
Merge remote-tracking branch 'sebastienvercammen/develop' into seb
Aug 14, 2017
488c133
fix merge mistake
Aug 14, 2017
32ee519
Fix start time range. (#6)
sebastienvercammen Aug 14, 2017
ae5b73e
Fix start time range. (#6)
sebastienvercammen Aug 14, 2017
eaa9d51
Fix headers in RPC requests.
sebastienvercammen Aug 19, 2017
8e7a088
update rpc headers
Aug 19, 2017
252bdb8
Merge remote-tracking branch 'seb/headers' into seb
Aug 19, 2017
ae23eef
adapt latest changes from ZeChrales
Aug 22, 2017
7ee0781
Update login headers.
sebastienvercammen Aug 22, 2017
50202aa
Add missing profile request.
sebastienvercammen Aug 22, 2017
b1b1215
Always consume or release response on login.
sebastienvercammen Aug 22, 2017
4185961
Remove Accept RPC header.
sebastienvercammen Aug 22, 2017
6c56539
update headers
Aug 23, 2017
055b2d3
move locale param
Aug 23, 2017
58319c7
Fix RPC headers.
sebastienvercammen Aug 25, 2017
1d14c64
Merge remote-tracking branch 'seb/headers' into seb
Aug 25, 2017
e8bb81e
Fix pgoapi requests. (#7)
sebastienvercammen Aug 25, 2017
0c155ea
restore protos before yapf
Sep 6, 2017
386f2a1
update protos
Sep 6, 2017
2863a53
update to version 0.73.1
Sep 6, 2017
c1b940d
add missing request types
Sep 7, 2017
f09d01f
Merge remote-tracking branch 'pogodevorg/develop' into proto-update
Sep 7, 2017
2714019
0.73.1 (#8)
sebastienvercammen Sep 7, 2017
5915f08
Merge remote-tracking branch 'seb/develop' into proto-update
Sep 8, 2017
b17b28d
update to version 0.75.0
Sep 25, 2017
2a5963a
update to version 0.75.1
Oct 5, 2017
8a9c543
update to version 0.77.1
Oct 13, 2017
df336c3
update to version 0.79.3
Oct 19, 2017
3550be4
Merge remote-tracking branch 'pogodevorg/develop' into proto-update
Nov 10, 2017
d304515
update to v0.83.0/2
michikrug Nov 30, 2017
a0955ae
update unity version header
Dec 3, 2017
3cbebd5
Protos Update
SkOODaT Dec 6, 2017
857fc13
update ptc login
Dec 6, 2017
5909155
forward exception
Dec 6, 2017
4ff4359
update to version 0.85.2
Dec 7, 2017
bfe598b
fix service parameter
Dec 7, 2017
45c374a
Merge remote-tracking branch 'refs/remotes/michikrug/update-ptc-login…
SkOODaT Dec 7, 2017
58ef5dc
0.85.x Weather Protos
SkOODaT Dec 10, 2017
12c2b7b
0.85.X Full Update
SkOODaT Dec 14, 2017
ca2d79c
update protos (IMPORTANT: GET_INVENTORY -> GET_HOLO_INVENTORY)
Dec 14, 2017
4e84fd4
add/update protos, add locale parameter, update auth class, update PT…
Dec 17, 2017
04af5a9
remove plat_eight protos
Dec 17, 2017
6c7c189
update headers
Dec 21, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
sudo: false
language: python

notifications:
email:
on_success: never
on_failure: always
cache:
pip: true
directories:
- node_modules
python:
- "2.7"
- "3.5"
- "3.6"

install:
- pip install -r requirements.txt
- python setup.py install

script:
- python -c 'import pgoapi'
File renamed without changes.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ It allows automatic parsing of requests/responses by finding the correct protobu
* Thread-safety
* Advanced logging/debugging
* Uses [POGOProtos](https://github.com/AeonLucid/POGOProtos)
* Mostly all available RPC calls (see [API reference](https://docs.pogodev.org) on the wiki)

## Documentation
Documentation is available at the github [pgoapi wiki](https://wiki.pogodev.org).

## Requirements
* Python 2 or 3
Expand All @@ -34,20 +30,20 @@ Documentation is available at the github [pgoapi wiki](https://wiki.pogodev.org)
## Use
To use this api as part of a python project using setuptools/pip, modify your requirements.txt file to include:
```
git+https://github.com/pogodevorg/pgoapi.git@develop#egg=pgoapi
git+https://github.com/sebastienvercammen/pgoapi.git@develop#egg=pgoapi
```

If you are not using setuptools/pip, follow the instructions in the Contributing section below to clone this repository and then install pgoapi using the appropriate method for your project.

## Contributing
Contributions are highly welcome. Please use github or [Discord](https://discord.pogodev.org) for it!
Contributions are highly welcome. Please use github or [Discord](https://discord.gg/rocketmap) for it!

You can get started by cloning this repository. Note that as pgoapi uses [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) you must perform a recursive clone:

| Protocol | Command |
| -------- | ------- |
| HTTPS | `git clone --recursive https://github.com/pogodevorg/pgoapi.git` |
| SSH | `git clone --recursive [email protected]:pogodevorg/pgoapi.git` |
| HTTPS | `git clone --recursive https://github.com/sebastienvercammen/pgoapi.git` |
| SSH | `git clone --recursive [email protected]:sebastienvercammen/pgoapi.git` |

If you already have a copy of the repository you can use `git submodule update --init` to fetch and update the submodules.

Expand Down
72 changes: 53 additions & 19 deletions examples/pogo-optimizer/pogo-optimizer-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,40 @@

log = logging.getLogger(__name__)


def encode(cellid):
output = []
encoder._VarintEncoder()(output.append, cellid)
return ''.join(output)


def init_config():
parser = argparse.ArgumentParser()
config_file = "config.json"

# If config file exists, load variables from json
load = {}
load = {}
if os.path.isfile(config_file):
with open(config_file) as data:
load.update(json.load(data))

# Read passed in Arguments
required = lambda x: not x in load
parser.add_argument("-a", "--auth_service", help="Auth Service ('ptc' or 'google')",
parser.add_argument(
"-a",
"--auth_service",
help="Auth Service ('ptc' or 'google')",
required=required("auth_service"))
parser.add_argument("-u", "--username", help="Username", required=required("username"))
parser.add_argument(
"-u", "--username", help="Username", required=required("username"))
parser.add_argument("-p", "--password", help="Password")
parser.add_argument("-d", "--debug", help="Debug Mode", action='store_true')
parser.add_argument("-t", "--test", help="Only parse the specified location", action='store_true')
parser.add_argument(
"-d", "--debug", help="Debug Mode", action='store_true')
parser.add_argument(
"-t",
"--test",
help="Only parse the specified location",
action='store_true')
parser.set_defaults(DEBUG=False, TEST=False)
config = parser.parse_args()

Expand All @@ -82,19 +93,24 @@ def init_config():
config.__dict__[key] = str(load[key])

if config.__dict__["password"] is None:
log.info("Secure Password Input (if there is no password prompt, use --password <pw>):")
log.info(
"Secure Password Input (if there is no password prompt, use --password <pw>):"
)
config.__dict__["password"] = getpass.getpass()

if config.auth_service not in ['ptc', 'google']:
log.error("Invalid Auth service specified! ('ptc' or 'google')")
return None
log.error("Invalid Auth service specified! ('ptc' or 'google')")
return None

return config


def main():
# log settings
# log format
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
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
Expand Down Expand Up @@ -137,21 +153,39 @@ def main():

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']
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 = 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"))
print(tabulate(all_pokemon, headers="keys"))


if __name__ == '__main__':
main()
87 changes: 61 additions & 26 deletions examples/spiral_poi_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,21 @@

log = logging.getLogger(__name__)


def get_pos_by_name(location_name):
geolocator = GoogleV3()
loc = geolocator.geocode(location_name)
if not loc:
return None

log.info('Your given location: %s', loc.address.encode('utf-8'))
log.info('lat/long/alt: %s %s %s', loc.latitude, loc.longitude, loc.altitude)
log.info('lat/long/alt: %s %s %s', loc.latitude, loc.longitude,
loc.altitude)

return (loc.latitude, loc.longitude, loc.altitude)

def get_cell_ids(lat, long, radius = 10):

def get_cell_ids(lat, long, radius=10):
origin = CellId.from_lat_lng(LatLng.from_degrees(lat, long)).parent(15)
walk = [origin.id()]
right = origin.next()
Expand All @@ -73,30 +76,43 @@ def get_cell_ids(lat, long, radius = 10):
# Return everything
return sorted(walk)


def encode(cellid):
output = []
encoder._VarintEncoder()(output.append, cellid)
return ''.join(output)


def init_config():
parser = argparse.ArgumentParser()
config_file = "config.json"

# If config file exists, load variables from json
load = {}
load = {}
if os.path.isfile(config_file):
with open(config_file) as data:
load.update(json.load(data))

# Read passed in Arguments
required = lambda x: x not in load
parser.add_argument("-a", "--auth_service", help="Auth Service ('ptc' or 'google')",
parser.add_argument(
"-a",
"--auth_service",
help="Auth Service ('ptc' or 'google')",
required=required("auth_service"))
parser.add_argument("-u", "--username", help="Username", required=required("username"))
parser.add_argument("-p", "--password", help="Password", required=required("password"))
parser.add_argument("-l", "--location", help="Location", required=required("location"))
parser.add_argument("-d", "--debug", help="Debug Mode", action='store_true')
parser.add_argument("-t", "--test", help="Only parse the specified location", action='store_true')
parser.add_argument(
"-u", "--username", help="Username", required=required("username"))
parser.add_argument(
"-p", "--password", help="Password", required=required("password"))
parser.add_argument(
"-l", "--location", help="Location", required=required("location"))
parser.add_argument(
"-d", "--debug", help="Debug Mode", action='store_true')
parser.add_argument(
"-t",
"--test",
help="Only parse the specified location",
action='store_true')
parser.set_defaults(DEBUG=False, TEST=False)
config = parser.parse_args()

Expand All @@ -106,15 +122,18 @@ def init_config():
config.__dict__[key] = load[key]

if config.auth_service not in ['ptc', 'google']:
log.error("Invalid Auth service specified! ('ptc' or 'google')")
return None
log.error("Invalid Auth service specified! ('ptc' or 'google')")
return None

return config


def main():
# log settings
# log format
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')
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
Expand All @@ -134,7 +153,7 @@ def main():
position = get_pos_by_name(config.location)
if not position:
return

if config.test:
return

Expand All @@ -153,11 +172,13 @@ def main():
# ----------------------
response_dict = api.get_player()

# apparently new dict has binary data in it, so formatting it with this method no longer works, pprint works here but there are other alternatives
# apparently new dict has binary data in it, so formatting it with this method no longer works, pprint works here but there are other alternatives
# print('Response dictionary: \n\r{}'.format(json.dumps(response_dict, indent=2)))
print('Response dictionary: \n\r{}'.format(pprint.PrettyPrinter(indent=4).pformat(response_dict)))
print('Response dictionary: \n\r{}'.format(
pprint.PrettyPrinter(indent=4).pformat(response_dict)))
find_poi(api, position[0], position[1])


def find_poi(api, lat, lng):
poi = {'pokemons': {}, 'forts': []}
step_size = 0.0015
Expand All @@ -168,41 +189,54 @@ def find_poi(api, lat, lng):
lng = coord['lng']
api.set_position(lat, lng, 0)


#get_cellid was buggy -> replaced through get_cell_ids from pokecli
#timestamp gets computed a different way:
cell_ids = get_cell_ids(lat, lng)
timestamps = [0,] * len(cell_ids)
response_dict = api.get_map_objects(latitude = util.f2i(lat), longitude = util.f2i(lng), since_timestamp_ms = timestamps, cell_id = cell_ids)
timestamps = [
0,
] * len(cell_ids)
response_dict = api.get_map_objects(
latitude=util.f2i(lat),
longitude=util.f2i(lng),
since_timestamp_ms=timestamps,
cell_id=cell_ids)
if (response_dict['responses']):
if 'status' in response_dict['responses']['GET_MAP_OBJECTS']:
if response_dict['responses']['GET_MAP_OBJECTS']['status'] == 1:
for map_cell in response_dict['responses']['GET_MAP_OBJECTS']['map_cells']:
if response_dict['responses']['GET_MAP_OBJECTS'][
'status'] == 1:
for map_cell in response_dict['responses'][
'GET_MAP_OBJECTS']['map_cells']:
if 'wild_pokemons' in map_cell:
for pokemon in map_cell['wild_pokemons']:
pokekey = get_key_from_pokemon(pokemon)
pokemon['hides_at'] = time.time() + pokemon['time_till_hidden_ms']/1000
pokemon['hides_at'] = time.time(
) + pokemon['time_till_hidden_ms'] / 1000
poi['pokemons'][pokekey] = pokemon

# time.sleep(0.51)
# new dict, binary data
# print('POI dictionary: \n\r{}'.format(json.dumps(poi, indent=2)))
print('POI dictionary: \n\r{}'.format(pprint.PrettyPrinter(indent=4).pformat(poi)))
# new dict, binary data
# print('POI dictionary: \n\r{}'.format(json.dumps(poi, indent=2)))
print('POI dictionary: \n\r{}'.format(
pprint.PrettyPrinter(indent=4).pformat(poi)))
print('Open this in a browser to see the path the spiral search took:')
print_gmaps_dbug(coords)


def get_key_from_pokemon(pokemon):
return '{}-{}'.format(pokemon['spawn_point_id'], pokemon['pokemon_data']['pokemon_id'])
return '{}-{}'.format(pokemon['spawn_point_id'],
pokemon['pokemon_data']['pokemon_id'])


def print_gmaps_dbug(coords):
url_string = 'http://maps.googleapis.com/maps/api/staticmap?size=400x400&path='
for coord in coords:
url_string += '{},{}|'.format(coord['lat'], coord['lng'])
print(url_string[:-1])


def generate_spiral(starting_lat, starting_lng, step_size, step_limit):
coords = [{'lat': starting_lat, 'lng': starting_lng}]
steps,x,y,d,m = 1, 0, 0, 1, 1
steps, x, y, d, m = 1, 0, 0, 1, 1
rlow = 0.0
rhigh = 0.0005

Expand All @@ -224,5 +258,6 @@ def generate_spiral(starting_lat, starting_lng, step_size, step_limit):
m = m + 1
return coords


if __name__ == '__main__':
main()
Loading