From 28e6784fa237eabecfc4f4b378fca4236bd6f602 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Sat, 16 Nov 2013 20:13:35 +0100 Subject: [PATCH 1/6] config: bump chrome version in user-agent --- fut14/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fut14/config.py b/fut14/config.py index 2c891c9..9267559 100644 --- a/fut14/config.py +++ b/fut14/config.py @@ -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', From 3e23052fcb6ef1ca60346815e6f84392ca53db0d Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Sat, 16 Nov 2013 20:24:43 +0100 Subject: [PATCH 2/6] core: add assetId param to searchAuction method --- fut14/core.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fut14/core.py b/fut14/core.py index 8bdb9b5..ab17777 100644 --- a/fut14/core.py +++ b/fut14/core.py @@ -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 @@ -220,10 +220,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: @@ -237,6 +237,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 From a09c77e3df2ab36a18a488b265e975535d246d0b Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Mon, 23 Dec 2013 21:32:08 +0100 Subject: [PATCH 3/6] core: add pileSize --- .gitignore | 1 + README.rst | 4 ++++ fut14/core.py | 11 +++++++++++ 3 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index 78d4e7b..afb5add 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ fut14.egg-info/ test.py log.log content.log +error.log diff --git a/README.rst b/README.rst index 117c18d..5d1374b 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/fut14/core.py b/fut14/core.py index ab17777..65530de 100644 --- a/fut14/core.py +++ b/fut14/core.py @@ -90,6 +90,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 @@ -176,6 +177,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.""" @@ -317,3 +322,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']} From 1c4083f2d5b45c6cec46caec8e6cc7e3b4899a11 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Mon, 23 Dec 2013 21:40:04 +0100 Subject: [PATCH 4/6] core: add leagueId to item data parser --- fut14/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fut14/core.py b/fut14/core.py index 65530de..848c4cb 100644 --- a/fut14/core.py +++ b/fut14/core.py @@ -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'], From a6f720a9b7d4ce4b26afebd0a3431f729332f082 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Mon, 23 Dec 2013 21:44:16 +0100 Subject: [PATCH 5/6] temporary mask requests-2.1.0 due to incompatibility (bug?) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 179108f..1b3fd0d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -requests>=1.0.0 +requests>=1.0.0,<2.1.0 xmltodict From c1738190945cd16f115ed1668e010db86ae86dbf Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Mon, 23 Dec 2013 21:47:11 +0100 Subject: [PATCH 6/6] v0.0.5 --- fut14/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fut14/__init__.py b/fut14/__init__.py index aeb1085..6302e1e 100644 --- a/fut14/__init__.py +++ b/fut14/__init__.py @@ -18,7 +18,7 @@ """ __title__ = 'fut14' -__version__ = '0.0.4' +__version__ = '0.0.5' __author__ = 'Piotr Staroszczyk' __author_email__ = 'piotr.staroszczyk@get24.org' __license__ = 'GNU GPL v3' diff --git a/setup.py b/setup.py index 992ca50..d9c04bb 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ __title__ = 'fut14' -__version__ = '0.0.4' +__version__ = '0.0.5' __author__ = 'Piotr Staroszczyk' __author_email__ = 'piotr.staroszczyk@get24.org' __license__ = 'GNU GPL v3'