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 Sep 22, 2014
2 parents 97808fd + 8f52fc5 commit 629c035
Show file tree
Hide file tree
Showing 21 changed files with 149 additions and 133 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ docs/_build
*.pyc
build/
dist/
fut14.egg-info/
fut.egg-info/
test.py
testemu.py
log.log
content.log
error.log
fut14.log
fut.log
test.log
testemu.py
2 changes: 1 addition & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Fut14 is written and maintained by Piotr Staroszczyk and various contributors:
Fut is written and maintained by Piotr Staroszczyk and various contributors:

Development Lead
````````````````
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Changelog
---------


0.0.17 (2014-09-22)
++++++++++++++++++
* rename project (fut14->fut)
* fut15 (drop support for fifa 14)


0.0.16 (2014-08-31)
++++++++++++++++++
* #76 fix buying (thanks to arthurnn)
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

fut14 is a library for managing sharing websites (like netload.in).
fut is a library for managing sharing websites (like netload.in).
Copyright (C) 2013 Piotr Staroszczyk

This program is free software: you can redistribute it and/or modify
Expand All @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

fut14 Copyright (C) 2013 Piotr Staroszczyk
fut Copyright (C) 2013 Piotr Staroszczyk
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include README.rst LICENSE AUTHORS.rst requirements.txt test_fut14.py
include README.rst LICENSE AUTHORS.rst requirements.txt test_fut.py
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test-deps:
pip install -r requirements.txt

six:
python test_fut14.py
python test_fut.py

deps: requests

18 changes: 9 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
fut14
fut
=====

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

fut14 is a simple library for managing Fifa 14 Ultimate Team.
fut is a simple library for managing Fifa Ultimate Team.
It is written entirely in Python.



Documentation
-------------
Documentation is available at http://fut14.readthedocs.org/.
Documentation is available at http://fut.readthedocs.org/.

Players database: http://cdn.content.easports.com/fifa/fltOnlineAssets/C74DDF38-0B11-49b0-B199-2E2A11D1CC13/2014/fut/items/web/players.json
Players database: http://cdn.content.easports.com/fifa/fltOnlineAssets/8D941B48-51BB-4B87-960A-06A61A62EBC0/2015/fut/items/web/players.json



Expand All @@ -22,11 +22,11 @@ Usage

