Configuration

Before we run autoremove-torrents, we need to create a config.yml to save our configurations.

Warning

In order to avoid the torrents being mistakenly deleted, we highly recommend you to run autoremove-torrents --view once to preview the results after modifying the configuration file.

The script uses the YAML language as the language of the configuration file. The YAML language has a clear structure, so I think it’s more friendly than the JSON and easy to learn.

Look at the example please, the task block can be divided into 3 parts.

# A task block
my_task:          # Part 1: Task Name
  # Part 2: Login Information
  client: qbittorrent
  host: http://127.0.0.1:9091
  username: admin
  password: adminadmin
  # Part 3: Strategies Block (Remove Conditions)
  strategies:
    strategy1:    # Part I: Strategy Name
      # Part II: Filters
      categories:
        - IPT
      # Part III: Remove Condition
      ratio: 1
      seeding_time: 1209600
    strategy2:
      all_categories: true
      excluded_categories:
        - IPT
      seeding_time: 259200
    # Add more strategies here...
  # Part 4: Decide whether to remove and delete data (optional)
  delete_data: true

# Add more tasks here...

Centainly, the configuration file can contain more than one task blocks, and a task block can contain more than one strategy blocks. Each task block represents a BT client, and each strategy block represents a kind of torrents.

Part 1: Task Name

Just name your task.

Note

No spaces are allowed before the task name.

Part 2: Login Information

This part is your login inforamtion.

For qBittorrent, Transmission or μTorrent

