Compare commits
2 commits
832cf01b20
...
7cbe96ac3d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7cbe96ac3d | ||
![]() |
b066701d51 |
6 changed files with 128 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
|
settings.json
|
||||||
|
|
||||||
# ---> Python
|
# ---> Python
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
0
earnapp/__init__.py
Normal file
0
earnapp/__init__.py
Normal file
31
earnapp/earnapp.py
Normal file
31
earnapp/earnapp.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
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()
|
63
earnapp/errors.py
Normal file
63
earnapp/errors.py
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
class UnKnownError(Exception):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class AuthenticationError(Exception):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__({'error': 'Error authenticating. Enter a proper oauth-refresh-token.'})
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceAddError(Exception):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceNotFoundError(DeviceAddError):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceAlreadyAddedError(DeviceAddError):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class UnknownDeviceAddError(DeviceAddError):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class TooManyRequestsError(DeviceAddError):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class IPCheckError(Exception):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class UnknownIPCheckError(IPCheckError):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidIPAddressError(IPCheckError):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__('The IP Address is not valid.', *args)
|
||||||
|
|
||||||
|
|
||||||
|
class RedeemError(Exception):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class UnKnownRedeemError(RedeemError):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
|
class MinimumRedeemBalanceError(RedeemError):
|
||||||
|
def __init__(self, *args: object) -> None:
|
||||||
|
super().__init__(*args)
|
24
run.py
Normal file
24
run.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from earnapp.earnapp import EarnApp
|
||||||
|
|
||||||
|
ea = EarnApp()
|
||||||
|
|
||||||
|
# user_data = ea.get('/user_data')
|
||||||
|
# notifications = ea.get('/notifications')
|
||||||
|
# counters = ea.get('/counters')
|
||||||
|
# money = ea.get('/money')
|
||||||
|
# payment_methods = ea.get('/payment_methods')
|
||||||
|
# usage = ea.get('/usage')
|
||||||
|
# devices = ea.get('/devices')
|
||||||
|
# device_statuses = ea.get('/device_statuses')
|
||||||
|
# transaction_info = ea.get('/transactions')
|
||||||
|
# referees = ea.get('/referees')
|
||||||
|
# referees_bvpn = ea.get('/referees_bvpn')
|
||||||
|
# bonuses = ea.get('/bonuses')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
8
settings.example.json
Normal file
8
settings.example.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"settings": {
|
||||||
|
"webhook": "",
|
||||||
|
"oauth-refresh-token": "",
|
||||||
|
"oauth-token": "",
|
||||||
|
"api": "https://earnapp.com/dashboard/api"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue