Skip to content

Examples

Stephen Cox edited this page Dec 10, 2025 · 4 revisions

Examples

This section provides real-world rule examples organised by common use cases.

Content Organisation

Auto-Categorise Movies

- name: "Auto-categorize HD movies"
  enabled: true
  stop_on_match: true
  conditions:
    trigger: on_added
    all:
      - field: info.name
        operator: matches
        value: '(?i).*(1080p|2160p|4k).*\.(mkv|mp4|avi)$'
  actions:
    - type: set_category
      params:
        category: "Movies-HD"
    - type: add_tag
      params:
        tag: "movies"

Auto-Categorize TV Shows

- name: "Auto-categorize TV shows"
  enabled: true
  stop_on_match: true
  conditions:
    trigger: on_added
    all:
      - field: info.name
        operator: matches
        value: '(?i).*[Ss]\d{2}[Ee]\d{2}.*'
  actions:
    - type: set_category
      params:
        category: "TV-Shows"
    - type: add_tag
      params:
        tag: "tv"

Organize by Tracker

- name: "Categorize private tracker content"
  enabled: true
  stop_on_match: true
  conditions:
    trigger: on_added
    any:
      - field: trackers.url
        operator: contains
        value: "privatehd.to"
      - field: trackers.url
        operator: contains
        value: "passthepopcorn.me"
  actions:
    - type: set_category
      params:
        category: "Private"
    - type: add_tag
      params:
        tag: "private-tracker"

9.2 Content Filtering

Block Archive Files

- name: "Remove torrents with only archives"
  enabled: true
  stop_on_match: true
  conditions:
    trigger: on_added
    all:
      - field: files.name
        operator: matches
        value: '(?i).*\.(rar|zip|7z|tar|gz)$'
  actions:
    - type: delete_torrent
      params:
        delete_files: true

Remove Sample Files

- name: "Delete torrents with sample files"
  enabled: true
  stop_on_match: true
  conditions:
    trigger: on_added
    any:
      - field: info.name
        operator: contains
        value: "sample"
      - field: files.name
        operator: contains
        value: "sample"
  actions:
    - type: delete_torrent
      params:
        delete_files: true

Filter by Size

- name: "Remove torrents too small"
  enabled: true
  conditions:
    trigger: on_added
    all:
      - field: info.size
        operator: "<"
        value: 104857600  # < 100MB
      - field: info.category
        operator: "=="
        value: "Movies"
  actions:
    - type: delete_torrent
      params:
        delete_files: true

9.3 Tracker Management

Tag Private Trackers

- name: "Tag all private tracker torrents"
  enabled: true
  conditions:
    trigger: manual
    all:
      - field: trackers.url
        operator: not_contains
        value: "public"
  actions:
    - type: add_tag
      params:
        tag: "private"

Force Start on Specific Tracker

- name: "Force start low-seeded torrents on private trackers"
  enabled: true
  conditions:
    trigger: manual
    all:
      - field: trackers.url
        operator: contains
        value: "privatehd.to"
      - field: info.num_complete
        operator: "<"
        value: 3
  actions:
    - type: force_start

Reannounce Stalled Trackers

- name: "Reannounce torrents with tracker errors"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: trackers.msg
        operator: not_contains
        value: "Working"
      - field: info.state
        operator: "=="
        value: "stalledUP"
  actions:
    - type: reannounce

9.4 Cleanup & Maintenance

Remove Old Completed Torrents

- name: "Delete old completed torrents"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: info.state
        operator: in
        value: ["uploading", "pausedUP", "stalledUP"]
      - field: info.completion_on
        operator: older_than
        value: 2592000  # 30 days
      - field: info.ratio
        operator: ">="
        value: 1.0
  actions:
    - type: delete_torrent
      params:
        delete_files: false

Remove Stalled Downloads

- name: "Delete stalled downloads after 7 days"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: info.state
        operator: "=="
        value: "stalledDL"
      - field: info.added_on
        operator: older_than
        value: 604800  # 7 days
  actions:
    - type: delete_torrent
      params:
        delete_files: true

Clean Up Errored Torrents

- name: "Remove errored torrents"
  enabled: true
  conditions:
    trigger: scheduled
    any:
      - field: info.state
        operator: "=="
        value: "error"
      - field: info.state
        operator: "=="
        value: "missingFiles"
  actions:
    - type: delete_torrent
      params:
        delete_files: false

9.5 Seeding Management

Pause Well-Seeded Torrents

- name: "Pause torrents with high ratio and seeders"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: info.ratio
        operator: ">="
        value: 2.0
      - field: info.num_complete
        operator: ">"
        value: 10
      - field: info.state
        operator: "=="
        value: "uploading"
  actions:
    - type: stop

Start Underseded Torrents

- name: "Force start torrents with low seeders"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: info.num_complete
        operator: "<="
        value: 2
      - field: info.state
        operator: in
        value: ["pausedUP", "stalledUP"]
  actions:
    - type: force_start

