diff --git a/README.md b/README.md index 316c1d01..274cb765 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,9 @@ Documentation is available at the [pgoapi wiki](https://wiki.pogodev.org). * Python ≥3.5 * aiohttp * protobuf (≥3) - * pycrypt - * cyrandom + * [pycrypt](https://github.com/Noctem/pycrypt) + * [cyrandom](https://github.com/Noctem/cyrandom) + * [pogeo](https://github.com/Noctem/pogeo) ##### Optional Packages * *gpsoauth*: required for Google accounts diff --git a/aiopogo/__init__.py b/aiopogo/__init__.py index 66879514..8d6931b3 100755 --- a/aiopogo/__init__.py +++ b/aiopogo/__init__.py @@ -1,5 +1,5 @@ __title__ = 'aiopogo' -__version__ = '2.0.1' +__version__ = '2.1.0b0' __author__ = 'David Christenson' __license__ = 'MIT License' __copyright__ = 'Copyright (c) 2017 David Christenson ' diff --git a/aiopogo/pgoapi.py b/aiopogo/pgoapi.py index 6c64fa96..996dcefb 100755 --- a/aiopogo/pgoapi.py +++ b/aiopogo/pgoapi.py @@ -1,7 +1,8 @@ from logging import getLogger -from yarl import URL from aiohttp import BasicAuth +from pogeo import Location +from yarl import URL try: from aiosocks import Socks4Auth, Socks5Auth except ImportError: @@ -24,16 +25,12 @@ class PGoApi: log = getLogger(__name__) log.info('%s v%s', __title__, __version__) - def __init__(self, lat=None, lon=None, alt=None, proxy=None, device_info=None): + def __init__(self, proxy=None, device_info=None): self.auth_provider = None self.state = RpcState() self._api_endpoint = 'https://pgorelease.nianticlabs.com/plfe/rpc' - self.latitude = lat - self.longitude = lon - self.altitude = alt - self.proxy_auth = None self.proxy = proxy self.device_info = device_info @@ -57,34 +54,23 @@ async def set_authentication(self, provider='ptc', username=None, password=None, await self.auth_provider.user_login(username, password) - def set_position(self, lat, lon, alt=None): - self.log.debug('Set Position - Lat: %s Lon: %s Alt: %s', lat, lon, alt) - self.latitude = lat - self.longitude = lon - self.altitude = alt + def set_position(self, lat, lon, alt=0.0): + """Deprecated position setter, setting directly is recommended""" + self.position = Location(lat, lon) + self.position[2] = alt def create_request(self): return PGoApiRequest(self) - @staticmethod - def activate_hash_server(hash_token, conn_limit=300): - HashServer.set_token(hash_token) - HashServer.activate_session(conn_limit) - - @property - def position(self): - return self.latitude, self.longitude, self.altitude - @property def api_endpoint(self): return self._api_endpoint @api_endpoint.setter def api_endpoint(self, api_url): - if api_url.startswith("https"): - self._api_endpoint = URL(api_url) - else: - self._api_endpoint = URL('https://' + api_url + '/rpc') + self._api_endpoint = (URL(api_url) + if api_url.startswith("https") + else URL('https://' + api_url + '/rpc')) @property def proxy(self): @@ -136,10 +122,9 @@ def __init__(self, parent): async def call(self): parent = self.__parent__ auth_provider = parent.auth_provider - position = parent.position try: - assert position[0] is not None and position[1] is not None - except AssertionError: + position = parent.position + except AttributeError: raise NoPlayerPositionSetException('No position set.') request = RpcApi(auth_provider, parent.state) diff --git a/aiopogo/rpc_api.py b/aiopogo/rpc_api.py index b47308f3..5a883990 100755 --- a/aiopogo/rpc_api.py +++ b/aiopogo/rpc_api.py @@ -145,7 +145,7 @@ async def _build_main_request(self, subrequests, player_position, device_info=No loc.latitude = request.latitude loc.longitude = request.longitude - loc.altitude = altitude or uniform(150, 250) + loc.altitude = altitude or uniform(390.0, 490.0) if random() > .85: # no reading for roughly 1 in 7 updates diff --git a/requirements.txt b/requirements.txt index da531d2e..b5cac444 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ aiohttp>=2.0.7,<2.2 pycrypt>=0.7.0 cyrandom>=0.1.2 yarl>=0.10.0 +pogeo>=0.4b0 diff --git a/setup.py b/setup.py index 055fb6d3..b8a54ca9 100755 --- a/setup.py +++ b/setup.py @@ -6,14 +6,15 @@ author='David Christenson', author_email='mail@noctem.xyz', description='Asynchronous Pokemon API lib', - version='2.0.1', + version='2.1.0b0', url='https://github.com/Noctem/aiopogo', packages=find_packages(), install_requires=[ 'protobuf>=3.0.0', 'aiohttp>=2.0.7,<2.2', 'pycrypt>=0.7.0', - 'cyrandom>=0.1.2'], + 'cyrandom>=0.1.2', + 'pogeo>=0.4b0'], extras_require={ 'performance': ['ujson>=1.3.5', 'cchardet>=2.1.0', 'aiodns>=1.1.1'], 'socks': ['aiosocks>=0.2.2'],