akinator.py icon indicating copy to clipboard operation
akinator.py copied to clipboard

Encountered an error while using aki. start_game

Open Container-Zero opened this issue 1 year ago • 9 comments

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

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

Additional Context

No response

Container-Zero avatar Apr 02 '24 07:04 Container-Zero

~~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 avatar Apr 07 '24 15:04 Container-Zero

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?

Container-Zero avatar Apr 09 '24 16:04 Container-Zero

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

codewarnab avatar May 04 '24 08:05 codewarnab

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 avatar May 08 '24 17:05 advnpzn

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.

https://github.com/Ombucha/akinator.py/blob/323d05a7422adafe1423e027eace70aee09adc5f/akinator/akinator.py#L106-L118

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 avatar May 10 '24 18:05 advnpzn

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

advnpzn avatar May 11 '24 08:05 advnpzn

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?

0xc60f avatar May 12 '24 20:05 0xc60f

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

advnpzn avatar May 12 '24 21:05 advnpzn

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.

0xc60f avatar May 12 '24 21:05 0xc60f