StuffAnThings / qbit_manage

This tool will help manage tedious tasks in qBittorrent and automate them. Tag, categorize, remove Orphaned data, remove unregistered torrents and much much more.
MIT License
742 stars 45 forks source link

[Bug]: min_seeding_time and max_seeding_time are calculating incorrectly #529

Closed DetermineAbsurd closed 5 months ago

DetermineAbsurd commented 6 months ago

Describe the Bug

qbit_manage reports that my max_seeding_time is lower than my min_seeding_time, but the max is set to infinite, so I don't know why it's reporting this.

config has replaced references to the trackers with numbered generic names, but the tags and tracker keywords in the actual config do not contain odd characters. Just alphanumeric, "." and "-" in the tracker domains only.

Config

# Qbit_manage Config
# This is an example configuration file that documents all the options.
# It will need to be modified for your specific use case.
# Please refer to the link below for more details on how to set up the configuration file
# https://github.com/StuffAnThings/qbit_manage/wiki/Config-Setup

commands:
  # The commands defined below will IGNORE any commands used in command line and docker env variables.
  dry_run: false
  cross_seed: false
  recheck: false
  cat_update: false
  tag_update: true
  rem_unregistered: true
  tag_tracker_error: true
  rem_orphaned: true
  tag_nohardlinks: true
  share_limits: true
  skip_qb_version_check: false
  skip_cleanup: false

qbt:
  # qBittorrent parameters
  host: localhost:8081
  user: REDACTED
  pass: 
    REDACTED

settings:
  force_auto_tmm: true # Will force qBittorrent to enable Automatic Torrent Management for each torrent.
  tracker_error_tag: issue_no_tracker # Will set the tag of any torrents that do not have a working tracker.
  nohardlinks_tag: noHL # Will set the tag of any torrents with no hardlinks.
  share_limits_tag: ~share_limit # Will add this tag when applying share limits to provide an easy way to filter torrents by share limit group/priority for each torrent
  ignoreTags_OnUpdate: # When running tag-update function, it will update torrent tags for a given torrent even if the torrent has at least one or more of the tags defined here. Otherwise torrents will not be tagged if tags exist.
  - noHL
  - issue_no_tracker
  - cross-seed
  - privatetracker1
  - privatetracker3
  - publictracker1
  - privatetracker2
  - privatetracker4
  - other
directory:
  # Do not remove these
  # Cross-seed var: </your/path/here/>  # Output directory of cross-seed
  # root_dir var: </your/path/here/>  # Root downloads directory used to check for orphaned files, noHL, and RecycleBin.
  # <OPTIONAL> remote_dir var: </your/path/here/>  # Path of docker host mapping of root_dir.
  # remote_dir must be set if you're running qbit_manage locally and qBittorrent/cross_seed is in a docker
  # remote_dir should not be set if qbit_manage is running in a container
  # <OPTIONAL> recycle_bin var: </your/path/here/>   # Path of the RecycleBin folder. Default location is set to remote_dir/.RecycleBin
  # <OPTIONAL> torrents_dir var: </your/path/here/>  # Path of the your qbittorrent torrents directory. Required for `save_torrents` attribute in recyclebin
  # <OPTIONAL> orphaned_dir var: </your/path/here/>  # Path of the the Orphaned Data folder. This is similar to RecycleBin, but only for orphaned data.
  root_dir: /data/torrents/
  recycle_bin: /data/torrents/.RecycleBin
  orphaned_dir: /data/torrents/orphaned
  remote_dir: /data/torrents/
  cross_seed:
  torrents_dir:
cat:
  # Category & Path Parameters
  # <Category Name> : <save_path>  # Path of your save directory.
  radarr: /data/torrents/movies
  tv-sonarr: /data/torrents/tv-shows
  lidarr: /data/torrents/music
  readarr: /data/torrents/books
  prowlarr: /data/torrents/prowlarr
  Games: /data/torrents/games
  Software: /data/torrents/software
  Todo: /data/torrents/Todo
  Post_Import: /data/torrents/post_import

