Skip to content

feat: add content_path filter for precise torrent deletion#207

Open
sysit wants to merge 1 commit into
jerrymakesjelly:masterfrom
sysit:feature/content-path-filter
Open

feat: add content_path filter for precise torrent deletion#207
sysit wants to merge 1 commit into
jerrymakesjelly:masterfrom
sysit:feature/content-path-filter

Conversation

@sysit
Copy link
Copy Markdown

@sysit sysit commented Mar 22, 2026

Summary

Add support for filtering torrents by their download directory (content_path), allowing users to apply different retention policies based on where torrents are downloaded.

Motivation

Currently, users can filter torrents by tracker, category, and status. However, there's no way to differentiate torrents based on their download location. This feature enables more precise cleanup strategies, e.g.:

  • Delete old movies after 30 days, but keep TV shows longer
  • Apply different policies to different storage volumes
  • Protect important directories from automatic cleanup

Changes

New Files

  • autoremovetorrents/filter/contentpath.py - ContentPathFilter implementation

Modified Files

  • autoremovetorrents/client/qbittorrent.py - Fetch content_path from qBittorrent API
  • autoremovetorrents/client/transmission.py - Fetch downloadDir from Transmission API
  • autoremovetorrents/strategy.py - Register ContentPathFilter
  • autoremovetorrents/torrent.py - Document content_path attribute

Usage Example

my_task:
  client: transmission
  host: http://127.0.0.1:9091
  username: admin
  password: password
  strategies:
    # Delete movies after 30 days
    movies_cleanup:
      content_paths:
        - /downloads/movies
      remove: seeding_time > 2592000 or ratio > 2
    
    # Delete TV shows after 14 days, but protect important ones
    tv_cleanup:
      content_paths:
        - /downloads/tv
      excluded_content_paths:
        - /downloads/tv/important
      remove: seeding_time > 1209600

  delete_data: false

Features

  • ✅ Exact path match
  • ✅ Parent directory match (/downloads/tv matches /downloads/tv/show)
  • ✅ Multiple content paths support
  • excluded_content_paths for fine-grained control
  • ✅ Works with both qBittorrent and Transmission clients

Testing

Tested with:

  • qBittorrent 4.x
  • Transmission 3.00
  • 1400+ torrents, filtered by content_path + tracker + seeding_time

Checklist

  • Code follows project style
  • Backwards compatible (new optional filter)
  • Tested with real Transmission instance

Add support for filtering torrents by their download directory (content_path).
This allows users to apply different retention policies based on where
torrents are downloaded.

Features:
- Filter by exact path match
- Filter by parent directory (e.g., /downloads/tv matches /downloads/tv/show)
- Support multiple content paths
- Support excluded_content_paths for fine-grained control
- Works with qBittorrent and Transmission clients

Example configuration:
  strategies:
    movies_cleanup:
      content_paths:
        - /downloads/movies
      remove: seeding_time > 2592000 or ratio > 2

    tv_cleanup:
      content_paths:
        - /downloads/tv
      excluded_content_paths:
        - /downloads/tv/important
      remove: seeding_time > 1209600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant