From b94643080619f431a20bbfee6d1dbba58879722d Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Fri, 20 Feb 2015 13:33:48 +0100 Subject: [PATCH 01/10] core: update credits only on demand --- CHANGELOG.rst | 1 + fut/core.py | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a602af3..9517a2b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ Changelog 0.0.23 (2015-02-11) ++++++++++++++++++ * core: fix #135 type conversion in quickSell & watchlistDelete +* core: rename parameter squad_num to squad_id 0.0.23 (2015-02-09) ++++++++++++++++++ diff --git a/fut/core.py b/fut/core.py index 8609370..3f8d1e1 100644 --- a/fut/core.py +++ b/fut/core.py @@ -111,7 +111,6 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul # TODO: split into smaller methods # TODO: check first if login is needed (https://www.easports.com/fifa/api/isUserLoggedIn) secret_answer_hash = EAHashingAlgorithm().EAHash(secret_answer) - self.credits = 0 # create session self.r = requests.Session() # init/reset requests session object # load saved cookies/session @@ -316,7 +315,6 @@ def __request__(self, method, url, *args, **kwargs): if not rc.ok: # status != 200 raise UnknownError(rc.content) if rc.text == '': - self.keepalive() # credits not avaible in response, manualy updating rc = {} else: captcha_token = rc.headers.get('Proxy-Authorization', '').replace('captcha=', '') # captcha token (always AAAA ?) @@ -339,11 +337,6 @@ def __request__(self, method, url, *args, **kwargs): raise FeatureDisabled else: raise UnknownError(rc.__str__()) - # update credits - if 'credits' not in rc: - self.keepalive() # credits not avaible in response, manualy updating - else: - self.credits = rc['credits'] self.saveSession() return rc @@ -393,6 +386,11 @@ def logout(self, save=True): self.saveSession() return True + @property + def credits(self): + """Returns credit amount.""" + return self.__get__(self.urls['fut']['Credits'])['credits'] + def saveSession(self): '''Saves cookies/session.''' if self.cookies_file: @@ -576,7 +574,7 @@ def relist(self, clean=False): def keepalive(self): """Just refresh credit amount to let know that we're still online. Returns credit amount.""" - return self.__get__(self.urls['fut']['Credits']) + return self.credits def pileSize(self): """Returns size of tradepile and watchlist.""" From 92fca59a8c8b801cff17e10aa6b6528c0cc80e57 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Fri, 20 Feb 2015 13:34:29 +0100 Subject: [PATCH 02/10] changelog --- CHANGELOG.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9517a2b..9873854 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,10 @@ Changelog --------- +0.0.24 (????-??-??) +++++++++++++++++++ +# core: update credits only on demand + 0.0.23 (2015-02-11) ++++++++++++++++++ * core: fix #135 type conversion in quickSell & watchlistDelete From badf242b7b31c55152d85252c6cba30c819e8ec0 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Fri, 20 Feb 2015 13:35:04 +0100 Subject: [PATCH 03/10] changelog --- CHANGELOG.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9873854..52bc5b7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,11 +4,11 @@ Changelog --------- -0.0.24 (????-??-??) +0.0.25 (????-??-??) ++++++++++++++++++ # core: update credits only on demand -0.0.23 (2015-02-11) +0.0.24 (2015-02-11) ++++++++++++++++++ * core: fix #135 type conversion in quickSell & watchlistDelete * core: rename parameter squad_num to squad_id From f8d6295e0b8c07eef50d297af9ea069a01a57ffe Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Fri, 20 Feb 2015 13:35:29 +0100 Subject: [PATCH 04/10] changelog --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 52bc5b7..f7baccf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,7 +6,7 @@ Changelog 0.0.25 (????-??-??) ++++++++++++++++++ -# core: update credits only on demand +* core: update credits only on demand 0.0.24 (2015-02-11) ++++++++++++++++++ From 18ed74f40f5a056bbabfef3b2d055b34b54920b9 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Wed, 16 Sep 2015 09:16:01 +0200 Subject: [PATCH 05/10] update user agent, changelog, version --- CHANGELOG.rst | 4 +++- fut/__init__.py | 2 +- fut/config.py | 4 ++-- setup.py | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f7baccf..10cd428 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,9 +4,11 @@ Changelog --------- -0.0.25 (????-??-??) +0.1.0 (2015-09-1?) ++++++++++++++++++ +* fifa 16 * core: update credits only on demand +* config: update user-agent (chrome 45 @ win10) 0.0.24 (2015-02-11) ++++++++++++++++++ diff --git a/fut/__init__.py b/fut/__init__.py index 0c5f8c2..3aa71d5 100644 --- a/fut/__init__.py +++ b/fut/__init__.py @@ -18,7 +18,7 @@ """ __title__ = 'fut' -__version__ = '0.0.24' +__version__ = '0.1.0' __author__ = 'Piotr Staroszczyk' __author_email__ = 'piotr.staroszczyk@get24.org' __license__ = 'GNU GPL v3' diff --git a/fut/config.py b/fut/config.py index 427ea9f..851a3f7 100644 --- a/fut/config.py +++ b/fut/config.py @@ -1,6 +1,6 @@ -# chrome 33 +# chrome 45 @ win10 headers = { - 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 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', diff --git a/setup.py b/setup.py index 362ddaf..a94676a 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ __title__ = 'fut' -__version__ = '0.0.24' +__version__ = '0.1.0' __author__ = 'Piotr Staroszczyk' __author_email__ = 'piotr.staroszczyk@get24.org' __license__ = 'GNU GPL v3' @@ -58,6 +58,7 @@ # 'Programming Language :: Python :: 3.1', # not tested 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', + # 'Programming Language :: Python :: 3.4', # not tested # 'Programming Language :: Python :: Implementation :: CPython', # not tested # 'Programming Language :: Python :: Implementation :: IronPython', # not tested 'Programming Language :: Python :: Implementation :: PyPy', From 9e2a059acccfbfabfcf111f7c67d11e7ef53c2a3 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Wed, 16 Sep 2015 11:14:46 +0200 Subject: [PATCH 06/10] fifa 16 --- fut/core.py | 24 ++++++++++++++---------- fut/urls.py | 22 +++++++++++----------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/fut/core.py b/fut/core.py index 3f8d1e1..9fd4971 100644 --- a/fut/core.py +++ b/fut/core.py @@ -133,23 +133,23 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul # return True # no need to log in again # emulate if emulate == 'ios': - sku = 'FUT15IOS' + sku = 'FUT16IOS' clientVersion = 11 elif emulate == 'and': - sku = 'FUT15AND' + sku = 'FUT16AND' clientVersion = 11 # TODO: need more info about log in procedure in game # elif emulate == 'xbox': -# sku = 'FFA15XBX' # FFA14CAP ? +# sku = 'FFA16XBX' # FFA14CAP ? # clientVersion = 1 # elif emulate == 'ps3': -# sku = 'FFA15PS3' # FFA14KTL ? +# sku = 'FFA16PS3' # FFA14KTL ? # clientVersion = 1 # elif emulate == 'pc': # sku = '' # dunno # clientVersion = 1 elif not emulate: - sku = 'FUT15WEB' + sku = 'FUT16WEB' clientVersion = 1 else: raise FutError('Invalid emulate parameter. (Valid ones are and/ios).') # pc/ps3/xbox/ @@ -160,8 +160,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul 'password': passwd, '_rememberMe': 'on', 'rememberMe': 'on', - '_eventId': 'submit', - 'facebookAuth': ''} + '_eventId': 'submit'} rc = self.r.post(self.urls['login'], data=data) self.logger.debug(rc.content) @@ -178,11 +177,16 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul if not code: self.saveSession() raise FutError('Error during login process - code is required.') - self.r.headers['Referer'] = rc.url - rc = self.r.post(rc.url, {'twoFactorCode': code, '_eventId': 'submit'}).text + self.r.headers['Referer'] = url = rc.url + # self.r.headers['Upgrade-Insecure-Requests'] = 1 # ? + # self.r.headers['Origin'] = 'https://signin.ea.com' + rc = self.r.post(url, {'twofactorCode': code, '_trustThisDevice': 'on', 'trustThisDevice': 'on', '_eventId': 'submit'}).text if 'Incorrect code entered' in rc or 'Please enter a valid security code' in rc: raise FutError('Error during login process - provided code is incorrect.') self.logger.debug(rc) + if 'Set Up an App Authenticator' in rc: + rc = self.r.post(url.replace('s2', 's3'), {'_eventId': 'cancel', 'appDevice': 'IPHONE'}).text + self.logger.debug(rc) self.r.headers['Referer'] = self.urls['login'] if self.r.get(self.urls['main_site'] + '/fifa/api/isUserLoggedIn').json()['isLoggedIn'] is not True: # TODO: parse error? @@ -282,7 +286,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul del self.r.headers['X-UT-Route'] self.r.headers.update({ # 'X-HTTP-Method-Override': 'GET', # __request__ method manages this - 'Referer': 'https://www.easports.com/iframe/fut15/bundles/futweb/web/flash/FifaUltimateTeam.swf', + 'Referer': 'https://www.easports.com/iframe/fut16/bundles/futweb/web/flash/FifaUltimateTeam.swf', 'Origin': 'https://www.easports.com', # 'Content-Type': 'application/json', # already set 'Accept': 'application/json', diff --git a/fut/urls.py b/fut/urls.py index 4791e95..5b98393 100644 --- a/fut/urls.py +++ b/fut/urls.py @@ -11,8 +11,8 @@ def __updateUrls__(urls, cl): urls['fut_config'] = '%s?cl=%s' % (urls['fut_config'], cl) rc = xmltodict.parse(requests.get(urls['fut_config']).content) services = rc['main']['services']['prod'] - path = '{0}{1}game/fifa15/'.format(urls['fut_host'], rc['main']['directHttpServiceDestination']) - path_auth = '{0}/iframe/fut15{1}'.format(urls['main_site'], rc['main']['httpServiceDestination']) + path = '{0}{1}game/fifa16/'.format(urls['fut_host'], rc['main']['directHttpServiceDestination']) + path_auth = '{0}/iframe/fut16{1}'.format(urls['main_site'], rc['main']['httpServiceDestination']) for i in services: if i == 'authentication': urls['fut'][i] = path_auth + services[i] @@ -25,14 +25,14 @@ def urls(platform, cl=None): """Returns services urls.""" urls = { 'main_site': 'https://www.easports.com', - 'futweb': 'https://www.easports.com/iframe/fut15/?baseShowoffUrl=https%3A%2F%2Fwww.easports.com%2Ffifa%2Fultimate-team%2Fweb-app%2Fshow-off&guest_app_uri=http%3A%2F%2Fwww.easports.com%2Ffifa%2Fultimate-team%2Fweb-app&locale=en_US', - 'fut_config': 'https://www.easports.com/iframe/fut15/bundles/futweb/web/flash/xml/site_config.xml', # add timestamp + 'futweb': 'https://www.easports.com/iframe/fut16/?baseShowoffUrl=https%3A%2F%2Fwww.easports.com%2Ffifa%2Fultimate-team%2Fweb-app%2Fshow-off&guest_app_uri=http%3A%2F%2Fwww.easports.com%2Ffifa%2Fultimate-team%2Fweb-app&locale=en_US', + 'fut_config': 'https://www.easports.com/iframe/fut16/bundles/futweb/web/flash/xml/site_config.xml', # add timestamp 'fut_home': 'https://www.easports.com/uk/fifa/football-club/ultimate-team', 'fut': {}, # it's updated dynamicly (based on fut_config) - 'fut_question': 'https://www.easports.com/iframe/fut15/p/ut/game/fifa15/phishing/question', # add timestamp - 'fut_validate': 'https://www.easports.com/iframe/fut15/p/ut/game/fifa15/phishing/validate', - 'fut_captcha_img': 'https://www.easports.com/iframe/fut15/p/ut/captcha/img', # add timestamp - 'fut_captcha_validate': 'https://www.easports.com/iframe/fut15/p/ut/captcha/validate', + 'fut_question': 'https://www.easports.com/iframe/fut16/p/ut/game/fifa16/phishing/question', # add timestamp + 'fut_validate': 'https://www.easports.com/iframe/fut16/p/ut/game/fifa16/phishing/validate', + 'fut_captcha_img': 'https://www.easports.com/iframe/fut16/p/ut/captcha/img', # add timestamp + 'fut_captcha_validate': 'https://www.easports.com/iframe/fut16/p/ut/captcha/validate', 'fut_host': {'pc': 'https://utas.s2.fut.ea.com:443', 'ps3': 'https://utas.s2.fut.ea.com:443', @@ -40,9 +40,9 @@ def urls(platform, cl=None): 'ios': 'https://utas.fut.ea.com:443', 'and': 'https://utas.fut.ea.com:443'}, - 'shards': 'https://www.easports.com/iframe/fut15/p/ut/shards', # add timestamp - 'acc_info': 'https://www.easports.com/iframe/fut15/p/ut/game/fifa15/user/accountinfo', - 'card_info': 'https://fifa15.content.easports.com/fifa/fltOnlineAssets/8D941B48-51BB-4B87-960A-06A61A62EBC0/2015/fut/items/web/', + 'shards': 'https://www.easports.com/iframe/fut16/p/ut/shards', # add timestamp + 'acc_info': 'https://www.easports.com/iframe/fut16/p/ut/game/fifa16/user/accountinfo', + 'card_info': 'https://fifa15.content.easports.com/fifa/fltOnlineAssets/B488919F-23B5-497F-9FC0-CACFB38863D0/2016/fut/items/web/', } # urls['login'] = requests.get(urls['fut_home']).url From 3ce54efc6f15781d44fc8f825275c24ea7cd5033 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Wed, 16 Sep 2015 17:39:29 +0200 Subject: [PATCH 07/10] fix for xbox/ps3 --- fut/core.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fut/core.py b/fut/core.py index 9fd4971..57dddf9 100644 --- a/fut/core.py +++ b/fut/core.py @@ -129,6 +129,14 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul self.r.headers = headers.copy() # i'm chrome browser now ;-) self.urls = urls(platform) # TODO: urls won't be loaded if we drop here + if platform == 'pc': + gameSku = 'FFA16PCC' + elif platform == 'xbox': + gameSku == 'FFA16XBO' + elif platform == 'ps3': + gameSku == 'FFA16PS3' # not tested + else: + raise FutError('Wrong platform. (Valid ones are pc/xbox/ps3)') # if self.r.get(self.urls['main_site']+'/fifa/api/isUserLoggedIn').json()['isLoggedIn']: # return True # no need to log in again # emulate @@ -238,6 +246,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul # 'nuc': self.nucleus_id, 'nucleusPersonaId': self.persona_id, 'nucleusPersonaDisplayName': self.persona_name, + 'gameSku': gameSku, 'nucleusPersonaPlatform': platform, 'locale': 'en-GB', 'method': 'authcode', From b246601fa7ffbaccebd8299064efecf7433332c9 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Wed, 16 Sep 2015 18:33:56 +0200 Subject: [PATCH 08/10] typo --- fut/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fut/core.py b/fut/core.py index 57dddf9..5d82ea9 100644 --- a/fut/core.py +++ b/fut/core.py @@ -132,9 +132,9 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul if platform == 'pc': gameSku = 'FFA16PCC' elif platform == 'xbox': - gameSku == 'FFA16XBO' + gameSku = 'FFA16XBO' elif platform == 'ps3': - gameSku == 'FFA16PS3' # not tested + gameSku = 'FFA16PS3' # not tested else: raise FutError('Wrong platform. (Valid ones are pc/xbox/ps3)') # if self.r.get(self.urls['main_site']+'/fifa/api/isUserLoggedIn').json()['isLoggedIn']: From 6e5158f9bcb70c670e5df214109fbc6cfb0ff1d7 Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Thu, 17 Sep 2015 10:49:41 +0200 Subject: [PATCH 09/10] urls: update url for xbox --- fut/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fut/urls.py b/fut/urls.py index 5b98393..18e3afb 100644 --- a/fut/urls.py +++ b/fut/urls.py @@ -36,7 +36,7 @@ def urls(platform, cl=None): 'fut_host': {'pc': 'https://utas.s2.fut.ea.com:443', 'ps3': 'https://utas.s2.fut.ea.com:443', - 'xbox': 'https://utas.fut.ea.com:443', + 'xbox': 'https://utas.s3.fut.ea.com:443', 'ios': 'https://utas.fut.ea.com:443', 'and': 'https://utas.fut.ea.com:443'}, From a51db40723cdc81a1924364a83dfad68a50f5f9b Mon Sep 17 00:00:00 2001 From: Piotr Staroszczyk Date: Thu, 17 Sep 2015 11:10:12 +0200 Subject: [PATCH 10/10] headers: i'm shockwave flash, ain't i? --- fut/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fut/core.py b/fut/core.py index 5d82ea9..f37cc59 100644 --- a/fut/core.py +++ b/fut/core.py @@ -232,7 +232,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul self.persona_id = rc['personaId'] self.persona_name = rc['personaName'] self.clubs = [i for i in rc['userClubList']] - # sort clubs by lastAccessTime (latest firts) + # sort clubs by lastAccessTime (latest first) self.clubs.sort(key=lambda i: i['lastAccessTime'], reverse=True) # authorization @@ -295,6 +295,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, emul del self.r.headers['X-UT-Route'] self.r.headers.update({ # 'X-HTTP-Method-Override': 'GET', # __request__ method manages this + 'X-Requested-With': 'ShockwaveFlash/19.0.0.162', 'Referer': 'https://www.easports.com/iframe/fut16/bundles/futweb/web/flash/FifaUltimateTeam.swf', 'Origin': 'https://www.easports.com', # 'Content-Type': 'application/json', # already set