# cat_change:
#   # This moves all the torrents from one category to another category. This executes on --cat-update
#   # WARNING: if the paths are different and Default Torrent Management Mode is set to automatic the files could be moved !!!
#   # <Old Category Name> : <New Category>
#   Radarr-HD.cross-seed: movies-hd
#   Radarr-UHD.cross-seed: movies-uhd
#   movies-hd.cross-seed: movies-hd
#   movies-uhd.cross-seed: movies-uhd

tracker:
  # Mandatory
  # Tag Parameters
  # <Tracker URL Keyword>:    # <MANDATORY> This is the keyword in the tracker url. You can define multiple tracker urls by splitting with `|` delimiter
  # <MANDATORY> Set tag name. Can be a list of tags or a single tag
  #   tag: <Tag Name>
  # <OPTIONAL> Set the category based on tracker URL. This category option takes priority over the category defined by save directory
  #   cat: <Category Name>
  # <OPTIONAL> Set this to the notifiarr react name. This is used to add indexer reactions to the notifications sent by Notifiarr
  #   notifiarr: <notifiarr indexer>
  privatetracker1:
    tag: privatetracker1
  privatetracker3:
    tag: privatetracker3
  privatetracker2:
    tag: privatetracker2
  publictracker1:
    tag: publictracker1
  privatetracker4d1|privatetracker4d2|privatetracker4d3|privatetracker4d4|privatetracker4d5|privatetracker4d6:
    tag: privatetracker4
  # The "other" key is a special keyword and if defined will tag any other trackers that don't match the above trackers into this tag
  other:
    tag: other

nohardlinks:
  # Tag Movies/Series that are not hard linked outside the root directory
  # Mandatory to fill out directory parameter above to use this function (root_dir/remote_dir)
  # This variable should be set to your category name of your completed movies/completed series in qbit. Acceptable variable can be any category you would like to tag if there are no hardlinks found
- radarr
- tv-sonarr
- lidarr
- readarr
- Post_Import

share_limits:
  privatetracker1:
    priority: 5
    include_any_tags:
    - privatetracker1
    min_seeding_time: 10080
    min_num_seeds: 5
    max_ratio: -1
    cleanup: false
    resume_torrent_after_change: false
    add_group_to_tag: true
  privatetracker2:
    priority: 6
    include_any_tags:
    - privatetracker2
    min_seeding_time: 10080
    min_num_seeds: 2
    max_ratio: -1
    cleanup: true
    resume_torrent_after_change: false
    add_group_to_tag: true
  privatetracker3:
    priority: 7
    include_any_tags:
     - privatetracker3
    min_seeding_time: 7200
    max_ratio: -1
    cleanup: true
    resume_torrent_after_change: false
    add_group_to_tag: true
  noHL:
    priority: 20
    include_any_tags:
    - noHL
    exclude_any_tags:
    - privatetracker1
    categories:
    - radarr
    - tv-sonarr
    - lidarr
    - readarr
    - prowlarr
    - Todo
    - Post_Import
    max_ratio: 10
    # seeding times are in minutes, 43,200 is 30 days.
    max_seeding_time: 43200
    # Last active is in minutes, 1,440 is 1 day.
    last_active: 1440
    cleanup: true
    resume_torrent_after_change: false
    add_group_to_tag: true
    min_num_seeds: 2
  cross-seed:
    priority: 30
    include_all_tags:
    - cross-seed
    max_seeding_time: 10200
    cleanup: false
  public_tracked:
    priority: 40
    exclude_any_tags:
    - privatetracker1
    - privatetracker2
    categories:
    - radarr
    - tv-sonarr
    - lidarr
    - readarr
    - prowlarr
    - Post_Import
    max_ratio: 10
    # seeding times are in minutes, 43,200 is 30 days.
    max_seeding_time: 43200
    # last_active time in minutes.
    last_active: 15
    cleanup: true
    resume_torrent_after_change: false
    add_group_to_tag: true
  default:
    priority: 999
    max_ratio: -1
    max_seeding_time: -1
    cleanup: false