For qBittorrent/Transmission/μTorrent, this program works with your client’s WebUI.

  • client: Your client name. It’s case-insensitive.
  • host: The URL of your client’s WebUI, and the URL must have a scheme (http:// or https://).
  • username: The username of the WebUI.
  • password: The password of the WebUI.

For Deluge

This program accesses Deluge via its RPC protocol.

  • client: Your client name. Here is Deluge.
  • host: The IP address (or domain name) and the port number of your Deluge Daemon, for example, 127.0.0.1:58846.
  • username: The username of the Deluge Daemon.
  • password: The password of the Deluge Daemon.

Example:

my_task:
  client: deluge
  host: 127.0.0.1:58846
  username: localclient
  password: 357a0d23f09b9f303f58846e41986b36fef2ac88

Note

  1. Don’t write any schemes in host field. The program uses neither HTTP protocol nor HTTPS protocol to access Deluge.
  2. The port number is the port number of the Deluge Daemon, not the WebUI. You can find it in the Connection Manager of your WebUI.
  3. When you are running the autoremove-torrents and the Deluge on different computers, please make sure that your Deluge accepts remote connections. You can modify this setting at Preferences -> Daemon -> Allow Remote Connections.

Note

Generally, you can find the username and password in ~/.config/deluge/auth. Also, you can create a new user by adding a new line to the end of the file.

For more information of the authentication, please visit https://dev.deluge-torrent.org/wiki/UserGuide/Authentication.

Part 3: Strategy Block

This part contains strategy blocks. Each strategy block can be divided into 3 parts, too.

Part I: Strategy Name

Just name your strategy like the task name.

Part II: Filters

The removing condtions are only available for the torrents you chosen. There are 9 filters available.

  • all_trackers/all_categories/all_status: Choose all the trackers/categories/status.
  • categories: Choose torrents in these categories.
  • excluded_categories: Don’t choose torrents in these categories.
  • trackers: Choose torrents in these trackers.
  • excluded_trackers: Don’t choose torrents in these trackers.
  • status: Choose torrents in these status. Available status is as follows:
Status Remarks
Downloading /
Uploading /
Checking /
Queued /
Paused Transmission doesn’t have this status.
Stopped qBittorrent doesn’t have this status.
Error /
StalledUpload μTorrent doesn’t have this status.
StalledDownload μTorrent doesn’t have this status.
  • excluded_status: Don’t choose these torrents in these status. Available status is shown in the table above.

The result of each filter is a set of torrents.

Note

When two or three of categories, trackers and status filter are specificed, the program will take the intersection of these sets, and subtracts set excluded_categories, excluded_trackers and excluded_status.

Note

  1. Don’t write sockets in trackers. The trackers field only needs hostname, for example, just fill tracker.site1.com for https://tracker.site1.com.
  2. In 1.4.4 and later version, if there’s only one item in categories, trackers or status, it’s not necessary to use list structure. A single-line text is enough, for example:
categories: cata1
status: uploading
  1. The StalledUp and StalledDown is the new status in version 1.4.5. In this program, Uploading inlcudes the torrents in StalledUpload status, and Downloading includes the torrents in StalledDownload status.

Let’s see some examples. Select those torrents whose categories are Movies or Games:

my_task:
  client: xxx
  host: xxx
  username: xxx
  password: xxx
  strategies:
    my_strategy:
      categories:
        - Movies
        - Games
      # Removing conditions are here
      # ...

Select those torrents whose hostnames of tracker are tracker.aaa.com or x.bbb.com:

my_task:
  client: xxx
  host: xxx
  username: xxx
  password: xxx
  strategies:
    my_strategy:
      trackers:
        - tracker.aaa.com
        - x.bbb.com
      # Removing conditons are here
      # ...

Select torrents whose categories are Movies or Games, but exclude those torrents whose tracker is tracker.yyy.com:

my_task:
  client: xxx
  host: xxx
  username: xxx
  password: xxx
  strategies:
    my_strategy:
      categories:
        - Movies
        - Games
      excluded_trackers:
        - tracker.yyy.com
      # Removing conditions are here
      # ...

Select those torrents whose categories is Movies and status is uploading:

my_task:
  client: xxx
  host: xxx
  username: xxx
  password: xxx
  strategies:
    my_strategy:
      categories:
        - Movies
      status:
        - Uploading
      # Removing conditions are here
      # ...

Part III: Remove Condition

There are 2 ways to set removing condition.

2. Use remove Keyword (Advanced)

Use the remove keyword. The remove keyword is a new keyword in version 1.4.0, which supports the complex removing condition. The remove keyword is followed by an expression, which consists of the following syntax:

  1. <Parameter> <Comparison Operator> <Value>

    Parameter: Available parameters are as follows, and they are case-insensitive.

    Note

    Some properties can only be used in specific status. The torrents not in available status will not be removed.

    Parameter Unit Available Status Description
    average_downloadspeed KiB/s All Average download speed.
    average_uploadspeed KiB/s All Average upload speed.
    connected_leecher / Downloading or Uploading The number of connected leecher.
    connected_seeder / Downloading or Uploading The number of connected seeder.
    create_time Second All The elapsed time since the torrent was added to the client.
    download GiB All Downloaded Size
    download_speed KiB/s Downloading Download speed.
    last_activity Second All The elapsed time since the torrent has stopped being active (without uploading or downloading).
    leecher / All The number of leechers.
    progress % All The download progress.
    ratio / All Ratio
    seeder / All The number of seeders.
    seeding_time Second All Seeding time.
    size GiB All The torrent size.
    upload GiB All Uploaded Size
    upload_ratio / All uploaded size / size
    upload_speed KiB/s Downloading or Uploading Upload Speed

    Comparison Operator: Available parameters are as follows. This program doesn’t provide the equal sign, because the status data of the torrents change quickly, and usually it’s meaningless to set a specific value.

    Comparison Operator Description
    < Less Than
    > Greater Than

    Value: Specify a numeric value. Supports integers and floats.

    This syntax selects the eligible torrents directly, and removes them directly or works with the following compound expressions. Here is an example, it removes the torrents which seeding time is greater than 259200 seconds:

    my_task:
      client: xxx
      host: xxx
      username: xxx
      password: xxx
      strategies:
        my_strategy:
          remove: seeding_time > 259200
    
  2. <Expression 1> and <Expression 2> and <Expression 1> or <Expression 2>

    This syntax is a compound expression.

    • and: Select torrents that meet both the Expression 1 and Expression 2 (intersection).
    • or: Select torrents that meet one or both of the Expression 1 and Expression 2 (Union).

    Here is an example. For all torrents, it removes those torrents which ratio is greater than 2 and seeding time is more than 60000 seconds:

    my_task:
      client: xxx
      host: xxx
      username: xxx
      password: xxx
      strategies:
        my_strategy:
          remove: ratio > 2 and seeding_time > 60000
    

    Here is another example. For all torrents, it removes those torrents which ratio is less than 1 or seeding time is more than 60000:

    my_task:
      client: xxx
      host: xxx
      username: xxx
      password: xxx
      strategies:
        my_strategy:
          remove: ratio < 1 or seeding_time > 60000
    
  3. (<Expression>)

    When an expression is enclosed in parentheses, it is still an expression. Using parentheses can change the priority. And you can use multiple parentheses for nesting.

    Here is an example. For all torrents, it removes those torrents which seeding time is more than 60000 seconds, or those torrents which ratio is greater than 3 and added time is more than 1400000 seconds:

    my_task:
      client: xxx
      host: xxx
      username: xxx
      password: xxx
      strategies:
        my_strategy:
          remove: seeding_time > 60000 or (ratio > 3 and create_time > 1400000)
    

Part 4: Delete data

Determine whether to delete data at the same time. If this field isn’t specificed, the default value is false.

The Last Step…

Remember to check your configuration file and make sure it works as you think. Use the following command line to see the torrents that will be removed (but not really remove them).

autoremove-torrents --view