Skip to content

qbit-guard logo Installation Guide

qbit-guard can be deployed in two ways: as a containerized service (recommended) or as a traditional script. Choose the method that best fits your setup.


The containerized version runs as a standalone service that continuously monitors qBittorrent, eliminating the need for webhook configuration.

Prerequisites

Quick Start

  1. Pull the official image:

    Bash
    # Linux/macOS/Windows (PowerShell/Command Prompt)
    docker pull ghcr.io/gengines/qbit-guard:latest
    

  2. Create a basic docker-compose.yml:

    YAML
    version: '3.8'
    services:
      qbit-guard:
        image: ghcr.io/gengines/qbit-guard:latest
        container_name: qbit-guard
        restart: unless-stopped
        environment:
          - QBIT_HOST=http://qbittorrent:8080
          - QBIT_USER=admin
          - QBIT_PASS=your_password
          - QBIT_ALLOWED_CATEGORIES=tv-sonarr,radarr
          - ENABLE_PREAIR_CHECK=1
          - SONARR_URL=http://sonarr:8989
          - SONARR_APIKEY=your_api_key
          - LOG_LEVEL=INFO
        networks:
          - arr-network
    
    networks:
      arr-network:
        driver: bridge
    

  3. Start the service:

    Bash
    # Linux/macOS/Windows (PowerShell/Command Prompt)
    docker-compose up -d
    

Container Modes

Polling Mode (Default): The container continuously polls qBittorrent's API for new torrents. This is the recommended approach as it: - Requires no qBittorrent webhook configuration - Works reliably across container restarts - Handles network interruptions gracefully - Provides better visibility into processing status

Webhook Mode: Configure qBittorrent to call the container on torrent add events. This requires: - Exposing the container port (8080:8080) - Configuring qBittorrent's "Run external program" setting to call http://qbit-guard:8080/webhook - Additional network connectivity setup - More complex debugging when issues arise

For most users, polling mode is simpler and more reliable.

Windows-Specific Considerations

When running Docker containers on Windows, consider these additional points:

  • Volume Mounts: Windows paths in docker-compose.yml should use forward slashes or escaped backslashes:

    YAML
    1
    2
    3
    4
    5
    # Correct Windows path syntax
    volumes:
      - "C:/qbit-guard/config:/config"
      # or
      - "C:\\qbit-guard\\config:/config"
    

  • Network Connectivity: If running qBittorrent natively on Windows (not in Docker), use host.docker.internal instead of localhost or 127.0.0.1 to access it from containers:

    YAML
    environment:
      - QBIT_HOST=http://host.docker.internal:8080
    

  • Docker Desktop Settings: Ensure "Use Docker Compose V2" is enabled in Docker Desktop settings for better compatibility.

Network Requirements

qbit-guard needs network connectivity to your services:

  • qBittorrent API: HTTP access to qBittorrent's Web UI (default port 8080)
  • Sonarr API: HTTP access to Sonarr (default port 8989)
  • Radarr API: HTTP access to Radarr (default port 7878)
  • Internet APIs: HTTPS access to TVmaze and TheTVDB for cross-verification

Docker Compose Networking

Create a shared network for all services:

YAML
1
2
3
networks:
  arr-network:
    driver: bridge

All services (qbit-guard, qbittorrent, sonarr, radarr) should use the same network to enable service discovery by container name.


Script Installation (Traditional)

For users who prefer the traditional webhook approach or need to customize the deployment:

Prerequisites

  • Python 3.8+ installed
  • Linux/macOS: Install via package manager or python.org
  • Windows: Download from python.org and ensure "Add Python to PATH" is checked during installation
  • qBittorrent with WebUI enabled
  • Sonarr/Radarr accessible (optional)

Installation Steps

  1. Download and make executable:

Linux/macOS:

Bash
curl -o /config/scripts/qbit-guard.py https://raw.githubusercontent.com/GEngines/qbit-guard/main/src/guard.py
chmod +x /config/scripts/qbit-guard.py

Windows (PowerShell):

PowerShell
1
2
3
4
5
# Create the scripts directory in user profile
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\qbit-guard\scripts"

# Download the script
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/GEngines/qbit-guard/main/src/guard.py" -OutFile "$env:USERPROFILE\qbit-guard\scripts\qbit-guard.py"

Windows (Command Prompt with curl):

Text Only
mkdir "%USERPROFILE%\qbit-guard\scripts" 2>nul
curl -o "%USERPROFILE%\qbit-guard\scripts\qbit-guard.py" https://raw.githubusercontent.com/GEngines/qbit-guard/main/src/guard.py

Manual Download (All Platforms):

If you prefer to download manually or the above commands don't work:

  1. Create the directory structure:

    • Linux/macOS: /config/scripts/
    • Windows: %USERPROFILE%\qbit-guard\scripts\ (typically C:\Users\YourUsername\qbit-guard\scripts\)
  2. Download the script file:

  3. Linux/macOS only: Make the script executable:

    Bash
    chmod +x /config/scripts/qbit-guard.py
    

  4. Configure qBittorrent:

  5. Navigate to OptionsDownloadsRun external program
  6. Run on torrent added:

    Linux/macOS:

    Bash
    /usr/bin/python3 /config/scripts/qbit-guard.py %I %L
    

    Windows:

    Text Only
    python "%USERPROFILE%\qbit-guard\scripts\qbit-guard.py" %I %L
    

    Note for Windows: Use the full path to python.exe if python command is not in PATH:

    Text Only
    "C:\Python39\python.exe" "%USERPROFILE%\qbit-guard\scripts\qbit-guard.py" %I %L
    

  7. Important: Remove any existing "Run on torrent added" scripts to avoid conflicts

  8. Set environment variables in your container/docker-compose file

  9. Restart qBittorrent

Windows Troubleshooting

Common issues and solutions for Windows users:

  • Python not found: Ensure Python is installed and added to PATH. Test with python --version in Command Prompt.
  • Script execution policy: If using PowerShell and getting execution policy errors:
    PowerShell
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    
  • File permissions: Windows doesn't require chmod, but ensure the script file is not marked as blocked. Right-click → Properties → General → Unblock if present.
  • Path separators: Always use forward slashes in URLs and environment variables, even on Windows.
  • qBittorrent service account: If running qBittorrent as a Windows service, ensure it has permission to execute the Python script.

Script Mode vs Container Mode

FeatureContainer ModeScript Mode
Setup ComplexitySimpleModerate
Webhook RequiredNoYes
Continuous MonitoringYesPer-torrent
Container RestartsGracefulManual reconfig
Resource UsageSingle processPer-execution
DebuggingCentralized logsPer-execution logs
Recommended ForMost usersAdvanced setups

Next Steps

After installation, proceed to:

Tip: A complete working docker-compose.yml file is included in the repository root with all configuration options documented.