Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to get jodel key and version from environment variables. #70

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,6 @@ ENV/

# Rope project settings
.ropeproject

# Pycharm IDE
.idea/
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
19 changes: 17 additions & 2 deletions src/jodel_api/jodel_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
Expand Down