Skip to main content

Unofficial package to access Cookidoo.

Project description

Cookidoo API

PyPI version

An unofficial python package to access Cookidoo.

Unit tests Smoke test Ruff Mypy Markdownlint

GitHub Patreon BuyMeACoffee PayPal

Disclaimer

The developers of this module are in no way endorsed by or affiliated with Cookidoo or Vorwerk, or any associated subsidiaries, logos or trademarks.

Installation

Disclaimer: This library needs a runner (browser) to execute the calls through web automation. Make sure to have it correctly set up using one of the following options before proceeding.

Setup runner

Once you have tested your runner, install the cookidoo library and use it with your preferred browser.

pip install cookidoo-api

Documentation

See below for usage examples. See Exceptions for API-specific exceptions and mitigation strategies for common exceptions.

Usage Example

The API is based on the async implementation of the library playwright in collaboration with a runner for browser emulation.

Make sure to have stored your credentials in the top-level file .env as such, to loaded by dotenv. Alternatively, provide the environment variables by any other dotenv compatible means.

EMAIL=your@mail.com
PASSWORD=password

Run the example script and have a look at the inline comments for more explanation.

Exceptions

In case something goes wrong during a request, several exceptions can be thrown. They will either be

  • CookidooActionException
  • CookidooAuthBotDetectionException
  • CookidooAuthException
  • CookidooConfigException
  • CookidooNavigationException
  • CookidooSelectorException
  • CookidooUnavailableException
  • CookidooUnexpectedStateException

depending on the context. All inherit from CookidooException.

Another asyncio event loop is

With the async calls, you might encounter an error that another asyncio event loop is already running on the same thread. This is expected behavior according to the asyncio.run() documentation. You cannot use more than one aiohttp session per thread, reuse the existing one!

Exception ignored: RuntimeError: Event loop is closed

Due to a known issue in some versions of aiohttp when using Windows, you might encounter a similar error to this:

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000000>
Traceback (most recent call last):
  File "C:\...\py38\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\...\py38\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\...\py38\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\...\py38\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

You can fix this according to this StackOverflow answer by adding the following line of code before executing the library:

asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

Bot detection and captcha problems

There is an inbuilt bot detection on cookidoo which can block the login process. There is a clear error message, when that happens. The tokens are valid for a fixed duration and therefore the library tries to minimize the amount of logins required to avoid the captcha process. Unfortunately, this is not always possible when developing or debugging a setup, and you might run into it. To continue, either wait a day or switch to a runner with a gui and enable captcha mode to manually solve the captcha during the login or a service such as capsolver.

It is generally advised, to first try the login in fail mode and only activate a recovery mode on a CookidooAuthBotDetectionException raised.

Captcha recovery mode user_input

cookidoo = Cookidoo(<your headful browser setup>)
await cookidoo.login(captcha_recovery_mode="user_input")

Be aware, using this option with a headless browser will indefinitely block the process in login, as it is waiting for user action.

Captcha recovery mode capsolver

This requires the capsolver to be installed.

pip install capsolver
cookidoo = Cookidoo(<your browser setup>)
await cookidoo.login(captcha_recovery_mode="capsolver")

This is not yet implemented.

Alternatively, they also provide a browser extension, which might be a cleaner way.

Dev

Setup the dev environment using VSCode, it is highly recommended.

python -m venv .venv
source .venv/bin/activate
pip install -r requirements_dev.txt

Install pre-commit

pre-commit install

# Run the commit hooks manually
pre-commit run --all-files

Following VSCode integrations may be helpful:

CHANGELOG

0.1.0

Initial commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cookidoo_api-0.1.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

cookidoo_api-0.1.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file cookidoo_api-0.1.0.tar.gz.

File metadata

  • Download URL: cookidoo_api-0.1.0.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cookidoo_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a636da7ae8e8500c5be62b9f156add35ef78d871d1f9ad0215f0d3ced376b26d
MD5 4b64a9ac5bf2a6538450a36df20f1ad4
BLAKE2b-256 ae12e04256ed875a7bbeb2a82b524b38159d95a3d9427811fe87b0a89f3b3927

See more details on using hashes here.

File details

Details for the file cookidoo_api-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cookidoo_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cookidoo_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc70c54b1db900907067a4d7d07a65c6f544fe1d8cac8b94f572a874d9baaef6
MD5 478e4fc3dc624e83c16d824a0e0cd428
BLAKE2b-256 6df369dd234394939c6461b4a9550b4046f20745795bcc16eba3f69f87bce683

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page