Skip to content

Commit

Permalink
v4.0.5 (#418)
Browse files Browse the repository at this point in the history
* Fixes #388

* Bump docker/setup-buildx-action from 2 to 3

Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](docker/setup-buildx-action@v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump docker/login-action from 2 to 3

Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](docker/login-action@v2...v3)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump docker/build-push-action from 4 to 5

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](docker/build-push-action@v4...v5)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump gitpython from 3.1.35 to 3.1.36

Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.35 to 3.1.36.
- [Release notes](https://github.com/gitpython-developers/GitPython/releases)
- [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES)
- [Commits](gitpython-developers/GitPython@3.1.35...3.1.36)

---
updated-dependencies:
- dependency-name: gitpython
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/asottile/reorder-python-imports: v3.10.0 → v3.11.0](asottile/reorder-python-imports@v3.10.0...v3.11.0)
- [github.com/asottile/pyupgrade: v3.10.1 → v3.11.0](asottile/pyupgrade@v3.10.1...v3.11.0)
- [github.com/psf/black: 23.7.0 → 23.9.1](psf/black@23.7.0...23.9.1)

* Error handling when BHD API doesn't respond

* add BHD specific announce related issues

* handle JSONDecodeError

* Special mapping to leave torrents uncategorized on cat-update (#398)

Special mapping to leave torrents uncategorized on cat-update (closes #395)

* Bump gitpython from 3.1.36 to 3.1.37

Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.36 to 3.1.37.
- [Release notes](https://github.com/gitpython-developers/GitPython/releases)
- [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES)
- [Commits](gitpython-developers/GitPython@3.1.36...3.1.37)

---
updated-dependencies:
- dependency-name: gitpython
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump ruamel-yaml from 0.17.32 to 0.17.33

Bumps [ruamel-yaml](https://sourceforge.net/p/ruamel-yaml/code/ci/default/tree) from 0.17.32 to 0.17.33.

---
updated-dependencies:
- dependency-name: ruamel-yaml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* last_active flag for share_limits (#397)

Added a last_active flag for share_limits to resume torrents and avoid cleanup if there was activity in the last X minutes.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: bobokun <12660469+bobokun@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#405)

updates:
- [github.com/asottile/reorder-python-imports: v3.10.0 → v3.11.0](asottile/reorder-python-imports@v3.10.0...v3.11.0)
- [github.com/asottile/pyupgrade: v3.10.1 → v3.13.0](asottile/pyupgrade@v3.10.1...v3.13.0)
- [github.com/psf/black: 23.7.0 → 23.9.1](psf/black@23.7.0...23.9.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: bobokun <12660469+bobokun@users.noreply.github.com>

* Bump schedule from 1.2.0 to 1.2.1

Bumps [schedule](https://github.com/dbader/schedule) from 1.2.0 to 1.2.1.
- [Changelog](https://github.com/dbader/schedule/blob/master/HISTORY.rst)
- [Commits](dbader/schedule@1.2.0...1.2.1)

---
updated-dependencies:
- dependency-name: schedule
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump ruamel-yaml from 0.17.33 to 0.17.34

Bumps [ruamel-yaml](https://sourceforge.net/p/ruamel-yaml/code/ci/default/tree) from 0.17.33 to 0.17.34.

---
updated-dependencies:
- dependency-name: ruamel-yaml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix exit codes when program fails (#411)

Co-authored-by: bobokun <12660469+bobokun@users.noreply.github.com>

* Bump ruamel-yaml from 0.17.34 to 0.17.35

Bumps [ruamel-yaml](https://sourceforge.net/p/ruamel-yaml/code/ci/default/tree) from 0.17.34 to 0.17.35.

---
updated-dependencies:
- dependency-name: ruamel-yaml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* [pre-commit.ci] pre-commit autoupdate (#409)

updates:
- [github.com/asottile/reorder-python-imports: v3.10.0 → v3.12.0](asottile/reorder-python-imports@v3.10.0...v3.12.0)
- [github.com/asottile/pyupgrade: v3.10.1 → v3.14.0](asottile/pyupgrade@v3.10.1...v3.14.0)
- [github.com/psf/black: 23.7.0 → 23.9.1](psf/black@23.7.0...23.9.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: bobokun <12660469+bobokun@users.noreply.github.com>

* New option cat in trackers (#400)

* New option cat in trackers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: bobokun <12660469+bobokun@users.noreply.github.com>

* update config.sample for #200

* add additional script to edit trackers

* clarify remote_dir usage (#417)

* Bump gitpython from 3.1.35 to 3.1.37 (#414)

Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.35 to 3.1.37.
- [Release notes](https://github.com/gitpython-developers/GitPython/releases)
- [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES)
- [Commits](gitpython-developers/GitPython@3.1.35...3.1.37)

---
updated-dependencies:
- dependency-name: gitpython
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#413)

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](pre-commit/pre-commit-hooks@v4.4.0...v4.5.0)
- [github.com/asottile/reorder-python-imports: v3.10.0 → v3.12.0](asottile/reorder-python-imports@v3.10.0...v3.12.0)
- [github.com/asottile/pyupgrade: v3.10.1 → v3.15.0](asottile/pyupgrade@v3.10.1...v3.15.0)
- [github.com/psf/black: 23.7.0 → 23.9.1](psf/black@23.7.0...23.9.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: bobokun <12660469+bobokun@users.noreply.github.com>

* 4.0.5

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Esteban Thilliez <77675611+estebanthi@users.noreply.github.com>
Co-authored-by: Fabricio Silva <hi@fabricio.dev>
Co-authored-by: bakerboy448 <55419169+bakerboy448@users.noreply.github.com>
  • Loading branch information
7 people authored Oct 14, 2023
1 parent db5e881 commit 24ba90f
Show file tree
Hide file tree
Showing 18 changed files with 170 additions and 43 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
body: '{ "application": "qbitmanage", "branch": "nightly" }'

- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
Expand All @@ -38,11 +38,11 @@ jobs:

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
body: '{ "application": "qbitmanage", "branch": "release" }'

- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
Expand All @@ -34,11 +34,11 @@ jobs:

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0

- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
Expand All @@ -30,15 +30,15 @@ jobs:

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT

- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand Down Expand Up @@ -32,16 +32,16 @@ repos:
- id: yamlfix
exclude: ^.github/
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.10.0
rev: v3.12.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py3-plus]
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black
language_version: python3
Expand Down
18 changes: 14 additions & 4 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Requirements Updated
- qbitorrent-api updated to 2023.9.53
- GitPython updated to 3.1.35
- GitPython==3.1.37
- ruamel.yaml==0.17.35
- schedule==1.2.1

# New Features
- Added a last_active flag for share_limits to resume torrents and avoid cleanup if there was activity in the last X minutes. (Closes #353)
- New cat option in trackers/[tracker] to allow changing category based on tracker URL. (Closes #200)
- Added new script to edit tracker urls (https://github.com/StuffAnThings/qbit_manage/commit/9290d2c958ea733d22cb3c98d30bab7037997f1d)

# Bug Fixes
- Fixes [#377](https://github.com/StuffAnThings/qbit_manage/issues/377)
- Fixes [#388](https://github.com/StuffAnThings/qbit_manage/issues/388)
- Fixes handling BHD API announce related issues
- Special mapping to leave torrents uncategorized on cat-update (closes #395)
- fix exit codes when program fails (#411)

**Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v4.0.4...v4.0.5

**Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v4.0.3...v4.0.4
Special thanks to @estebanthi, @fabricionaweb for their contributions!
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.4
4.0.5
9 changes: 8 additions & 1 deletion config/config.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ directory:
# 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.
# Must be set if you're running qbit_manage locally and qBittorrent/cross_seed is in a docker
# 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.
Expand Down Expand Up @@ -70,6 +71,8 @@ tracker:
# <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>
animebytes.tv:
Expand Down Expand Up @@ -179,6 +182,10 @@ share_limits:
# If the torrent has not yet reached this minimum seeding time, it will change the share limits back to no limits and resume the torrent to continue seeding.
# Will default to 0 if not specified for the group.
min_seeding_time: 43200
# <OPTIONAL> last_active <int>: Will prevent torrent deletion by cleanup variable if torrent has been active within the last x minutes.
# If the torrent has been active within the last x minutes, it will change the share limits back to no limits and resume the torrent to continue seeding.
# Will default to 0 if not specified for the group.
last_active: 43200
# <OPTIONAL> Limit Upload Speed <int>: Will limit the upload speed KiB/s (KiloBytes/second) (`-1` : No Limit)
limit_upload_speed: 0
# <OPTIONAL> cleanup <bool>: WARNING!! Setting this as true Will remove and delete contents of any torrents that satisfies the share limits
Expand Down
12 changes: 5 additions & 7 deletions modules/bhd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ def search(self, json, path="torrents/"):
logger.trace(response)
response_json = response.json()
except JSONDecodeError as err:
if response.status_code >= 400:
raise Failed(err) from err
elif "Expecting value" in err:
logger.debug(err)
logger.debug(err)
return {}
if response.status_code >= 400:
logger.debug(f"Response: {response_json}")
raise Failed(f"({response.status_code} [{response.reason}]) {response_json}")
if not response_json["success"]:
raise Failed(f"BHD Error: {response_json['status_message']}")
return response.json()
if not response_json.get("success"):
raise Failed(f"BHD Error: {response_json.get('status_message','Issue receiving response from BHD API.')}")
return response_json
13 changes: 12 additions & 1 deletion modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,17 @@ def _sort_share_limits(share_limits):
do_print=False,
save=False,
)
self.share_limits[group]["last_active"] = self.util.check_for_attribute(
self.data,
"last_active",
parent="share_limits",
subparent=group,
var_type="int",
min_int=0,
default=0,
do_print=False,
save=False,
)
self.share_limits[group]["resume_torrent_after_change"] = self.util.check_for_attribute(
self.data,
"resume_torrent_after_change",
Expand Down Expand Up @@ -656,7 +667,7 @@ def cleanup_dirs(self, location):
ex = logger.print_line(
f"{location} Warning - FileNotFound: No such file or directory: {file} ", "WARNING"
)
self.config.notify(ex, "Cleanup Dirs", False)
self.notify(ex, "Cleanup Dirs", False)
continue
now = time.time() # in seconds
days = (now - last_modified) / (60 * 60 * 24)
Expand Down
10 changes: 9 additions & 1 deletion modules/core/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, qbit_manager):
self.stats = 0
self.torrents_updated = [] # List of torrents updated
self.notify_attr = [] # List of single torrent attributes to send to notifiarr
self.uncategorized_mapping = "Uncategorized"

self.category()
self.config.webhooks_factory.notify(self.torrents_updated, self.notify_attr, group_by="category")
Expand All @@ -22,7 +23,10 @@ def category(self):
logger.separator("Updating Categories", space=False, border=False)
torrent_list = self.qbt.get_torrents({"category": "", "status_filter": "completed"})
for torrent in torrent_list:
new_cat = self.qbt.get_category(torrent.save_path)
new_cat = self.get_tracker_cat(torrent) or self.qbt.get_category(torrent.save_path)
if new_cat == self.uncategorized_mapping:
logger.print_line(f"{torrent.name} remains uncategorized.", self.config.loglevel)
continue
self.update_cat(torrent, new_cat, False)

# Change categories
Expand All @@ -40,6 +44,10 @@ def category(self):
else:
logger.print_line("No new torrents to categorize.", self.config.loglevel)

def get_tracker_cat(self, torrent):
tracker = self.qbt.get_tags(torrent.trackers)
return tracker["cat"]

def update_cat(self, torrent, new_cat, cat_change):
"""Update category based on the torrent information"""
tracker = self.qbt.get_tags(torrent.trackers)
Expand Down
3 changes: 1 addition & 2 deletions modules/core/remove_unregistered.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def check_for_unregistered_torrents_using_bhd_api(self, tracker, msg_up, torrent
):
json = {"info_hash": torrent_hash}
response = self.config.beyond_hd.search(json)
if response["total_results"] == 0:
if response.get("total_results") == 0:
return True
return False

Expand Down Expand Up @@ -122,7 +122,6 @@ def process_torrent_issues(self):
# Tag any error torrents
if self.cfg_tag_error and self.tag_error not in check_tags:
self.tag_tracker_error(msg, tracker, torrent)

except NotFound404Error:
continue
except Exception as ex:
Expand Down
47 changes: 44 additions & 3 deletions modules/core/share_limits.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from datetime import timedelta
from time import time

from modules import util
from modules.util import is_tag_in_torrent
Expand All @@ -9,6 +10,7 @@

MIN_SEEDING_TIME_TAG = "MinSeedTimeNotReached"
MIN_NUM_SEEDS_TAG = "MinSeedsNotMet"
LAST_ACTIVE_TAG = "LastActiveLimitNotReached"


class ShareLimits:
Expand Down Expand Up @@ -57,6 +59,7 @@ def update_share_limits(self):
"torrent_min_seeding_time": group_config["min_seeding_time"],
"torrent_min_num_seeds": group_config["min_num_seeds"],
"torrent_limit_upload_speed": group_config["limit_upload_speed"],
"torrent_last_active": group_config["last_active"],
}
if len(self.torrents_updated) > 0:
self.config.send_notifications(attr)
Expand Down Expand Up @@ -209,8 +212,10 @@ def update_share_limits_for_group(self, group_name, group_config, torrents):
if (
check_max_ratio or check_max_seeding_time or check_limit_upload_speed or share_limits_not_yet_tagged
) and hash_not_prev_checked:
if not is_tag_in_torrent(MIN_SEEDING_TIME_TAG, torrent.tags) and not is_tag_in_torrent(
MIN_NUM_SEEDS_TAG, torrent.tags
if (
not is_tag_in_torrent(MIN_SEEDING_TIME_TAG, torrent.tags)
and not is_tag_in_torrent(MIN_NUM_SEEDS_TAG, torrent.tags)
and not is_tag_in_torrent(LAST_ACTIVE_TAG, torrent.tags)
):
logger.print_line(logger.insert_space(f"Torrent Name: {t_name}", 3), self.config.loglevel)
logger.print_line(logger.insert_space(f'Tracker: {tracker["url"]}', 8), self.config.loglevel)
Expand All @@ -226,6 +231,7 @@ def update_share_limits_for_group(self, group_name, group_config, torrents):
max_seeding_time=group_config["max_seeding_time"],
min_seeding_time=group_config["min_seeding_time"],
min_num_seeds=group_config["min_num_seeds"],
last_active=group_config["last_active"],
resume_torrent=group_config["resume_torrent_after_change"],
tracker=tracker["url"],
)
Expand Down Expand Up @@ -371,11 +377,13 @@ def set_tags_and_limits(self, torrent, max_ratio, max_seeding_time, limit_upload
return []
if is_tag_in_torrent(MIN_NUM_SEEDS_TAG, torrent.tags):
return []
if is_tag_in_torrent(LAST_ACTIVE_TAG, torrent.tags):
return []
torrent.set_share_limits(max_ratio, max_seeding_time)
return body

def has_reached_seed_limit(
self, torrent, max_ratio, max_seeding_time, min_seeding_time, min_num_seeds, resume_torrent, tracker
self, torrent, max_ratio, max_seeding_time, min_seeding_time, min_num_seeds, last_active, resume_torrent, tracker
):
"""Check if torrent has reached seed limit"""
body = ""
Expand Down Expand Up @@ -440,6 +448,36 @@ def _is_less_than_min_num_seeds():
torrent.resume()
return True

def _has_reached_last_active_time_limit():
print_log = []
now = int(time())
inactive_time_minutes = round((now - torrent.last_activity) / 60)
if inactive_time_minutes >= last_active * 60:
if is_tag_in_torrent(LAST_ACTIVE_TAG, torrent.tags):
if not self.config.dry_run:
torrent.remove_tags(tags=LAST_ACTIVE_TAG)
return True
else:
if not is_tag_in_torrent(LAST_ACTIVE_TAG, torrent.tags):
print_log += logger.print_line(logger.insert_space(f"Torrent Name: {torrent.name}", 3), self.config.loglevel)
print_log += logger.print_line(logger.insert_space(f"Tracker: {tracker}", 8), self.config.loglevel)
print_log += logger.print_line(
logger.insert_space(
f"Min inactive time not met: {timedelta(seconds=inactive_time_minutes)} <="
f" {timedelta(minutes=last_active)}. Removing Share Limits so qBittorrent can continue"
" seeding.",
8,
),
self.config.loglevel,
)
print_log += logger.print_line(logger.insert_space(f"Adding Tag: {LAST_ACTIVE_TAG}", 8), self.config.loglevel)
if not self.config.dry_run:
torrent.add_tags(LAST_ACTIVE_TAG)
torrent.set_share_limits(-1, -1)
if resume_torrent:
torrent.resume()
return False

def _has_reached_seeding_time_limit():
nonlocal body
seeding_time_limit = None
Expand All @@ -464,6 +502,9 @@ def _has_reached_seeding_time_limit():
if min_num_seeds is not None:
if _is_less_than_min_num_seeds():
return body
if last_active is not None:
if not _has_reached_last_active_time_limit():
return body
if max_ratio is not None:
if max_ratio >= 0:
if torrent.ratio >= max_ratio and _has_reached_min_seeding_time_limit():
Expand Down
13 changes: 12 additions & 1 deletion modules/qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, config, params):
else:
self.config.notify(ex, "Qbittorrent")
logger.print_line(ex, "CRITICAL")
sys.exit(0)
sys.exit(1)
logger.info("Qbt Connection Successful")
except LoginFailed as exc:
ex = "Qbittorrent Error: Failed to login. Invalid username/password."
Expand Down Expand Up @@ -204,6 +204,7 @@ def get_tags(self, trackers):
urls = [x.url for x in trackers if x.url.startswith("http")]
tracker = {}
tracker["tag"] = None
tracker["cat"] = None
tracker["notifiarr"] = None
tracker["url"] = None
tracker_other_tag = self.config.util.check_for_attribute(
Expand Down Expand Up @@ -238,6 +239,16 @@ def get_tags(self, trackers):
tracker["tag"] = self.config.util.check_for_attribute(
self.config.data, "tag", parent="tracker", subparent=tag_url, default=tag_url, var_type="list"
)
tracker["cat"] = self.config.util.check_for_attribute(
self.config.data,
"cat",
parent="tracker",
subparent=tag_url,
default_is_none=True,
var_type="str",
save=False,
do_print=False,
)
if tracker["tag"] == [tag_url]:
self.config.data["tracker"][tag_url]["tag"] = [tag_url]
if isinstance(tracker["tag"], str):
Expand Down
Loading

0 comments on commit 24ba90f

Please sign in to comment.