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

Encountered an error while using aki. start_game #13

Open
3 tasks done
Container-Zero opened this issue Apr 2, 2024 · 9 comments
Open
3 tasks done

Encountered an error while using aki. start_game #13

Container-Zero opened this issue Apr 2, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@Container-Zero
Copy link

Container-Zero commented Apr 2, 2024

Summary

Encountered an error while using aki. start_game

Reproduction Steps

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/dist-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
  File "/app/app.py", line 48, in handle_request
    q = await aki.start_game(language=lang)
  File "/usr/local/lib/python3.9/dist-packages/akinator/async_aki/async_akinator.py", line 168, in start_game
    region_info = await self._auto_get_region(get_lang_and_theme(language)["lang"], get_lang_and_theme(language)["theme"])
  File "/usr/local/lib/python3.9/dist-packages/akinator/async_aki/async_akinator.py", line 114, in _auto_get_region
    parsed = json.loads(match.group().split("'arrUrlThemesToPlay', ")[-1])
AttributeError: 'NoneType' object has no attribute 'group'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f819fc90670>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f819fa81a60>, 5245086.969)]']
connector: <aiohttp.connector.TCPConnector object at 0x7f819fc905e0>

Minimal Reproducible Code

The problem can be reproduced 100% by only allowing the code in [ examples/async_aki.py ] to be run.
I'm pretty sure that the first time this error would have occurred would have been within five minutes before UTC/GMT: 2024-04-02 06:10:00 , and I think it's likely that akinator officially, probably at 6:00, changed something.

Expected Results

No errors

Actual Results

An error has occurred

System Information

Ubuntu 20.04.5 LTS (GNU/Linux 5.4.0-28-generic x86_64)

Checklist

  • I have searched open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have made sure that this issue is valid.

Additional Context

No response

@Container-Zero Container-Zero added the bug Something isn't working label Apr 2, 2024
@Container-Zero
Copy link
Author

Container-Zero commented Apr 7, 2024

The problem has been resolved and appears to have been caused by aki's own network fluctuations, which have now recovered on their own.

This issue has arisen again.
I think something may still be happening.

The exception caused by that aki.start_game can be repeated on completely different hosts with different network environments, so I'm pretty sure it's not my problem. But it feels like it's weird to have this exception periodically.

image

@Container-Zero
Copy link
Author

Container-Zero commented Apr 9, 2024

hi man, did you get it to work? It'd help me a lot as I'm also working on it :D

Yes, there have been major changes to aki's official website, I just spent 2 hours completely refactoring the asynchronous portion of the project's code and it's working, but it's not quite finished yet. :)

I'll have to sleep and get up and do the rest.

Also I found that the new official version doesn't seem to support custom aki.progression custom values and calling ... /list to force an answer to a question, this interface is no longer officially provided, do you have a solution for this?

@codewarnab
Copy link

this issue still persists
https://github.com/codewarnab/akinatorbot in this repo i am currenlty facing this issue

aki_play_cmd_handler
    q = aki.start_game(language=None, child_mode=False)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Akinator.start_game() got an unexpected keyword argument 'language'

most probably this is due to some api changes

@advnpzn
Copy link
Contributor

advnpzn commented May 8, 2024

Yup, I'm facing this issue currently as well. Haven't checkout Akinator library in a while yet.
I'll probably try to debug it from my end and see what can be done. When I get time 😭 ofcourse.

Also @Container-Zero please let me know what you're working on to fix this issue? I assume the problem is because things have changed or restructured in the Akinator official site right ?

@advnpzn
Copy link
Contributor

advnpzn commented May 10, 2024

I was able to reproduce this error through debugging.
The problem is the regex pattern is not matching with the HTML text output from requests object.

def _auto_get_region(self, lang, theme):
"""Automatically get the uri and server from akinator.com for the specified language and theme"""
server_regex = re.compile("[{\"translated_theme_name\":\"[\s\S]*\",\"urlWs\":\"https:\\\/\\\/srv[0-9]+\.akinator\.com:[0-9]+\\\/ws\",\"subject_id\":\"[0-9]+\"}]")
uri = lang + ".akinator.com"
bad_list = ["https://srv12.akinator.com:9398/ws"]
while True:
r = requests.get("https://" + uri, verify=False)
match = server_regex.search(r.text)
parsed = json.loads(match.group().split("'arrUrlThemesToPlay', ")[-1])

I assume there is a change in the Akinator site structure or the regex pattern is not valid anymore.
I was using Python 3.12.

@advnpzn
Copy link
Contributor

advnpzn commented May 11, 2024

Okay, it seems like they have made changes to the API a lot.

@0xc60f
Copy link

0xc60f commented May 12, 2024

Are there any hotfixes we can apply on our end to patch it temporarily until there is a full update, or has the API changed too much to apply a few fixes?

@advnpzn
Copy link
Contributor

advnpzn commented May 12, 2024

Are there any hotfixes we can apply on our end to patch it temporarily until there is a full update, or has the API changed too much to apply a few fixes?

I've actually created the same library from scratch with new changes to the API. It is working fine now. But there are a lot of things that is missing currently in mine. I followed the same code structure as this wrapper to make sure I get the similar end interface because I use this wrapper as a dependency in other projects. You can probably check out the below link.

https://github.com/advnpzn/akipy

@0xc60f
Copy link

0xc60f commented May 12, 2024

Are there any hotfixes we can apply on our end to patch it temporarily until there is a full update, or has the API changed too much to apply a few fixes?

I've actually created the same library from scratch with new changes to the API. It is working fine now. But there are a lot of things that is missing currently in mine. I followed the same code structure as this wrapper to make sure I get the similar end interface because I use this wrapper as a dependency in other projects. You can probably check out the below link.

https://github.com/advnpzn/akipy

Looks like it's already functioning partially! I'm about to graduate soon, but once I'm done with school I'll definitely try to help with some stuff like docs since I relied on this library for a Discord bot I maintain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@Container-Zero @0xc60f @advnpzn @codewarnab and others