DarkCat09 / python-aternos

[UNMAINTAINED] Unofficial Aternos API written in Python
https://pypi.org/project/python-aternos/
Apache License 2.0
92 stars 12 forks source link

RecursionError: maximum recursion depth exceeded while calling a Python object #18

Closed P4R1H closed 2 years ago

P4R1H commented 2 years ago

entire traceback

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/__init__.py", line 47, in from_credentials
    return cls.from_hashed(username, md5)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/__init__.py", line 23, in from_hashed
    atconn.parse_token()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/atconnect.py", line 23, in parse_token
    loginpage = self.request_cloudflare(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/atconnect.py", line 142, in request_cloudflare
    self.request_cloudflare(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/atconnect.py", line 142, in request_cloudflare
    self.request_cloudflare(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/atconnect.py", line 142, in request_cloudflare
    self.request_cloudflare(
  [Previous line repeated 969 more times]
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/atconnect.py", line 134, in request_cloudflare
    req = self.session.get(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/cloudscraper/__init__.py", line 257, in request
    self.perform_request(method, url, *args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/cloudscraper/__init__.py", line 190, in perform_request
    return super(CloudScraper, self).request(method, url, *args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.8/http/client.py", line 1344, in getresponse
    response.begin()
  File "/usr/lib/python3.8/http/client.py", line 331, in begin
    self.headers = self.msg = parse_headers(self.fp)
  File "/usr/lib/python3.8/http/client.py", line 225, in parse_headers
    return email.parser.Parser(_class=_class).parsestr(hstring)
  File "/usr/lib/python3.8/email/parser.py", line 67, in parsestr
    return self.parse(StringIO(text), headersonly=headersonly)
  File "/usr/lib/python3.8/email/parser.py", line 56, in parse
    feedparser.feed(data)
  File "/usr/lib/python3.8/email/feedparser.py", line 176, in feed
    self._call_parse()
  File "/usr/lib/python3.8/email/feedparser.py", line 180, in _call_parse
    self._parse()
  File "/usr/lib/python3.8/email/feedparser.py", line 295, in _parsegen
    if self._cur.get_content_maintype() == 'message':
  File "/usr/lib/python3.8/email/message.py", line 594, in get_content_maintype
    ctype = self.get_content_type()
  File "/usr/lib/python3.8/email/message.py", line 578, in get_content_type
    value = self.get('content-type', missing)
  File "/usr/lib/python3.8/email/message.py", line 471, in get
    return self.policy.header_fetch_parse(k, v)
  File "/usr/lib/python3.8/email/_policybase.py", line 316, in header_fetch_parse
    return self._sanitize_header(name, value)
  File "/usr/lib/python3.8/email/_policybase.py", line 287, in _sanitize_header
    if _has_surrogates(value):
  File "/usr/lib/python3.8/email/utils.py", line 57, in _has_surrogates
    s.encode()
P4R1H commented 2 years ago

Here's the part of the code that logs in to aternos

from python_aternos import Client

intents = discord.Intents.all()
client = commands.Bot(command_prefix='>', intents=intents)
# Log in
try:
    atern = Client.from_credentials(f'{os.getenv("username")}', f'{os.getenv("password")}')
except Exception as a:
    print(a)
servs = atern.list_servers()
DarkCat09 commented 2 years ago

Hello. Thank you for opening the issue.
Your problem is the same as #17
python-aternos can't bypass the Cloudflare protection, and repeats the function call many times (view this code, it's a recursion).
I'm already working on it.

DarkCat09 commented 2 years ago

I've forgot to decrease the retries number...


Screenshot

ZeynX92 commented 2 years ago

Здравствуйте! Проблема будет решена на уровне API я верно понял?)

DarkCat09 commented 2 years ago

I hope / Надеюсь.

P4R1H commented 2 years ago

thanks for the quick reply

not facing recursion error anymore but the same one as zeyn now

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/atconnect.py", line 33, in parse_token
    token_func = js_code[1] if len(js_code) > 1 else js_code[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 13, in <module>
    atern = Client.from_credentials(f'{os.getenv("username")}', f'{os.getenv("password")}')
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/__init__.py", line 47, in from_credentials
    return cls.from_hashed(username, md5)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/__init__.py", line 23, in from_hashed
    atconn.parse_token()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/python_aternos/atconnect.py", line 39, in parse_token
    raise CredentialsError(
python_aternos.aterrors.CredentialsError: Unable to parse TOKEN from the page
DarkCat09 commented 2 years ago

@Sept1-c, are you still getting the CredentialsError?
Send me the token function:

  1. Open a server panel (aternos.org/server)
  2. Open DevTools (Ctrl+Shift+I or Inspect in context menu)
  3. Find the <head>, click on the arrow to expand
  4. Now, find the second <script type=text/javascript> which must contain something like https://github.com/DarkCat09/python-aternos/blob/main/token.txt
  5. Send me this javascript code
  6. Logout (for some security reasons)
DarkCat09 commented 2 years ago

Please, update the module, I fixed it. JavaScript parser works properly now.

P4R1H commented 2 years ago

updated, still seem to get the same error also couldn't find anything like the link you sent in any of the <script type=text/javascript>

DarkCat09 commented 2 years ago

Update it to 1.0.3.

flancast90 commented 2 years ago

Update it to 1.0.3.

This did nothing for me. Here is what is included in the Githubissues.

  • Githubissues is a development platform for aggregating issues.