Metadata-Version: 2.4
Name: pinchana-core
Version: 26.11.15
Summary: Shared models, storage, and VPN controller for scraper services
License-Expression: MIT
License-File: LICENSE
Requires-Dist: aiohttp>=3.14.5
Requires-Dist: fastapi>=0.162.2
Requires-Dist: httpx>=0.28.1
Requires-Dist: pillow>=13.0.0
Requires-Dist: pydantic>=2.14.3
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: starlette>=1.10.0,<2.0.0
Requires-Dist: tenacity>=9.2.1
Requires-Dist: yt-dlp[default,deno]>=2026.10.26
Requires-Python: >=3.13
Project-URL: Repository, https://github.com/Pinchana/pinchana-api
Project-URL: Issues, https://github.com/Pinchana/pinchana-api/issues
Description-Content-Type: text/markdown

# Pinchana Core

Pinchana Core is the shared Python library used by the Pinchana gateway and platform modules. It provides common request and legacy response models, cache storage, music extraction helpers, VPN control, module lifecycle support, and the in-process plugin registry.

## Main packages

- `pinchana_core.models` defines the shared Pydantic request and module response types.
- `pinchana_core.storage` downloads media, resolves cache paths, and evicts the oldest post directories when the configured size limit is exceeded.
- `pinchana_core.music` contains common behavior for the music platform modules.
- `pinchana_core.vpn` checks the tunnel, Gluetun DNS process, and a real DNS
  lookup before reporting the VPN ready, and safely reconnects the tunnel.
- `pinchana_core.docker_manager` reads module configuration and performs optional container lifecycle operations.
- `pinchana_core.plugins` registers modules that run inside the gateway process during development.

The gateway, rather than this package, converts module responses to the public API v1 `{data, meta}` contract.

## Development

Run commands from this directory:

```sh
uv sync --frozen
uv run python -c "import pinchana_core; print('pinchana_core imported')"
```

Other repository modules consume this package through a local uv path dependency. Docker builds must use the parent `pinchana-api` directory as their build context because module Dockerfiles copy both this package and the selected service.

The DNS readiness probe resolves `cloudflare.com` with a five-second timeout.
Direct deployments may override these defaults with
`VPN_DNS_PROBE_HOSTNAME` and `VPN_DNS_PROBE_TIMEOUT_SECONDS`.

## Security notes

Treat cached media as private operational data. Do not expose arbitrary cache paths, Gluetun control port 8000, or Docker lifecycle operations to the public Internet. `CONTAINER_MODE=false` disables lifecycle routes but does not remove an existing Docker socket mount.

## License

MIT. See `LICENSE` in the repository root.