.. code-block:: pycon
>>> import fut14
>>> fut = fut14.Core('email', 'password', 'secret answer', platform='xbox', emulate='and', debug=True)
>>> import fut
>>> fut = fut.Core('email', 'password', 'secret answer', platform='xbox', emulate='and', debug=True)
>>> # PLATFORM: pc / ps3 / xbox / and / ios (pc default)
>>> # EMULATE: and / ios (use this feature to avoid webapp errors [BE WARE IT'S HIGH RISK])
>>> # DEBUG: save http response to fut14.log)
>>> # DEBUG: save http response to fut.log)
>>> items = fut.searchAuctions('development', # search items
... level='gold', category='fitness', min_price=300, # optional parametrs
Expand Down
8 changes: 4 additions & 4 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ qthelp:
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/fut14.qhcp"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/fut.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/fut14.qhc"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/fut.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/fut14"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/fut14"
@echo "# mkdir -p $$HOME/.local/share/devhelp/fut"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/fut"
@echo "# devhelp"

epub:
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# fut14 documentation build configuration file, created by
# fut documentation build configuration file, created by
# sphinx-quickstart on Thu Jan 16 00:01:22 2014.
#
# This file is execfile()d with the current directory set to its containing dir.
Expand All @@ -17,7 +17,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
from fut14 import __title__, __version__, __author__
from fut import __title__, __version__, __author__

# -- General configuration -----------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.. fut14 documentation master file, created by
.. fut documentation master file, created by
sphinx-quickstart on Thu Jan 16 00:01:22 2014.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to fut14's documentation!
Welcome to fut's documentation!
=================================

Release v\ |version|. (:ref:`Installation <install>`)

fut14 is a simple library for managing Fifa 14 Ultimate Team.
fut is a simple library for managing Fifa 14 Ultimate Team.



Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions fut14/__init__.py → fut/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-

"""
fut14
fut
~~~~~~~~~~~~~~~~~~~~~
fut14 is a simple library for managing Fifa 14 Ultimate Team.
fut is a simple library for managing Fifa Ultimate Team.
Usage:
>>> import fut14
>>> import fut
to be continued ;-)
Expand All @@ -17,8 +17,8 @@
"""

__title__ = 'fut14'
__version__ = '0.0.16'
__title__ = 'fut'
__version__ = '0.0.17'
__author__ = 'Piotr Staroszczyk'
__author_email__ = '[email protected]'
__license__ = 'GNU GPL v3'
Expand Down
4 changes: 2 additions & 2 deletions fut14/api.py → fut/api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-

"""
fut14.api
fut.api
~~~~~~~~~~~~~~~~~~~~~
This module implements the fut14's API.
This module implements the fut's API.
"""

Expand Down
File renamed without changes.
35 changes: 20 additions & 15 deletions fut14/core.py → fut/core.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-

"""
fut14.core
fut.core
~~~~~~~~~~~~~~~~~~~~~
This module implements the fut14's basic methods.
This module implements the fut's basic methods.
"""

Expand All @@ -18,7 +18,7 @@
from .config import headers, headers_and, headers_ios
from .log import logger
from .urls import urls
from .exceptions import (Fut14Error, ExpiredSession, InternalServerError,
from .exceptions import (FutError, ExpiredSession, InternalServerError,
UnknownError, PermissionDenied, Captcha,
Conflict, MaxSessions, MultipleSession,
FeatureDisabled, doLoginFail)
Expand Down Expand Up @@ -92,7 +92,7 @@ def cardInfo(resource_id):

class Core(object):
def __init__(self, email, passwd, secret_answer, platform='pc', emulate=None, debug=False):
if debug: # save full log to file (fut14.log)
if debug: # save full log to file (fut.log)
self.logger = logger(save=True)
else: # NullHandler
self.logger = logger()
Expand All @@ -115,29 +115,29 @@ def __login__(self, email, passwd, secret_answer, platform='pc', emulate=None):
self.urls = urls(platform)
# emulate
if emulate == 'ios':
sku = 'FUT14IOS'
sku = 'FUT15IOS'
clientVersion = 9
elif emulate == 'and':
sku = 'FUT14AND'
sku = 'FUT15AND'
clientVersion = 9
# TODO: need more info about log in procedure in game
# elif emulate == 'xbox':
# sku = 'FFA14XBX' # FFA14CAP ?
# sku = 'FFA15XBX' # FFA14CAP ?
# clientVersion = 1
# elif emulate == 'ps3':
# sku = 'FFA14PS3' # FFA14KTL ?
# sku = 'FFA15PS3' # FFA14KTL ?
# clientVersion = 1
# elif emulate == 'pc':
# sku = '' # dunno
# clientVersion = 1
elif not emulate:
sku = 'FUT14WEB'
sku = 'FUT15WEB'
clientVersion = 1
else:
raise Fut14Error('Invalid emulate parameter. (Valid ones are and/ios).') # pc/ps3/xbox/
raise FutError('Invalid emulate parameter. (Valid ones are and/ios).') # pc/ps3/xbox/
# === login
self.urls['login'] = self.r.get(self.urls['fut_home']).url
self.r.headers['Referer'] = self.urls['main_site'] # prepare headers
self.r.headers['Referer'] = self.urls['login'] # prepare headers
data = {'email': email,
'password': passwd,
'_rememberMe': 'on',
Expand All @@ -146,6 +146,8 @@ def __login__(self, email, passwd, secret_answer, platform='pc', emulate=None):
'facebookAuth': ''}
rc = self.r.post(self.urls['login'], data=data)
self.logger.debug(rc.content)
if self.r.get(self.urls['main_site']+'/fifa/api/isUserLoggedIn').json()['isLoggedIn'] is not True:
raise FutError('Error during login process (probably invalid email or password).')
# TODO: catch invalid data exception
#self.nucleus_id = re.search('userid : "([0-9]+)"', rc.text).group(1) # we'll get it later

Expand All @@ -154,12 +156,15 @@ def __login__(self, email, passwd, secret_answer, platform='pc', emulate=None):
rc = self.r.get(self.urls['futweb'])
self.logger.debug(rc.content)
rc = rc.text
if 'EASW_ID' not in rc:
raise Fut14Error('Error during login process (probably invalid email or password).')
# if 'EASW_ID' not in rc:
# raise FutError('Error during login process (probably invalid email or password).')
self.nucleus_id = re.search("var EASW_ID = '([0-9]+)';", rc).group(1)
self.build_cl = re.search("var BUILD_CL = '([0-9]+)';", rc).group(1)
#self.urls['fut_base'] = re.search("var BASE_FUT_URL = '(https://.+?)';", rc).group(1)
#self.urls['fut_home'] = re.search("var GUEST_APP_URI = '(http://.+?)';", rc).group(1)

self.urls = urls(platform, self.build_cl)

# acc info
self.r.headers.update({ # prepare headers
'Content-Type': 'application/json',
Expand Down Expand Up @@ -187,7 +192,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', emulate=None):
data = {'isReadOnly': False,
'sku': sku,
'clientVersion': clientVersion,
'nuc': self.nucleus_id,
#'nuc': self.nucleus_id,
'nucleusPersonaId': self.persona_id,
'nucleusPersonaDisplayName': self.persona_name,
'nucleusPersonaPlatform': platform,
Expand Down Expand Up @@ -226,7 +231,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', emulate=None):
rc = rc.json()
if rc['string'] != 'OK': # we've got error
if 'Answers do not match' in rc['reason']:
raise Fut14Error('Error during login process (invalid secret answer).')
raise FutError('Error during login process (invalid secret answer).')
else:
raise UnknownError
self.r.headers['Content-Type'] = 'application/json'
Expand Down
28 changes: 14 additions & 14 deletions fut14/exceptions.py → fut/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# -*- coding: utf-8 -*-

"""
fut14.exceptions
fut.exceptions
~~~~~~~~~~~~~~~~~~~
This module contains the set of fut14's exceptions.
This module contains the set of fut's exceptions.
"""


class Fut14Error(RuntimeError):
class FutError(RuntimeError):
"""There was an ambiguous exception that occurred while handling
your request."""

class UnknownError(Fut14Error):
class UnknownError(FutError):
"""Unknown error, please report full log at
https://github.com/oczkers/fut14/issues/24"""
https://github.com/oczkers/fut/issues/24"""

class ExpiredSession(Fut14Error):
class ExpiredSession(FutError):
"""Session has expired,
you should send at least one request every ~10 minutes."""

class InternalServerError(Fut14Error):
class InternalServerError(FutError):
"""[500] Internal Server Error (ut). (invalid parameters?)"""

class MaxSessions(Fut14Error):
class MaxSessions(FutError):
"""[503] Service Unavailable (ut) - max session."""

class FeatureDisabled(Fut14Error):
class FeatureDisabled(FutError):
"""[480] Feature Disabled."""

class PermissionDenied(Fut14Error):
class PermissionDenied(FutError):
"""[461] Permission Denied. (outbid?)"""

class Captcha(Fut14Error):
class Captcha(FutError):
"""[459] Captcha Triggered."""

class Conflict(Fut14Error):
class Conflict(FutError):
"""[409] Conflict. (You'r trying to sell somebody's item, don't you ;-)?)"""

class Unauthorized(Fut14Error):
class Unauthorized(FutError):
"""[401] Unauthorized (ut)."""

class MultipleSession(Unauthorized):
Expand All @@ -50,6 +50,6 @@ class doLoginFail(Unauthorized):
"""[403] Forbidden (ut)."""

'''
class InvalidCookie(Fut14Error):
class InvalidCookie(FutError):
"""[482] Invalid cookie."""
'''
Loading

0 comments on commit 629c035

Please sign in to comment.