34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
import httpx as requests
|
|
import json
|
|
|
|
from .errors import *
|
|
|
|
|
|
class EarnApp:
|
|
def __init__(self) -> None:
|
|
self.data = json.load(open('settings.json', mode='r', encoding='UTF-8'))['settings']
|
|
self.params = {
|
|
'appid': 'earnapp',
|
|
'version': '1.361.776',
|
|
}
|
|
self.headers = {
|
|
'cookie': 'auth=1; '
|
|
'auth-method=google; '
|
|
'oauth-token={}; '
|
|
'oauth-refresh-token={};'.format(self.data['oauth-token'], self.data['oauth-refresh-token'])
|
|
}
|
|
self.minimum_redeem_balance = float(2.50)
|
|
|
|
def get(self, endpoint: str) -> json:
|
|
r = requests.get(self.data['api'] + endpoint, params=self.params, headers=self.headers)
|
|
|
|
if r.status_code == 403:
|
|
raise AuthenticationError
|
|
elif r.status_code == 429:
|
|
raise TooManyRequestsError({'error': 'EarnApp does not allow adding multiple devices at the same time. '
|
|
'Try adding some delay between requests.'})
|
|
elif r.status_code == 200:
|
|
return r.json()
|
|
|
|
def start_monitor(self):
|
|
pass
|