diff --git a/.gitignore b/.gitignore index 62c1e73..9d7d1dd 100644 --- a/.gitignore +++ b/.gitignore @@ -92,3 +92,6 @@ ENV/ # Rope project settings .ropeproject + +# Pycharm IDE +.idea/ \ No newline at end of file diff --git a/README.rst b/README.rst index b7fbcf5..b3a385c 100644 --- a/README.rst +++ b/README.rst @@ -219,7 +219,7 @@ Error Codes - **401 "Unauthorized"**: Your ``access_token`` is invalid. Either you messed up, or it is outdated. You need to call - ``refresh_access_token()`` or ``refresh_all_token()`` (check the + ``refresh_access_token()`` or ``refresh_all_tokens()`` (check the above section on account creation). - **401 "Action not allowed"**: You are using a ``4.48`` account with ``is_legacy=True``, but ``4.48`` accounts are not allowed @@ -230,7 +230,9 @@ Error Codes to one specific endpoint. - **477 "Signed Request Expected"**: This library should handle request signing. Make sure to upgrade to the latest version of ``jodel_api``, - as the signing key changes every few weeks. + as the signing key changes every few weeks. You can set the signing key + and version manually through these environment variables: + JODEL_API_JODELKEY and JODEL_API_JODELVERSION (jodel_api will prefer newer versions) - **478 "Account not verified"**: Verify the account through GCM. - **502 "Bad Gateway"**: Something went wrong server-side. This happens pretty randomly. ``jodel_api`` automatically retries two times when diff --git a/setup.py b/setup.py index 861e7c2..bbff821 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ long_description = f.read() setup(name='jodel_api', - version='1.2.11', + version='1.2.12', description='Unoffical Python Interface to the Jodel API', long_description=long_description, url='https://github.com/nborrmann/jodel_api', diff --git a/src/jodel_api/jodel_api.py b/src/jodel_api/jodel_api.py index f982b31..dd8f96b 100644 --- a/src/jodel_api/jodel_api.py +++ b/src/jodel_api/jodel_api.py @@ -15,6 +15,8 @@ from urllib.parse import urlparse from jodel_api import gcmhack import time +from os import environ +from re import findall s = requests.Session() @@ -24,10 +26,23 @@ class JodelAccount: api_url = "https://api.go-tellm.com/api{}" client_id = '81e8a76e-1e02-4d17-9ba0-8a7020261b26' - secret = 'HtJoqSysGFQXgFqYZRgwbpcFVAzLFSioVKTCwMcL'.encode('ascii') - version = '4.79.1' secret_legacy = 'hyTBJcvtpDLSgGUWjybbYUNKSSoVvMcfdjtjiQvf'.encode('ascii') version_legacy = '4.47.0' + secret = 'DKUdMXSujwAPihgJiMzHIDcXaxUNJwhBagBgBYlg'.encode('ascii') + version = '4.84.1' + + + if not (environ.get('JODEL_API_JODELKEY') == None or environ.get('JODEL_API_JODELVERSION') == None): + ver_environ = [int(s) for s in findall(r'\b\d+\b', environ.get('JODEL_API_JODELVERSION'))] + ver_builtin = [int(s) for s in findall(r'\b\d+\b', version)] + + for i in range(len(ver_environ)): + if ver_builtin[i] < ver_environ[i]: + secret = environ.get('JODEL_API_JODELKEY').encode('ascii') + version = environ.get('JODEL_API_JODELVERSION') + break + elif ver_builtin[i] > ver_environ[i]: + break access_token = None