Metadata-Version: 2.5
Name: pyIntradel
Version: 0.1.0b2
Summary: Python interface for Intradel
Project-URL: Homepage, https://github.com/thomasgermain/pyintradel
Author-email: Thomas Germain <12560542+thomasgermain@users.noreply.github.com>
License: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Home Automation
Requires-Python: >=3.13
Requires-Dist: aiohttp<4.0,>=3.11
Requires-Dist: beautifulsoup4<5.0,>=4.15
Description-Content-Type: text/markdown

# pyIntradel

![PyPI - License](https://img.shields.io/github/license/thomasgermain/pyIntradel)
![PyPI](https://img.shields.io/pypi/v/pyIntradel)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyIntradel.svg)

A python connector for waste collection for province of Liège. This connector is using screen scraping to collect
following data (for the current year), in json:
- "Green bin" (organic waste) and "black bin" residual waste
  - Total weight
  - Number of collections
  - details of all the collections
  - chip number
  - starting date (01/01 of the current year)
- Recypark
  - details of all the visits
  - (01/01 of the current year)

Here is an example of json:

```json
[
    {
        "name": "ORGANIQUE",
        "start_date": "01-01-2022",
        "id": "123456",
        "details":
        [
            {
                "date": "20-01-2022",
                "detail": "34.0"
            },
            {
                "date": "17-02-2022",
                "detail": "27.0"
            },
            {
                "date": "07-04-2022",
                "detail": "36.0"
            }
        ],
        "total": "97"
    },
    {
        "name": "RESIDUEL",
        "start_date": "01-01-2022",
        "id": "78810",
        "details":
        [
            {
                "date": "20-01-2022",
                "detail": "14.5"
            },
            {
                "date": "07-04-2022",
                "detail": "11.5"
            },
            {
                "date": "21-04-2022",
                "detail": "11.5"
            }
        ],
        "total": "37.5"
    },
    {
        "name": "RECYPARC",
        "start_date": "01-01-2022",
        "id": "RECYPARC",
        "details":
        [
            {
                "date": "14-04-2022",
                "detail": "Encombrants (0.35 m³), Petits Bruns (0.00 pièce)"
            }
        ],
        "total": "1"
    }
]
```

## Usage

The intradel.be login form is protected by an invisible reCAPTCHA, so this library
cannot log in by itself. Authenticate once in a real browser, then pass the resulting
session cookie (the raw `Cookie` header, e.g. `PHPSESSID=...`).

Errors raised by `api.get_data`, all subclasses of `api.IntradelError` (itself a `ValueError`):
- `api.AuthenticationError`: the cookie has expired or is invalid; log in again in the
  browser and use the new cookie.
- `api.ApiError`: unexpected HTTP status, available as `.status`.
- `api.ParseError`: the page structure is not the expected one, likely after a website change.

### Python module

```python
import aiohttp
from pyintradel import api

async with aiohttp.ClientSession() as sess:
    await api.get_data(sess, cookie)
```

### Command line
```bash
python3 -m pyintradel.main --cookie "PHPSESSID=..."
```

## Development

The project uses [uv](https://docs.astral.sh/uv/):

```bash
uv sync                  # create .venv with the dev tools from uv.lock
uv run pytest
uv run ruff check
uv run ruff format
uv run mypy
uv build                 # sdist and wheel in dist/
```

Install the git pre-commit hook once per clone; it runs ruff (lint with autofix, format) and
checks that `uv.lock` matches `pyproject.toml` before each commit:

```bash
uv tool install pre-commit
pre-commit install
pre-commit run --all-files   # optional: run the hooks on the whole repository
```

CI runs the same checks plus mypy and the tests, so skipping the hook only delays the feedback.

To release, publish a GitHub release whose tag is the new version (e.g. `0.1.0`): the
version is derived from the tag, and CI publishes to PyPI once the checks pass.

---
<a href="https://www.buymeacoffee.com/tgermain" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
