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 Dec 23, 2013
2 parents d26e00a + c173819 commit 9c81c79
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ fut14.egg-info/
test.py
log.log
content.log
error.log
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Usage
>>> fut.credits # it's updated automatically on every request
0
>>> fut.tradepile_size
80
>>> fut.watchlist_size
30
>>> items = fut.tradepile() # get all items from trade pile
>>> items = fut.unassigned() # get all unassigned items
Expand Down
2 changes: 1 addition & 1 deletion fut14/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""

__title__ = 'fut14'
__version__ = '0.0.4'
__version__ = '0.0.5'
__author__ = 'Piotr Staroszczyk'
__author_email__ = '[email protected]'
__license__ = 'GNU GPL v3'
Expand Down
2 changes: 1 addition & 1 deletion fut14/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8',
Expand Down
23 changes: 18 additions & 5 deletions fut14/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


def baseId(resource_id, version=False):
"""Calculates base id."""
"""Calculates base id (assetId?)."""
v = 0
if resource_id > 1358954496:
resource_id -= 1342177280
Expand Down Expand Up @@ -54,6 +54,7 @@ def itemParse(item_data):
'itemState': item_data['itemData']['itemState'],
'rareflag': item_data['itemData']['rareflag'],
'formation': item_data['itemData']['formation'],
'leagueId': item_data['itemData']['leagueId'],
'injuryType': item_data['itemData']['injuryType'],
'injuryGames': item_data['itemData']['injuryGames'],
'lastSalePrice': item_data['itemData']['lastSalePrice'],
Expand Down Expand Up @@ -90,6 +91,7 @@ def __init__(self, email, passwd, secret_answer):

def __login__(self, email, passwd, secret_answer_hash):
"""Just log in."""
# TODO: split into smaller methods
# === login
urls['login'] = self.r.get(urls['fut_home']).url
self.r.headers['Referer'] = urls['main_site'] # prepare headers
Expand Down Expand Up @@ -176,6 +178,10 @@ def __login__(self, email, passwd, secret_answer_hash):
# get basic user info
# TODO: parse response (https://gist.github.com/oczkers/526577572c097eb8172f)
self.__get__(urls['fut']['user'])
# size of piles
piles = self.pileSize()
self.tradepile_size = piles['tradepile']
self.watchlist_size = piles['watchlist']

# def __shards__(self):
# """Returns shards info."""
Expand Down Expand Up @@ -220,10 +226,10 @@ def cardInfo(self, *args, **kwargs):
"""Alias for cardInfo."""
return cardInfo(*args, **kwargs)

def searchAuctions(self, ctype, level=None, category=None, min_price=None,
max_price=None, min_buy=None, max_buy=None, league=None,
club=None, position=None, nationality=None, playStyle=None,
start=0, page_size=16):
def searchAuctions(self, ctype, level=None, category=None, assetId=None,
min_price=None, max_price=None, min_buy=None, max_buy=None,
league=None, club=None, position=None, nationality=None,
playStyle=None, start=0, page_size=16):
"""Search specific items on transfer market."""
# TODO: add "search" alias
if start > 0 and page_size == 16:
Expand All @@ -237,6 +243,7 @@ def searchAuctions(self, ctype, level=None, category=None, min_price=None,
}
if level: params['lev'] = level
if category: params['cat'] = category
if assetId: params['maskedDefId'] = assetId
if min_price: params['micr'] = min_price
if max_price: params['macr'] = max_price
if min_buy: params['minb'] = min_buy
Expand Down Expand Up @@ -316,3 +323,9 @@ def keepalive(self):
"""Just refresh credits ammount to let know that we're still online."""
self.__get__(urls['fut']['Credits'])
return True

def pileSize(self):
"""Returns size of tradepile and watchlist."""
rc = self.__get__(urls['fut']['PileSize'])['entries']
return {'tradepile': rc[0]['value'],
'watchlist': rc[2]['value']}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests>=1.0.0
requests>=1.0.0,<2.1.0
xmltodict
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


__title__ = 'fut14'
__version__ = '0.0.4'
__version__ = '0.0.5'
__author__ = 'Piotr Staroszczyk'
__author_email__ = '[email protected]'
__license__ = 'GNU GPL v3'
Expand Down

0 comments on commit 9c81c79

Please sign in to comment.