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 Oct 18, 2017
2 parents 1fe0556 + 4c0296c commit 308ac1e
Show file tree
Hide file tree
Showing 13 changed files with 43,706 additions and 102,325 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Patches and Suggestions
- xAranaktu
- LasseRegin
- kirov
- jsarasti
16 changes: 16 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ Changelog
---------


0.3.1 (2017-10-18)
^^^^^^^^^^^^^^^^^^

* pinEvents: random timestamp with delay & option request before sending data
* add sbsSets
* correct few details (page_size, sleep times etc.) - community work :-)
* rename searchAuctions to search (You can still use searchAuctions)
* fix python2 compatibility (#296)
* correct _ value - all credits go to ricklhp7
* fix sendToWatchlist (jsarasti patch #303)
* proper currentBid check logic (jsarasti patch #303)
* fix squad method (#300)
* fix database (players, nations, leagues, teams, stadiums)
* add balls method (database)
* rewrite searchDefinition (jsarasti work #304)

0.3.0 (2017-10-12)
^^^^^^^^^^^^^^^^^^

Expand Down
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ fut
.. image:: https://img.shields.io/pypi/pyversions/fut.svg
:target: https://pypi.python.org/pypi/fut

.. image:: https://travis-ci.org/oczkers/fut.png?branch=master
:target: https://travis-ci.org/oczkers/fut
.. image:: https://travis-ci.org/futapi/fut.png?branch=master
:target: https://travis-ci.org/futapi/fut

.. image:: https://codecov.io/github/oczkers/fut/coverage.svg?branch=master
:target: https://codecov.io/github/oczkers/fut
.. image:: https://codecov.io/github/futapi/fut/coverage.svg?branch=master
:target: https://codecov.io/github/futapi/fut
:alt: codecov.io

.. image:: https://api.codacy.com/project/badge/Grade/f599808fba2447c98253cf44cca86a1b
Expand Down Expand Up @@ -88,14 +88,14 @@ Optional parameters:
- min_buy: [int] Minimal buy now price.
- max_buy: [int] Maximum buy now price.
- level: ['bronze'/'silver'/gold'] Card level.
- rare: [bool] False for non-rare only results.
- start: [int] Start page number.
- category: ['fitness'/'?'] Card category.
- assetId: [int] assetId.
- defId: [int] defId.
- league: [int] League id.
- club: [int] Club id.
- position: [int?/str?] Position.
- zone: ['attacker'/'?'] zone.
- nationality: [int] Nation id.
- rare: [boolean] True for searching special cards.
- playStyle: [str?] playStyle.
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.3.0'
__version__ = '0.3.1'
__author__ = 'Piotr Staroszczyk'
__author_email__ = 'piotr.staroszczyk@get24.org'
__license__ = 'GNU GPL v3'
Expand Down
6 changes: 3 additions & 3 deletions fut/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# chrome 58 @ win10
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip,deflate,sdch, br',
'Accept-Language': 'en-US,en;q=0.8',
# 'Accept-Charset': 'utf-8, iso-8859-1, utf-16, *;q=0.1',
'Connection': 'keep-alive',
# 'Connection': 'keep-alive',
# 'Keep-Alive': '300',
'DNT': '1',
}
Expand Down Expand Up @@ -39,4 +39,4 @@

cookies_file = 'cookies.txt'
timeout = 15 # defaulf global timeout
delay = (0, 5) # default mininum delay between requests (random range)
delay = (1, 3) # default mininum delay between requests (random range)
201 changes: 143 additions & 58 deletions fut/core.py

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions fut/pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
import requests
import re
import json
import time
from random import random
from datetime import datetime

from fut.config import headers
from fut.urls import pin_url, v
from fut.exceptions import FutError


Expand All @@ -25,8 +28,6 @@ def __init__(self, sku='FIFA18WEB', sid='', nucleus_id=0, persona_id='', dob=Fal
self.persona_id = persona_id
self.dob = dob
self.platform = platform
rc = requests.get('https://www.easports.com/fifa/ultimate-team/web-app/config/config.json').text
self.url = re.search('"pinURL": "(.+?)",', rc).group(1)
rc = requests.get('https://www.easports.com/fifa/ultimate-team/web-app/js/compiled_1.js').text
self.taxv = re.search('PinManager.TAXONOMY_VERSION=([0-9\.]+?)', rc).group(1)
self.tidt = re.search('PinManager.TITLE_ID_TYPE="(.+?)"', rc).group(1)
Expand Down Expand Up @@ -89,12 +90,13 @@ def event(self, en, pgid=False, status=False, source=False, end_reason=False):
return data

def send(self, events):
time.sleep(0.5 + random() / 50)
data = {"taxv": self.taxv, # convert to float?
"tidt": self.tidt,
"tid": self.sku,
"rel": self.rel,
"v": "18.0.0", # TODO: where is it from?
"ts_post": self.__ts(), # TODO: random delay between event and post (0.5-2s?)
"v": v,
"ts_post": self.__ts(),
"sid": self.sid,
"gid": self.gid, # convert to int?
"plat": self.plat,
Expand All @@ -103,7 +105,9 @@ def send(self, events):
"is_sess": self.sid != '',
"custom": self.custom,
"events": events}
rc = self.r.post(self.url, data=json.dumps(data)).json()
# print(data) # DEBUG
self.r.options(pin_url)
rc = self.r.post(pin_url, data=json.dumps(data)).json()
if rc['status'] != 'ok':
raise FutError('PinEvent is NOT OK, probably they changed something.')
return True
28 changes: 26 additions & 2 deletions fut/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
import requests

from .exceptions import FutError

# config
rc = requests.get('https://www.easports.com/fifa/ultimate-team/web-app/config/config.json').json()
auth_url = rc['authURL']
pin_url = rc['pinURL'] # TODO: urls in dict?
client_id = rc['eadpClientId']
fun_captcha_public_key = rc['funCaptchaPublicKey']

card_info_url = 'https://fifa18.content.easports.com/fifa/fltOnlineAssets/B1BA185F-AD7C-4128-8A64-746DE4EC5A82/2018/fut/items/web/' # TODO: get hash from config/remoteconfig, dynamic year
messages_url = 'https://www.easports.com/iframe/fut18/bundles/futweb/web/flash/xml/localization/messages.en_US.xml' # TODO: dynamic year

# remote config - should be refresh every x seconds
rc = requests.get('https://www.easports.com/fifa/ultimate-team/web-app/content/B1BA185F-AD7C-4128-8A64-746DE4EC5A82/2018/fut/config/companion/remoteConfig.json').json()

if rc['pin'] != {"b": True, "bf": 500, "bs": 10, "e": True, "r": 3, "rf": 300}:
print('>>> WARNING: ping variables changed: %s' % rc['pin'])

if rc['patch']['f'] != 1800000:
print('>>> WARNING: patch version changed: %s' % rc['patch']['f'])
v = '18.0.0'

if rc['futweb_maintenance']:
raise FutError('Futweb maintenance, please retry in few minutes.')

# TODO: parse itemsPerPage
# "itemsPerPage": {
# "club" : 45,
# "transferMarket" : 15
# },


card_info_url = 'https://fifa18.content.easports.com/fifa/fltOnlineAssets/B1BA185F-AD7C-4128-8A64-746DE4EC5A82/2018/fut/items/web/' # TODO: get hash from somewhere, dynamic year
messages_url = 'https://www.easports.com/fifa/ultimate-team/web-app/loc/en_US.json'
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
requests>=2.2.1
xmltodict
pyotp
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__ = 'fut'
__version__ = '0.3.0'
__version__ = '0.3.1'
__author__ = 'Piotr Staroszczyk'
__author_email__ = 'piotr.staroszczyk@get24.org'
__license__ = 'GNU GPL v3'
Expand Down
Loading

0 comments on commit 308ac1e

Please sign in to comment.