recyclebin:
  # Recycle Bin method of deletion will move files into the recycle bin (Located in /root_dir/.RecycleBin) instead of directly deleting them in qbit
  # By default the Recycle Bin will be emptied on every run of the qbit_manage script if empty_after_x_days is defined.
  enabled: false
  # <OPTIONAL> empty_after_x_days var:
  # Will automatically remove all files and folders in recycle bin after x days. (Checks every script run)
  # If this variable is not defined it, the RecycleBin will never be emptied.
  # WARNING: Setting this variable to 0 will delete all files immediately upon script run!
  empty_after_x_days: 60
  # <OPTIONAL> save_torrents var:
  # If this option is set to true you MUST fill out the torrents_dir in the directory attribute.
  # This will save a copy of your .torrent and .fastresume file in the recycle bin before deleting it from qbittorrent
  save_torrents: false
  # <OPTIONAL> split_by_category var:
  # This will split the recycle bin folder by the save path defined in the `cat` attribute
  # and add the base folder name of the recycle bin that was defined in the `recycle_bin` sub-attribute under directory.
  split_by_category: true
orphaned:
  # Orphaned files are those in the root_dir download directory that are not referenced by any active torrents.
  # Will automatically remove all files and folders in orphaned data after x days. (Checks every script run)
  # If this variable is not defined it, the orphaned data will never be emptied.
  # WARNING: Setting this variable to 0 will delete all files immediately upon script run!
  empty_after_x_days: 7
  # File patterns that will not be considered orphaned files. Handy for generated files that aren't part of the torrent but belong with the torrent's files
  exclude_patterns:
  - '**/.DS_Store'
  - '**/Thumbs.db'
  - '**/@eaDir'
  - "/data/torrents/temp/**"
  - '**/*.!qB'
  - '**/*_unpackerred'

# apprise:
  # Apprise integration with webhooks
  # Leave Empty/Blank to disable
  # Mandatory to fill out the url of your apprise API endpoint
  # api_url: http://apprise-api:8000
  # Mandatory to fill out the notification url/urls based on the notification services provided by apprise. https://github.com/caronc/apprise/wiki
  # notify_url:
webhooks:
  error:
  run_start:
  run_end:
  function:
    cross_seed:
    recheck:
    cat_update:
    tag_update:
    rem_unregistered:
    tag_tracker_error:
    rem_orphaned:
    tag_nohardlinks:
    share_limits:
    cleanup_dirs:

Logs

https://gist.github.com/DetermineAbsurd/4a430a033a64b4d4c505208135ee52d8

Screenshots

No response

Installation

Unraid

Version Number

4.1.1

What branch are you on?

master

Pid226 commented 5 months ago

I'm getting the same issue. If I use -1 for max_ratio or max_seeding_time when min_seeding_time is set to any value, I get verification error that value cannot be lower than min_seeding_time.

If I try remove max_ratio and max_seeding_time so it reverts to default values I still get the verification error as script still expects values for those fields. In effect the new change is making max_ratio and max_seeding_time mandatory fields if min_seeding_time is set.

To work around the verification, I've had to set arbritury high values to max_ratio (999) and max_seeding_time (525600) for any groups where they weren't set or used -1.

bobokun commented 5 months ago

Additional checks were added in place to avoid invalid configurations. The min_seeding_time was only being used whenever max_ratio is set.

In the case where max_ratio isn't set or set to infinite, setting min_seeding_time isn't doing anything. In order to fix this error you would want to change your min_seeding_time to max_seeding_time and therefore the share limits being applied will only delete the torrents once that particular group meets the max_seeding_time.

Pid226 commented 5 months ago

Ah ok. Yeah that makes sense now. I've removed min_seeding_time where I don't use max_ratio and script now works as expected. Thanks