Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
oczkers committed Apr 28, 2017
2 parents bb62558 + ef44c81 commit ac54357
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 27 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ Changelog
---------


0.2.12 (2017-04-28)
^^^^^^^^^^^^^^^^^^^

* proper #255 fix - from now we're going to read whole players db on login

0.2.10 (2017-04-24)
^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^

* fix baseId calculation (#255)

Expand Down
2 changes: 1 addition & 1 deletion fut/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""

__title__ = 'fut'
__version__ = '0.2.10'
__version__ = '0.2.12'
__author__ = 'Piotr Staroszczyk'
__author_email__ = 'piotr.staroszczyk@get24.org'
__license__ = 'GNU GPL v3'
Expand Down
16 changes: 15 additions & 1 deletion fut/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def baseId(resource_id, return_version=False):
while resource_id > 0x01000000: # 16777216
version += 1
if version == 1:
resource_id -= 0x80000000 # 2147483648
resource_id -= 0x80000000 # 2147483648 # 0x50000000 # 1342177280 ? || 0x2000000 # 33554432
elif version == 2:
resource_id -= 0x03000000 # 50331648
else:
Expand Down Expand Up @@ -168,6 +168,7 @@ def __init__(self, email, passwd, secret_answer, platform='pc', code=None, emula
self.logger = logger()
# TODO: validate fut request response (200 OK)
self.__login__(email, passwd, secret_answer, platform, code, emulate)
self.db_players = self.db()

def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emulate=None):
"""Log in.
Expand Down Expand Up @@ -518,6 +519,16 @@ def __sendToPile__(self, pile, trade_id, item_id=None):
self.logger.error("{0} (itemId: {1}) NOT MOVED to {2} Pile. REASON: {3}".format(trade_id, item_id, pile, rc['itemData'][0]['reason']))
return rc['itemData'][0]['success']

def db(self):
"""Return full database (only players for now)."""
rc = self.r.get('{0}{1}.json'.format(self.urls['card_info'], 'players')).json()
db = {}
for i in rc['Players']:
db[i['id']] = i
for i in rc['LegendsPlayers']:
db[i['id']] = i
return db

def logout(self, save=True):
"""Log out nicely (like clicking on logout button).
Expand Down Expand Up @@ -568,8 +579,11 @@ def cardInfo(self, resource_id):
:params resource_id: Resource id.
"""
# TODO: add referer to headers (futweb)
return self.db_players[baseId(resource_id)]
'''
url = '{0}{1}.json'.format(self.urls['card_info'], baseId(resource_id))
return requests.get(url, timeout=self.timeout).json()
'''

def searchDefinition(self, asset_id, start=0, count=35):
"""Return variations of the given asset id, e.g. IF cards.
Expand Down
48 changes: 24 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


__title__ = 'fut'
__version__ = '0.2.10'
__version__ = '0.2.12'
__author__ = 'Piotr Staroszczyk'
__author_email__ = 'piotr.staroszczyk@get24.org'
__license__ = 'GNU GPL v3'
Expand Down Expand Up @@ -44,29 +44,29 @@
install_requires=requires,
# license=open('LICENSE').read(),
license=__license__,
classifiers=(
'Development Status :: 3 - Alpha',
# 'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Natural Language :: English',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
# 'Programming Language :: Python :: 3.0', # not tested
# 'Programming Language :: Python :: 3.1', # not tested
# 'Programming Language :: Python :: 3.2', # dropped due requests incomapitibility
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
# 'Programming Language :: Python :: Implementation :: IronPython', # not tested
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Internet :: WWW/HTTP :: Site Management',
'Topic :: Software Development :: Libraries :: Python Modules',
),
# classifiers=(
# 'Development Status :: 3 - Alpha',
# # 'Development Status :: 4 - Beta',
# 'Intended Audience :: Developers',
# 'Natural Language :: English',
# 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
# 'Programming Language :: Python',
# 'Programming Language :: Python :: 2.6',
# 'Programming Language :: Python :: 2.7',
# 'Programming Language :: Python :: 3',
# # 'Programming Language :: Python :: 3.0', # not tested
# # 'Programming Language :: Python :: 3.1', # not tested
# # 'Programming Language :: Python :: 3.2', # dropped due requests incomapitibility
# 'Programming Language :: Python :: 3.3',
# 'Programming Language :: Python :: 3.4',
# 'Programming Language :: Python :: 3.5',
# 'Programming Language :: Python :: 3.6',
# 'Programming Language :: Python :: Implementation :: CPython',
# # 'Programming Language :: Python :: Implementation :: IronPython', # not tested
# 'Programming Language :: Python :: Implementation :: PyPy',
# 'Topic :: Internet :: WWW/HTTP :: Site Management',
# 'Topic :: Software Development :: Libraries :: Python Modules',
# ),
# entry_points={
# 'console_scripts': [
# 'fut = fut.cli:main',
Expand Down

0 comments on commit ac54357

Please sign in to comment.