Metadata-Version: 2.4
Name: sonarr-lang-checker
Version: 0.1.0
Summary: Controlla le discrepanze linguistiche tra episodi e stagioni in Sonarr
License-Expression: MIT
Project-URL: Repository, https://github.com/alsd4git/sonarr-lang-checker
Project-URL: Issues, https://github.com/alsd4git/sonarr-lang-checker/issues
Project-URL: Changelog, https://github.com/alsd4git/sonarr-lang-checker/blob/main/CHANGELOG.md
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests<3,>=2.32
Requires-Dist: python-dotenv<2,>=1.0
Dynamic: license-file

# sonarr-lang-checker

English · [Italiano](https://github.com/alsd4git/sonarr-lang-checker/blob/main/README.it.md)

[![CI](https://github.com/alsd4git/sonarr-lang-checker/actions/workflows/tests.yml/badge.svg)](https://github.com/alsd4git/sonarr-lang-checker/actions/workflows/tests.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](https://raw.githubusercontent.com/alsd4git/sonarr-lang-checker/main/LICENSE)

Find inconsistent audio-language coverage in a Sonarr v4 library. The CLI reports mixed-language seasons, compares seasons within a series, and checks whether episodes contain a requested set of languages.

![Terminal output from the CLI using a synthetic library; no Sonarr server was contacted.](https://raw.githubusercontent.com/alsd4git/sonarr-lang-checker/main/docs/demo-output.svg)

The demo uses synthetic series, episode, and audio-track fixtures with the real analysis and CLI output code. It does not contact Sonarr. Regenerate the image with `uv run python scripts/demo.py`.

Sonarr v4 is required. Earlier versions are not supported.

## Requirements

- Python 3.10 or newer
- [uv](https://docs.astral.sh/uv/)
- Git for installation from the GitHub source URL
- A Sonarr v4 URL and API key

## Installation

For versions listed on [PyPI](https://pypi.org/project/sonarr-lang-checker/), use `uv tool install sonarr-lang-checker` or `uvx --from sonarr-lang-checker sonarr-lang-checker --help`.

Install directly from the default branch on GitHub:

```bash
uv tool install git+https://github.com/alsd4git/sonarr-lang-checker.git
sonarr-lang-checker --help
```

For a one-off run without keeping the tool installed:

```bash
uvx --from git+https://github.com/alsd4git/sonarr-lang-checker.git sonarr-lang-checker --help
```

No packaged release has been published yet. Once a release exists, append its tag
to the Git URL, for example `@v0.1.0`, to select that version. The release workflow
builds wheel and source distributions. Maintainers follow the
[release procedure](RELEASING.md) to validate both artifacts and finalize
the prepared notes in [CHANGELOG.md](CHANGELOG.md) before tagging.

## Configuration

Create `.env` in the directory where you run the command:

```dotenv
API_KEY=replace-with-your-api-key
SONARR_URL=https://sonarr.example.org
```

Keep `.env` private. API keys passed as command-line arguments may be recorded in shell history or process listings.

## Usage

```bash
# Standard scan
sonarr-lang-checker

# Print JSON to stdout
sonarr-lang-checker --json

# Save structured results, including partial-failure metadata
sonarr-lang-checker --structured-json --output report.json

# Report missing or partial Italian and English coverage
sonarr-lang-checker --wanted-langs ita,eng

# Include seasons that fully match the requested languages
sonarr-lang-checker --wanted-langs ita,eng --show-all

# Reduce concurrent Sonarr requests
sonarr-lang-checker --workers 2
```

Use `sonarr-lang-checker --help` for the complete option list.

### Relevant options

| Option | Purpose |
| --- | --- |
| `--json` | Print the legacy JSON result shape to stdout. |
| `--structured-json` | Include `results`, `failures`, and `complete` metadata. |
| `--output PATH` | Write JSON output to a file. |
| `--wanted-langs LIST` | Check a comma-separated set such as `ita,eng`. |
| `--show-all` | Include monolingual or fully covered seasons. |
| `--ignore-unknown` | Exclude unknown audio tracks from language comparisons. |
| `--ignore-anime` | Skip series whose Sonarr type is Anime. |
| `--workers N` | Limit concurrent requests. The default is 4 and the maximum is 16. |
| `--timeout SECONDS` | Set the HTTP read timeout. |

Language codes are normalized before comparison. Track order does not matter, common aliases are unified, and unknown tracks use `und`.

## Exit codes

| Code | Meaning |
| --- | --- |
| `0` | The analysis completed. |
| `1` | A fatal configuration or request error prevented the analysis. |
| `2` | Partial results were produced because one or more series could not be fetched. |

Errors and partial-result summaries are written to stderr so JSON on stdout stays machine-readable.

## Development

```bash
git clone https://github.com/alsd4git/sonarr-lang-checker.git
cd sonarr-lang-checker
uv sync --locked --dev
uv run sonarr-lang-checker --help
uv run ruff format --check .
uv run ruff check .
uv run pytest -q
uv build
```

`main.py` remains directly executable for compatibility, but the installed `sonarr-lang-checker` entry point is the preferred user-facing interface.

GitHub Actions runs tests on Linux, macOS, and Windows with Python 3.10–3.15.
Formatting, lint, and the package smoke test run once
on Linux with Python 3.15.

## License

Released under the [MIT License](https://github.com/alsd4git/sonarr-lang-checker/blob/main/LICENSE).
