Skip to content

Commit

Permalink
Merge branch 'master' of github.com:oczkers/fut
Browse files Browse the repository at this point in the history
  • Loading branch information
oczkers committed Dec 7, 2017
2 parents fda8fac + 5e7ef77 commit 8234a1e
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions fut/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import json
import pyotp
from python_anticaptcha import AnticaptchaClient, FunCaptchaTask, Proxy
from python_anticaptcha.exceptions import AnticatpchaException
# from datetime import datetime, timedelta
try:
from cookielib import LWPCookieJar
Expand Down Expand Up @@ -583,23 +584,40 @@ def __launch__(self, email, passwd, secret_answer, platform='pc', code=None, tot
raise FutError('FunCaptcha requires a proxy. Add proxies param.')
self.logger.debug('Solving FunCaptcha...')
anticaptcha = AnticaptchaClient(anticaptcha_client_key)
task = FunCaptchaTask(
'https://www.easports.com',
fun_captcha_public_key,
proxy=Proxy.parse_url(proxies.get('http')),
user_agent=self.r.headers['User-Agent']
)
job = anticaptcha.createTask(task)
job.join()
fun_captcha_token = job.get_token_response()
self.logger.debug('FunCaptcha solved: {}'.format(fun_captcha_token))
self.__request__('POST', 'captcha/fun/validate', data=json.dumps({
'funCaptchaToken': fun_captcha_token,
}))
attempt = 0
while True:
attempt += 1
if attempt > 10:
raise FutError('Can\'t send captcha.')
try:
self.logger.debug('Attempt #{}'.format(attempt))
task = FunCaptchaTask(
'https://www.easports.com',
fun_captcha_public_key,
proxy=Proxy.parse_url(proxies.get('http')),
user_agent=self.r.headers['User-Agent']
)
job = anticaptcha.createTask(task)
job.join()
fun_captcha_token = job.get_token_response()
self.logger.debug('FunCaptcha solved: {}'.format(fun_captcha_token))
self.__request__('POST', 'captcha/fun/validate', data=json.dumps({
'funCaptchaToken': fun_captcha_token,
}))
rc = self.r.get('https://%s/ut/game/fifa18/phishing/question' % self.fut_host, params={'_': self._}, timeout=self.timeout).json()
self._ += 1
break
except AnticatpchaException as e:
if e.error_code in ['ERROR_PROXY_CONNECT_REFUSED', 'ERROR_PROXY_CONNECT_TIMEOUT', 'ERROR_PROXY_READ_TIMEOUT', 'ERROR_PROXY_BANNED']:
self.logger.exception('AnticatpchaException ' + e.error_code)
time.sleep(10)
continue
else:
raise

else:
raise Captcha(code=rc.get('code'), string=rc.get('string'), reason=rc.get('reason'))
elif rc.get('string') != 'Already answered question':
if rc.get('string') != 'Already answered question':
params = {'answer': secret_answer_hash}
rc = self.r.post('https://%s/ut/game/fifa18/phishing/validate' % self.fut_host, params=params, timeout=self.timeout).json()
if rc['string'] != 'OK': # we've got an error
Expand Down

0 comments on commit 8234a1e

Please sign in to comment.