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
635 stars 41 forks source link

[Bug]: MinSeedTimeNotReached tag not being applied correctly, causes torrent to pause and unpause every other run #597

Open ineednewpajamas opened 3 days ago

ineednewpajamas commented 3 days ago

Describe the Bug

Recently added min_seeding_time to a share limit, it partially works in that the torrent hit the ratio and qbit paused it, then QM disabled the ratio and resumed it (but never added the MinSeedTimeNotReached tag), the next run though it sets back the ratio and a then qbit pauses it again....and repeat.

I tried adding the MinSeedTimeNotReached manually, and QM just removes it. The trace logs havent been helpful.

torrent with the issue is mayor.of.kingstown.s03e05.1080p.web.h264-successfulcrab[EZTVx.to].mkv[eztvx.to]

trace where it set the ratio and removed the tag i had manually added: https://privatebin.net/?5317f37d52b2c0a1#9mEhbDzfSF9gxCREG7u7VjTZiHAdaGZhWEyX6MU3BRNo partial trace where it said it removed the ratio and said it added the tag but the tag wasnt added: https://privatebin.net/?5b69cc17542dc38d#BNWuQ1BEp5BYgEGfeob48hCiaoK5Vagq3kV14StTbaLa

also included the info level log of it removing the ratio one running and saying it was adding MinSeedTimeNotReached, then the next run saying it was both adding the MinSeedTimeNotReached and then setting the ratio back to 1

Config

# https://github.com/StuffAnThings/qbit_manage/wiki/Config-Setup
commands:
  dry_run: false
  cross_seed: false
  recheck: false
  cat_update: false
  tag_update: true
  rem_unregistered: false
  tag_tracker_error: true
  rem_orphaned: false
  tag_nohardlinks: true
  share_limits: true
  skip_qb_version_check: false
  skip_cleanup: false

qbt:
  host: qbittorrent:8080
  user:
  pass:

settings:
  force_auto_tmm: false
  tracker_error_tag: issue
  nohardlinks_tag: noHL
  share_limits_tag: ~share_limit
  share_limits_min_seeding_time_tag: MinSeedTimeNotReached
  share_limits_min_num_seeds_tag: MinSeedsNotMet
  share_limits_last_active_tag: LastActiveLimitNotReached
  cross_seed_tag: cross-seed
  cat_filter_completed: true
  share_limits_filter_completed: true
  tag_nohardlinks_filter_completed: true
  cat_update_all: true

directory:
  cross_seed:
  root_dir: /data/torrents/
  remote_dir: /data/torrents/
  recycle_bin: /data/torrents/.RecycleBin
  torrents_dir: /qbittorrent/data/BT_backup
  orphaned_dir: /data/torrents/orphaned_data

cat:
  movies: /data/torrents/movies
  tv: /data/torrents/tv
  audiobooks: /data/torrents/audiobooks
  books: /data/torrents/books
  manual: /data/torrents/manual
  music: /data/torrents/music
  prowlarr: /data/torrents/prowlarr
  cross-seed-link: /data/torrents/links

cat_change:

tracker:
  myanonamouse:
    tag: MaM
  torrentleech|tleechreload:
    tag: TorrentLeech
  other:
    tag: other

nohardlinks:
  # books: # Calibre doesn't hard link
  #   exclude_tags:
  #     - MaM
  #     - TorrentLeech
  audiobooks:
    # exclude_tags:
    #   - MaM
    #   - TorrentLeech
  movies:
    # exclude_tags:
    #   - MaM
    #   - TorrentLeech
  tv:
    # exclude_tags:
    #   - MaM
    #   - TorrentLeech
  manual:
    # exclude_tags:
    #   - MaM
    #   - TorrentLeech
  music:
    # exclude_tags:
    #   - MaM
    #   - TorrentLeech
  prowlarr:
    # exclude_tags:
    #   - MaM
    #   - TorrentLeech
  cross-seed-link:
    # exclude_tags:
    #   - MaM
    #   - TorrentLeech

share_limits:
  MaM:
    priority: 1
    include_all_tags:
      - MaM
    exclude_all_tags:
      - noHL
    max_ratio: -1
    max_seeding_time: -1
    # min_seeding_time: 75h
    cleanup: false
  MaM_noHL:
    priority: 2
    include_all_tags:
      - MaM
      - noHL
    max_ratio: -1
    max_seeding_time: -1
    # min_seeding_time: 75h
    cleanup: false
  TL:
    priority: 3
    include_all_tags:
      - TorrentLeech
    exclude_all_tags:
      - noHL
    max_ratio: -1
    max_seeding_time: -1
    # min_seeding_time: 11d
    cleanup: false
  TL_noHL:
    priority: 4
    include_all_tags:
      - TorrentLeech
      - noHL
    max_ratio: -1
    max_seeding_time: -1
    # min_seeding_time: 11d
    cleanup: false
  noHL:
    priority: 998
    include_all_tags:
      - noHL
      - other
    max_ratio: 1
    max_seeding_time: -1
    min_num_seeds: 2
    cleanup: true
  default:
    priority: 999
    max_ratio: 1
    max_seeding_time: -1
    min_seeding_time: 24h
    min_num_seeds: 5
    cleanup: true

recyclebin:
  enabled: true
  empty_after_x_days: 60
  save_torrents: true
  split_by_category: true

orphaned:
  empty_after_x_days: 60
  exclude_patterns:

apprise:
  api_url: http://apprise:8000
  notify_url: apprise://apprise:8000/default/?tags=qbitmanage

webhooks:
  error: apprise
  run_start: http://apprise:8000/notify/default?tag=qbitmanage_noise
  run_end: http://apprise:8000/notify/default?tag=qbitmanage_noise
  function:
    cross_seed: http://apprise:8000/notify/default?tag=qbitmanage_noise
    recheck: http://apprise:8000/notify/default?tag=qbitmanage_noise
    cat_update: http://apprise:8000/notify/default?tag=qbitmanage_noise
    tag_update: http://apprise:8000/notify/default?tag=qbitmanage_noise
    rem_unregistered: apprise
    tag_tracker_error: apprise
    rem_orphaned: http://apprise:8000/notify/default?tag=qbitmanage_noise
    tag_nohardlinks: http://apprise:8000/notify/default?tag=qbitmanage_noise
    share_limits: http://apprise:8000/notify/default?tag=qbitmanage_noise
    cleanup_dirs: apprise

Logs

https://privatebin.net/?65ea07d7966ebdbd#GdNHtKfVkUnKsAmWgvKGyEuFHX8nRJpBFdcEMnFCpwpf

Screenshots

No response

Installation

Docker

Version Number

4.1.7-develop1

What branch are you on?

develop

ineednewpajamas commented 3 days ago

Also tested on 4.1.7-develop6 just in case, still an issue. I tried to look through the code but I'm stumped.

ineednewpajamas commented 3 days ago

I wonder if the issue is here: https://github.com/StuffAnThings/qbit_manage/blob/adb58ddd1486207cab087647e577a07028a37103/modules/core/share_limits.py#L545

Since max_seeding_time defaults to -1, wouldn't it never really be None and there is no check for -1 so it would hit that else statement that removes the min_seeding_time_tag. I did test it locally adding in this right above the if statement on 550 and it did seem to work

if max_seeding_time == -1:
                return False

could totally be wrong, i'll make a PR and let you judge

bobokun commented 2 days ago

PR looks fine, made one more minor change to catch a similar bug for max_ratio and left one more comment to test. Once that's done I think we're ready to merge the change. Thanks for the contribution!