Throttle Old Torrents

- name: "Limit upload speed for old torrents"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: info.completion_on
        operator: older_than
        value: 1209600  # 14 days
      - field: info.ratio
        operator: ">="
        value: 1.5
  actions:
    - type: set_upload_limit
      params:
        limit: 524288  # 512 KB/s

9.6 Error Handling & Recovery

Recheck Missing Files

- name: "Recheck torrents with missing files"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: info.state
        operator: "=="
        value: "missingFiles"
  actions:
    - type: recheck

Remove Errored Torrents After Retry

- name: "Delete permanently errored torrents"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: info.state
        operator: "=="
        value: "error"
      - field: info.added_on
        operator: older_than
        value: 259200  # 3 days
  actions:
    - type: delete_torrent
      params:
        delete_files: false

Auto-Resume Paused Downloads

- name: "Resume paused downloads with activity"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: info.state
        operator: "=="
        value: "pausedDL"
      - field: info.availability
        operator: ">"
        value: 0.5
  actions:
    - type: start

9.7 Advanced Multi-Criteria Rules

Complex Download Management

- name: "Manage large, slow downloads"
  enabled: true
  conditions:
    trigger: scheduled
    all:
      - field: info.size
        operator: ">"
        value: 10737418240  # > 10GB
      - field: info.state
        operator: "=="
        value: "downloading"
      - field: info.dlspeed
        operator: "<"
        value: 102400  # < 100 KB/s
      - field: info.added_on
        operator: newer_than
        value: 86400  # < 1 day old
    none:
      - field: info.category
        operator: "=="
        value: "Priority"
  actions:
    - type: set_download_limit
      params:
        limit: 1048576  # 1 MB/s max
    - type: add_tag
      params:
        tag: "throttled"

Conditional Seeding Strategy

- name: "Smart seeding based on ratio and time"
  enabled: true
  conditions:
    trigger: on_completed
    any:
      # High ratio achieved
      - field: info.ratio
        operator: ">="
        value: 3.0
      # OR seeded for 30 days with ratio >= 1.0
      - all:
          - field: info.completion_on
            operator: older_than
            value: 2592000  # 30 days
          - field: info.ratio
            operator: ">="
            value: 1.0
  actions:
    - type: stop
    - type: add_tag
      params:
        tag: "seeding-complete"

Private Tracker Automation

- name: "Private tracker: force seed low-seeded content"
  enabled: true
  conditions:
    trigger: on_completed
    all:
      - field: trackers.url
        operator: contains
        value: "passthepopcorn.me"
      - field: info.num_complete
        operator: "<="
        value: 5
  actions:
    - type: force_start
    - type: set_category
      params:
        category: "Private-Important"
    - type: add_tag
      params:
        tag: "must-seed"
    - type: set_upload_limit
      params:
        limit: -1  # Unlimited

9.8 Scheduled Maintenance Example

# Daily cleanup at 3 AM
- name: "Daily cleanup: remove completed torrents"
  enabled: true
  conditions:
    trigger: scheduled
    schedule: "0 3 * * *"
    all:
      - field: info.state
        operator: in
        value: ["pausedUP", "stalledUP"]
      - field: info.ratio
        operator: ">="
        value: 2.0
      - field: info.completion_on
        operator: older_than
        value: 604800  # 7 days
  actions:
    - type: delete_torrent
      params:
        delete_files: false

# Weekly recheck of all torrents
- name: "Weekly integrity check"
  enabled: true
  conditions:
    trigger: scheduled
    schedule: "0 4 * * 0"  # Sundays at 4 AM
    all:
      - field: info.state
        operator: in
        value: ["uploading", "stalledUP"]
  actions:
    - type: recheck

9.9 Webhook Integration Example

# Auto-categorize on add
- name: "Webhook: Categorize new downloads"
  enabled: true
  conditions:
    trigger: on_added
    any:
      - field: info.name
        operator: matches
        value: '(?i).*\.(mkv|mp4|avi)$'
      - field: files.name
        operator: matches
        value: '(?i).*\.(mkv|mp4|avi)$'
  actions:
    - type: set_category
      params:
        category: "Videos"
    - type: add_tag
      params:
        tag: "auto-categorized"

# Post-completion actions
- name: "Webhook: Tag completed downloads"
  enabled: true
  conditions:
    trigger: on_completed
    all:
      - field: info.ratio
        operator: "<"
        value: 1.0
  actions:
    - type: add_tag
      params:
        tag: "needs-seeding"
    - type: force_start

🎯 qbt-rules

v0.3.0 | GitHub


📚 Getting Started

📖 Core Concepts

🔧 Configuration

🆘 Help & Support

🤝 Contributing


🆕 What's New (v0.3.0)

  • ✅ Unified CLI (qbt-rules)
  • ✅ Custom triggers
  • ✅ Trigger-agnostic mode
  • ✅ Size operators (50GB)

🔗 Quick Links

Clone this wiki locally