Metadata-Version: 2.4
Name: pdf2mela
Version: 0.1.0
Summary: Convert PDF recipes to .melarecipe format using Mistral OCR
Project-URL: Homepage, https://github.com/jjakubassa/pdf2mela
Project-URL: Issues, https://github.com/jjakubassa/pdf2mela/issues
Author-email: Jonas Jakubassa <jakubassa@posteo.de>
License: MIT
License-File: LICENSE
Keywords: mistral,ocr,recipes
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.11
Requires-Dist: loguru>=0.7.3
Requires-Dist: mistralai>=1.12.4
Requires-Dist: pydantic>=2.12.5
Requires-Dist: tenacity>=9.1.4
Requires-Dist: tyro>=1.0.8
Description-Content-Type: text/markdown

# pdf2mela

Convert scanned PDF recipes to [Mela](https://mela.recipes) format using Mistral OCR.

- Single PDF → `.melarecipe` (JSON)
- Multiple PDFs → `.melarecipes` (ZIP)

## Requirements

- Python 3.11+
- [uv](https://docs.astral.sh/uv/)
- A [Mistral API key](https://console.mistral.ai)

## Installation

```sh
git clone git@github.com:jjakubassa/pdf2mela.git
cd pdf2mela
uv sync
```

## Usage

```sh
# Single file
uv run pdf2mela --inputs recipe.pdf

# Multiple files
uv run pdf2mela --inputs recipe1.pdf recipe2.pdf

# Whole directory
uv run pdf2mela --inputs ./scans/

# Custom output directory
uv run pdf2mela --inputs ./scans/ --output ./mela/

# Explicit API key
uv run pdf2mela --inputs recipe.pdf --api-key YOUR_KEY
```

The Mistral API key is read from the `MISTRAL_API_KEY` environment variable by default.

## Pricing

Mistral OCR costs **$2 per 1,000 pages**. The tool prints an estimated cost at the end of each run, including what it would have cost with the 50% batch discount.

## Notes

- Recipes are extracted in their original language — no translation is applied.
- All PDFs in a run are processed concurrently.
- Failed requests are retried up to 3 times with exponential backoff.
- Set `LOGLEVEL=DEBUG` to see raw OCR responses.
