qbit-guard¶
A zero-dependency Python guard for qBittorrent that provides intelligent torrent management with pre-air checking and ISO/BDMV cleanup.
Get Started
Install and configure qbit-guard in minutes
Configuration
Environment-driven configuration with sensible defaults
Examples
Real-world deployment scenarios and configurations
Support
Troubleshooting guide and development resources
Features¶
Intelligent Torrent Management
qbit-guard automatically manages your torrents with smart filtering and cleanup rules.
Stops new TV torrents and validates air dates
- Checks
airDateUtc
with configurable grace/cap windows - Supports release group / indexer / tracker whitelisting
- Blocks too-early releases automatically
- Integrates with Sonarr for metadata validation
Removes disc-image-only torrents
- Detects ISO/IMG/MDF/NRG/CUE/BIN files
- Identifies
BDMV
andVIDEO_TS
folders - Preserves torrents with keepable video files
- Configurable minimum file size thresholds
Automated blocklist management
- Blocklists in Sonarr/Radarr before deletion
- Uses deduped history (single "grabbed" record per unique release)
- Queue failover if history endpoint times out
- Prevents duplicate downloads
Optional internet verification
- TVmaze and/or TheTVDB integration
- Cross-checks Sonarr air dates
- Improves accuracy of pre-air filtering
- No API keys required for TVmaze
Works with modern and legacy versions
- qBittorrent 5.x - Preferred with start/stop support
- qBittorrent 4.x - Uses resume/pause fallback
- WebUI authentication support
- Category-based filtering
Container-friendly and lightweight
- Pure Python 3.8+ standard library
- Environment variable configuration
- Structured JSON logging to stdout
- Minimal resource usage
How it Works¶
flowchart TD
A[Torrent Added] --> B{Category Check}
B -->|Allowed| C[Stop & Tag: guard:stopped]
B -->|Blocked| Z[Ignore]
C --> D{Pre-air Gate}
D -->|Enabled| E[Check Sonarr API]
D -->|Disabled| F[Get Metadata]
E --> G{Air Date Check}
G -->|Too Early| H[Blocklist & Delete]
G -->|Allowed| F[Get Metadata]
F --> I{ISO/BDMV Check}
I -->|Disc Image Only| J[Blocklist & Delete]
I -->|Has Video| K[Tag: guard:allowed & Start]
H --> L[Tag: trash:preair]
J --> M[Tag: trash:iso]
K --> N[Active Download]
Flow Steps
- On add → torrent immediately stopped and tagged
guard:stopped
- Category filter → only
QBIT_ALLOWED_CATEGORIES
are processed - Pre-air gate (if Sonarr category): consult Sonarr (+ optional TVmaze/TVDB)
- If blocked → blocklist in *arr, tag
trash:preair
, delete torrent - If allowed → continue
- If blocked → blocklist in *arr, tag
- Metadata fetch → briefly start torrent to get file list, respect wait/budget limits, then stop
- ISO/BDMV cleanup → if disc-image-only and no keepable video, blocklist + delete (tag
trash:iso
) - Start for real → tag
guard:allowed
and start torrent
Keepable Video Files
Files with extensions: .mkv .mp4 .m4v .avi .ts .m2ts .mov .webm
and size ≥ threshold.
Requirements¶
Prerequisites
Ensure all services are properly networked and accessible between containers.
Component | Version | Purpose | Required |
---|---|---|---|
qBittorrent | 5.x (4.x supported) | Torrent client | Required |
Python | 3.8+ | Script mode only | Optional |
Sonarr | v3+ | Pre-air checking | Optional |
Radarr | v3+ | Pre-air checking | Optional |
Network | - | Service connectivity | Required |
Quick Start¶
Next Steps
After starting qbit-guard, check the logs to ensure it connects successfully to qBittorrent and any configured *arr services.
Documentation¶
- Installation Guide - Detailed setup instructions
- Configuration Guide - Complete configuration options
- Environment Variables - Full variable reference
- Examples - Real-world deployment scenarios
- Development - Development and contribution guide
- Troubleshooting - Common issues and solutions