Files
ncore-hnr/README.md
Zsolt Alföldi ecea084003 Add support for notification dry run feature
- Introduced NOTIFICATION_DRY_RUN configuration option in .env.example and k8s/secret.example.yaml.
- Updated README.md to include usage instructions for the new dry run feature.
- Implemented logic in app.go to preview notifications without sending them when the dry run option is enabled.
- Enhanced config.go to load the new configuration option and validate notification types accordingly.
- Added a new function in notify.go to generate manual-needed notification messages for preview.
2026-05-07 00:35:05 +02:00

107 lines
2.5 KiB
Markdown

# ncore-hnr
Go app for checking nCore hit'n'run-risk torrents, force-starting matching qBittorrent torrents, and tracking state in SQLite.
## Configuration
Put local config in `.env`:
```bash
NCORE_USERNAME='your-ncore-username'
NCORE_PASSWORD='your-ncore-password'
QBITTORRENT_URL='http://localhost:8080'
QBITTORRENT_USERNAME='admin'
QBITTORRENT_PASSWORD='your-qbit-password'
APP_DB_PATH='data/ncore-hnr.sqlite'
DRY_RUN='false'
ALERT_AFTER='48h'
# Optional notifications: set NOTIFICATION_TYPE to 'ntfy' or 'smtp'.
NOTIFICATION_DRY_RUN='false'
NOTIFICATION_TYPE=''
NOTIFICATION_NTFY_URL=''
NOTIFICATION_SMTP_HOST=''
NOTIFICATION_SMTP_PORT='587'
NOTIFICATION_SMTP_USERNAME=''
NOTIFICATION_SMTP_PASSWORD=''
NOTIFICATION_SMTP_FROM=''
NOTIFICATION_SMTP_TO=''
```
`DRY_RUN=false` is the default and will call qBittorrent `setForceStart` and `reannounce`. Use `--dry-run=true` when you only want to preview matches.
Use `--notification-dry-run=true` to print the manual-needed notification subject/body without sending it.
Set `NOTIFICATION_TYPE=ntfy` and `NOTIFICATION_NTFY_URL='https://ntfy.sh/your-secret-topic'` to send manual-needed alerts through ntfy. For compatibility, old `NOTIFY_URL` values still work as the ntfy URL.
Set `NOTIFICATION_TYPE=smtp` to send manual-needed alerts by email. For Gmail, use:
```bash
NOTIFICATION_SMTP_HOST='smtp.gmail.com'
NOTIFICATION_SMTP_PORT='587'
NOTIFICATION_SMTP_USERNAME='youraddress@gmail.com'
NOTIFICATION_SMTP_PASSWORD='your-gmail-app-password'
NOTIFICATION_SMTP_FROM='ncore <youraddress@gmail.com>'
NOTIFICATION_SMTP_TO='target@example.com'
```
## Run
```bash
go run ./cmd/ncore-hnr
```
Preview without qBittorrent actions:
```bash
go run ./cmd/ncore-hnr --dry-run=true
```
Preview the notification body without sending it:
```bash
go run ./cmd/ncore-hnr --dry-run=true --alert-after=0s --notification-dry-run=true
```
JSON output:
```bash
go run ./cmd/ncore-hnr --json
```
## SQLite Views
Show aggregate statistics and the latest run:
```bash
go run ./cmd/ncore-hnr stats
```
Show tracked torrent status rows:
```bash
go run ./cmd/ncore-hnr status
```
Both read-only commands support JSON and a custom DB path:
```bash
go run ./cmd/ncore-hnr status --json
go run ./cmd/ncore-hnr stats --db data/ncore-hnr.sqlite
```
## Docker
```bash
docker build -t ncore-hnr:local .
docker run --rm --env-file .env -v "$PWD/data:/data" ncore-hnr:local
```
## Kubernetes
The `k8s/` folder contains a CronJob, PVC, and example Secret. Store real secrets out of git.