{ "info": { "author": "NinjaSnail1080", "author_email": "innuganti.ashwin@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Internet", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "===========\nakinator.py\n===========\n\n**An API wrapper for the online game, Akinator, written in Python**\n\n.. image:: https://img.shields.io/badge/pypi-v5.0.0-blue.svg\n :target: https://pypi.python.org/pypi/akinator.py/\n\n.. image:: https://img.shields.io/badge/python-%E2%89%A53.5.3-yellow.svg\n :target: https://www.python.org/downloads/\n\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nCopyright \u00a9 2019 NinjaSnail1080\n\nLicensed under the MIT License (see ``LICENSE.txt`` for details).\n\n`Akinator.com `_ is an online game where you think of a character, real or fiction, and by asking you questions the site will try to guess who you're thinking of. This library allows for easy access to the Akinator API and makes writing programs that use it much simpler.\n\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\n**********\nInstalling\n**********\n\nTo install the regular library without async support, just run the following command::\n\n python3 -m pip install -U akinator.py\n\nOtherwise, to get asynchronous support, do::\n\n python3 -m pip install -U akinator.py[async]\n\nTo get async support plus faster performance (via the ``aiodns`` and ``cchardet`` libraries), do::\n\n python3 -m pip install -U akinator.py[fast_async]\n\nRequirements\n============\n\n- Python \u22653.5.3\n\n- ``requests``\n\n- ``aiohttp`` (Optional, for async)\n\n- ``aiodns`` and ``cchardet`` (Optional, for faster performance with async)\n\nUsually ``pip`` will handle these for you.\n\n**************\nQuick Examples\n**************\n\nHere's a quick little example of the library being used to make a simple, text-based Akinator game:\n\n.. code-block:: python\n\n import akinator\n\n aki = akinator.Akinator()\n\n q = aki.start_game()\n\n while aki.progression <= 80:\n a = input(q + \"\\n\\t\")\n if a == \"b\":\n try:\n q = aki.back()\n except akinator.CantGoBackAnyFurther:\n pass\n else:\n q = aki.answer(a)\n aki.win()\n\n correct = input(f\"It's {aki.first_guess['name']} ({aki.first_guess['description']})! Was I correct?\\n{aki.first_guess['absolute_picture_path']}\\n\\t\")\n if correct.lower() == \"yes\" or correct.lower() == \"y\":\n print(\"Yay\\n\")\n else:\n print(\"Oof\\n\")\n\nHere's the same game as above, but using the async version of the library instead:\n\n.. code-block:: python\n\n from akinator.async_aki import Akinator\n import akinator\n import asyncio\n\n aki = Akinator()\n\n async def main():\n q = await aki.start_game()\n\n while aki.progression <= 80:\n a = input(q + \"\\n\\t\")\n if a == \"b\":\n try:\n q = await aki.back()\n except akinator.CantGoBackAnyFurther:\n pass\n else:\n q = await aki.answer(a)\n await aki.win()\n\n correct = input(f\"It's {aki.first_guess['name']} ({aki.first_guess['description']})! Was I correct?\\n{aki.first_guess['absolute_picture_path']}\\n\\t\")\n if correct.lower() == \"yes\" or correct.lower() == \"y\":\n print(\"Yay\\n\")\n else:\n print(\"Oof\\n\")\n await aki.close()\n\n loop = asyncio.get_event_loop()\n loop.run_until_complete(main())\n loop.close()\n\n*************\nDocumentation\n*************\n\nBecause this library is relatively simple and only has a few functions to keep track of, all the documentation is going to go here in the README, instead of on a separate site like `readthedocs.io `_ or something.\n\nThe async version of this library works almost exactly the same as the regular, non-async one. For the most part, both have the same classes, names of functions, etc. Any differences will be noted.\n\n**Version Information**::\n\n >>> import akinator\n >>> akinator.__version__\n\nAlternatively, you can view the ``VERSION.txt`` file\n\n*class* Akinator()\n==================\n\nA class that represents an Akinator game.\n\nThe first thing you want to do after creating an instance of this class is to call ``Akinator.start_game()``.\n\nTo get the **regular** Akinator class, make sure you've put ``import akinator`` at the top of your code. From there you can easily access the class via ``akinator.Akinator()``.\n\nTo get the **async** version of the class, make sure you have ``import akinator.async_aki`` or ``from akinator.async_aki import Akinator`` in your code and you'll be able to get the async Akinator class just as easily (Refer to the code examples above).\n\nFunctions\n=========\n\n**Note**: In the async version, all the below functions are coroutines and must be awaited\n\nstart_game(*language=None, child_mode=False*)\n Start an Akinator game. Run this function first before the others. Returns a string containing the first question\n\n The ``language`` parameter can be left as None for English, the default language, or it can be set to one of the following (case-insensitive):\n\n - ``en``: English (default)\n - ``en_animals``: English server for guessing animals. Here, Akinator will attempt to guess the animal you're thinking instead of a character\n - ``en_objects``: English server for guessing objects. Here, Akinator will attempt to guess the object you're thinking instead of a character\n - ``ar``: Arabic\n - ``cn``: Chinese\n - ``de``: German\n - ``de_animals``: German server for guessing animals\n - ``es``: Spanish\n - ``es_animals``: Spanish server for guessing animals\n - ``fr``: French\n - ``fr_animals``: French server for guessing animals\n - ``fr_objects``: French server for guessing objects\n - ``il``: Hebrew\n - ``it``: Italian\n - ``it_animals``: Italian server for guessing animals\n - ``jp``: Japanese\n - ``jp_animals``: Japanese server for guessing animals\n - ``kr``: Korean\n - ``nl``: Dutch\n - ``pl``: Polish\n - ``pt``: Portuguese\n - ``ru``: Russian\n - ``tr``: Turkish\n - ``id``: Indonesian\n\n You can also put the name of the language spelled out, like ``spanish``, ``korean``, ``french_animals``, etc. If you put something else entirely, then then the ``InvalidLanguageError`` exception will be raised\n\n The ``child_mode`` parameter is False by default. If it's set to True, then Akinator won't ask questions about things that are NSFW\n\n **Important Note**: In the async version of the class, there's a third parameter: ``client_session`` (None by default). Here you can optionally specify an aiohttp ClientSession for the class functions to use when making API requests. If unspecified, a new ClientSession will be created\n\nanswer(*ans*)\n Answer the current question, which you can find with ``Akinator.question``. Returns a string containing the next question\n\n The ``ans`` parameter must be one of these (case-insensitive):\n\n - ``yes`` or ``y`` or ``0`` for YES\n - ``no`` or ``n`` or ``1`` for NO\n - ``i`` or ``idk`` or ``i dont know`` or ``i don't know`` or ``2`` for I DON'T KNOW\n - ``probably`` or ``p`` or ``3`` for PROBABLY\n - ``probably not`` or ``pn`` or ``4`` for PROBABLY NOT\n\n If it's something else, then the ``InvalidAnswerError`` exception will be raised\n\nback()\n Goes back to the previous question. Returns a string containing that question\n\n If you're on the first question and you try to go back, the ``CantGoBackAnyFurther`` exception will be raised\n\nwin()\n Get Aki's guesses for who the person you're thinking of is based on your answers to the questions so far\n\n This function defines and returns the variable ``Akinator.first_guess``, a dictionary describing his first choice for who you're thinking about. The three most important values in the dict are ``name`` (character's name), ``description`` (description of character), and ``absolute_picture_path`` (direct link to image of character)\n Here's an example of what the dict looks like:\n\n .. code-block:: javascript\n\n {'absolute_picture_path': 'https://photos.clarinea.fr/BL_25_en/600/partenaire/c/2367495__1106501382.png',\n 'award_id': '-1',\n 'corrupt': '0',\n 'description': 'Entrepreneur',\n 'flag_photo': 0,\n 'id': '49291',\n 'id_base': '2367495',\n 'name': 'Elon Musk',\n 'picture_path': 'partenaire/c/2367495__1106501382.png',\n 'proba': '0.925177',\n 'pseudo': 'Elon Musk',\n 'ranking': '229',\n 'relative': '0',\n 'valide_contrainte': '1'}\n\n This function also defines ``Akinator.guesses``, which is a list of dictionaries containing his choices in order from most likely to least likely\n\n It's recommended that you call this function when Aki's progression is above 80%. You can get his current progression via ``Akinator.progression``\n\nclose()\n **This function is only in the async version of the class**\n\n Close the aiohttp ClientSession. Call this function after the Akinator game is finished\n\n However, if you specified your own ClientSession in \"Akinator.start_game()\", you might actually not want to call this function\n\nVariables\n=========\n\nThese variables contain important information about the Akinator game. Please don't change any of these values in your program. It'll definitely break things.\n\nuri\n The uri this Akinator game is using. Depends on what you put for the language param in ``Akinator.start_game()`` (e.g., ``\"en.akinator.com\"``, ``\"fr.akinator.com\"``, etc.)\n\nserver\n The server this Akinator game is using. Depends on what you put for the language param in ``Akinator.start_game()`` (e.g., ``\"https://srv2.akinator.com:9162\"``, ``\"https://srv6.akinator.com:9127\"``, etc.)\n\nsession\n A number, usually in between 0 and 100, that represents the game's session\n\nsignature\n A usually 9 or 10 digit number that represents the game's signature\n\nuid\n The game's UID (unique identifier) for authentication purposes\n\nfrontaddr\n An IP address encoded in Base64; also for authentication purposes\n\nchild_mode\n A boolean that matches the child_mode param in ``Akinator.start_game()``\n\ntimestamp\n A POSIX timestamp for when ``Akinator.start_game()`` was called\n\nquestion\n The current question that Akinator is asking the user. Examples of questions asked by Aki include: ``Is your character's gender female?``, ``Is your character more than 40 years old?``, ``Does your character create music?``, ``Is your character real?``, ``Is your character from a TV series?``, etc.\n\nprogression\n A floating point number that represents a percentage showing how close Aki thinks he is to guessing your character. I recommend keeping track of this value and calling ``Akinator.win()`` when it's above 80 or 90. In most cases, this is about when Aki will have it narrowed down to one choice, which will hopefully be the correct one\n\nstep\n An integer that tells you what question Akinator is on. This will be 0 on the first question, 1 on the second question, 2 on the third, 3 on the fourth, etc.\n\nfirst_guess\n A dict that describes Akinator's first guess for who your character is. An example of what this dict will look like can be found in the documentation for the ``Akinator.win()`` function above. This variable will only be defined once that function is called\n\nguesses\n A list of dicts containing his choices in order from most likely to least likely. Each dict will look the same as ``first_guess``. This list will also contain ``first_guess`` as the first entry. This variable will only be defined once ``Akinator.win()`` is called\n\nclient_session\n An aiohttp ClientSession object that is used when making API requests. This variable is only present in the async version of the class\n\nThe first 8 variables\u2014``uri``, ``server``, ``session``, ``signature``, ``uid``, ``frontaddr``, ``child_mode``, and ``timestamp``\u2014will remain unchanged, but the next 3\u2014``question``, ``progression``, and ``step``\u2014will change as you go on. The final two\u2014``first_guess`` and ``guesses``\u2014 will only be defined when ``Akinator.win()`` is called.\n\n``client_session``, which is only in the async version of the class, will not change once it's been set, but calling ``Akinator.close()`` will reset it to None.\n\nExceptions\n==========\n\nExceptions that are thrown by the library\n\nInvalidAnswerError\n Raised when the user inputs an invalid answer into ``Akinator.answer()``. Subclassed from ``ValueError``\n\nInvalidLanguageError\n Raised when the user inputs an invalid language into ``Akinator.start_game()``. Subclassed from ``ValueError``\n\nAkiConnectionFailure\n Raised if the Akinator API fails to connect for some reason. Base class for ``AkiTimedOut``, ``AkiNoQuestions``, ``AkiServerDown``, and ``AkiTechnicalError``\n\nAkiTimedOut\n Raised if the Akinator session times out. Derived from ``AkiConnectionFailure``\n\nAkiNoQuestions\n Raised if the Akinator API runs out of questions to ask. This will happen if ``Akinator.step`` is at 79 and the ``answer`` function is called again. Derived from ``AkiConnectionFailure``\n\nAkiServerDown\n Raised if Akinator's servers are down for the region you're running on. If this happens, try again later or use a different language. Derived from ``AkiConnectionFailure``\n\nAkiTechnicalError\n Raised if Aki's servers had a technical error. If this happens, try again later or use a different language. Derived from ``AkiConnectionFailure``\n\nCantGoBackAnyFurther:\n Raised when the user is on the first question and tries to go back further by calling ``Akinator.back()``\n\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\n.. image:: https://img.shields.io/badge/Enjoy%20this%20library%3F-Say%20Thanks!-brightgreen.svg\n :target: https://saythanks.io/to/innuganti.ashwin%40gmail.com\n\n.. image:: https://img.shields.io/badge/Having%20problems%3F-Issues%20Tracker-blueviolet.svg\n :target: https://github.com/NinjaSnail1080/akinator.py/issues\n\n.. image:: https://img.shields.io/badge/License-MIT-red.svg\n :target: https://opensource.org/licenses/MIT\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/NinjaSnail1080/akinator.py", "keywords": "akinator api", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "akinator.py", "package_url": "https://pypi.org/project/akinator.py/", "platform": "", "project_url": "https://pypi.org/project/akinator.py/", "project_urls": { "Documentation": "https://github.com/NinjaSnail1080/akinator.py/blob/master/README.rst", "Homepage": "https://github.com/NinjaSnail1080/akinator.py", "Say Thanks!": "https://saythanks.io/to/innuganti.ashwin%40gmail.com", "Source": "https://github.com/NinjaSnail1080/akinator.py", "Tracker": "https://github.com/NinjaSnail1080/akinator.py/issues" }, "release_url": "https://pypi.org/project/akinator.py/5.0.0/", "requires_dist": [ "requests", "aiohttp ; extra == 'async'", "aiohttp ; extra == 'fast_async'", "cchardet ; extra == 'fast_async'", "aiodns ; extra == 'fast_async'" ], "requires_python": ">=3.5.3", "summary": "An API wrapper for the online game, Akinator, written in Python", "version": "5.0.0", "yanked": false, "yanked_reason": null }, "last_serial": 10716674, "releases": { "5.0.0": [ { "comment_text": "", "digests": { "md5": "b92d7c54ad9ec44c9df392555832ee8b", "sha256": "babec73a150dee7d873d653929ba7cc4c974ec66f560c20024dd85be3774f1b5" }, "downloads": -1, "filename": "akinator.py-5.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b92d7c54ad9ec44c9df392555832ee8b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5.3", "size": 20154, "upload_time": "2021-06-23T00:15:00", "upload_time_iso_8601": "2021-06-23T00:15:00.643562Z", "url": "https://files.pythonhosted.org/packages/20/87/5f19f40c29dab6f7da56c990496eef3b1525a616f6f43cf6e09f96577b09/akinator.py-5.0.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "02d7031552df03829a82c9ec7fa17614", "sha256": "0d5c9f2bbe35205c9bbf111e6a012d0690d70a58a3a5c2322a771050d84bc140" }, "downloads": -1, "filename": "akinator.py-5.0.0.tar.gz", "has_sig": false, "md5_digest": "02d7031552df03829a82c9ec7fa17614", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.3", "size": 16694, "upload_time": "2021-06-23T00:15:02", "upload_time_iso_8601": "2021-06-23T00:15:02.546151Z", "url": "https://files.pythonhosted.org/packages/31/7f/fb9c4a36ac8a2516946d3b4767b493450456383e0334581d273bc5e4c036/akinator.py-5.0.0.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b92d7c54ad9ec44c9df392555832ee8b", "sha256": "babec73a150dee7d873d653929ba7cc4c974ec66f560c20024dd85be3774f1b5" }, "downloads": -1, "filename": "akinator.py-5.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b92d7c54ad9ec44c9df392555832ee8b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5.3", "size": 20154, "upload_time": "2021-06-23T00:15:00", "upload_time_iso_8601": "2021-06-23T00:15:00.643562Z", "url": "https://files.pythonhosted.org/packages/20/87/5f19f40c29dab6f7da56c990496eef3b1525a616f6f43cf6e09f96577b09/akinator.py-5.0.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "02d7031552df03829a82c9ec7fa17614", "sha256": "0d5c9f2bbe35205c9bbf111e6a012d0690d70a58a3a5c2322a771050d84bc140" }, "downloads": -1, "filename": "akinator.py-5.0.0.tar.gz", "has_sig": false, "md5_digest": "02d7031552df03829a82c9ec7fa17614", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.3", "size": 16694, "upload_time": "2021-06-23T00:15:02", "upload_time_iso_8601": "2021-06-23T00:15:02.546151Z", "url": "https://files.pythonhosted.org/packages/31/7f/fb9c4a36ac8a2516946d3b4767b493450456383e0334581d273bc5e4c036/akinator.py-5.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }