From fa4492d1698c1f0b9063d96414f54ba96b0c0712 Mon Sep 17 00:00:00 2001 From: bobokun Date: Tue, 27 Jun 2023 20:04:34 -0400 Subject: [PATCH 01/15] updates version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 4d54dad..ced333e 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.2 +4.0.3-develop1 From 5ab2019abd82df3f6ab09a21c71dbf100d063ff9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Jun 2023 01:00:12 +0000 Subject: [PATCH 02/15] Bump dependabot/fetch-metadata from 1.5.1 to 1.6.0 Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.5.1 to 1.6.0. - [Release notes](https://github.com/dependabot/fetch-metadata/releases) - [Commits](https://github.com/dependabot/fetch-metadata/compare/v1.5.1...v1.6.0) --- updated-dependencies: - dependency-name: dependabot/fetch-metadata dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/dependabot-approve-and-auto-merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-approve-and-auto-merge.yml b/.github/workflows/dependabot-approve-and-auto-merge.yml index 22dbab7..2612ab2 100644 --- a/.github/workflows/dependabot-approve-and-auto-merge.yml +++ b/.github/workflows/dependabot-approve-and-auto-merge.yml @@ -19,7 +19,7 @@ jobs: # will not occur. - name: Dependabot metadata id: dependabot-metadata - uses: dependabot/fetch-metadata@v1.5.1 + uses: dependabot/fetch-metadata@v1.6.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" # Here the PR gets approved. From 08231138b5579e38b750a25bce258749364eef23 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 00:31:59 +0000 Subject: [PATCH 03/15] Bump gitpython from 3.1.31 to 3.1.32 Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.31 to 3.1.32. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.31...3.1.32) --- updated-dependencies: - dependency-name: gitpython dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 95bf634..176b1ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ bencodepy==0.9.5 -GitPython==3.1.31 +GitPython==3.1.32 qbittorrent-api==2023.6.50 requests==2.31.0 retrying==1.3.4 From 462be62f0cb52957825a23f5ac920281af317f79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jul 2023 00:56:34 +0000 Subject: [PATCH 04/15] Bump qbittorrent-api from 2023.6.50 to 2023.7.52 Bumps [qbittorrent-api](https://github.com/rmartin16/qbittorrent-api) from 2023.6.50 to 2023.7.52. - [Release notes](https://github.com/rmartin16/qbittorrent-api/releases) - [Changelog](https://github.com/rmartin16/qbittorrent-api/blob/main/CHANGELOG.md) - [Commits](https://github.com/rmartin16/qbittorrent-api/compare/v2023.6.50...v2023.7.52) --- updated-dependencies: - dependency-name: qbittorrent-api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 176b1ce..cef8e1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ bencodepy==0.9.5 GitPython==3.1.32 -qbittorrent-api==2023.6.50 +qbittorrent-api==2023.7.52 requests==2.31.0 retrying==1.3.4 ruamel.yaml==0.17.32 From b217bbcdba02eb3d82a16ed87638b9eb844437fa Mon Sep 17 00:00:00 2001 From: bobokun Date: Sat, 15 Jul 2023 14:48:38 -0400 Subject: [PATCH 05/15] fixes bug in sending webhook with wrong attr type --- VERSION | 2 +- modules/core/cross_seed.py | 2 +- modules/core/recheck.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index ced333e..234aa61 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3-develop1 +4.0.3-develop2 diff --git a/modules/core/cross_seed.py b/modules/core/cross_seed.py index 21afc75..d841d5a 100644 --- a/modules/core/cross_seed.py +++ b/modules/core/cross_seed.py @@ -128,7 +128,7 @@ class CrossSeed: "torrents": [t_name], "torrent_category": t_cat, "torrent_tag": "cross-seed", - "torrent_tracker": tracker, + "torrent_tracker": tracker["url"], } self.notify_attr.append(attr) self.torrents_updated.append(t_name) diff --git a/modules/core/recheck.py b/modules/core/recheck.py index ab0a48e..921e2a7 100644 --- a/modules/core/recheck.py +++ b/modules/core/recheck.py @@ -46,7 +46,7 @@ class ReCheck: "title": "Resuming Torrent", "body": body, "torrents": [t_name], - "torrent_tag": tracker["tag"], + "torrent_tag": ", ".join(tracker["tag"]), "torrent_category": t_category, "torrent_tracker": tracker["url"], "notifiarr_indexer": tracker["notifiarr"], @@ -95,7 +95,7 @@ class ReCheck: "title": "Resuming Torrent", "body": body, "torrents": [t_name], - "torrent_tag": tracker["tag"], + "torrent_tag": ", ".join(tracker["tag"]), "torrent_category": t_category, "torrent_tracker": tracker["url"], "notifiarr_indexer": tracker["notifiarr"], @@ -120,7 +120,7 @@ class ReCheck: "title": "Rechecking Torrent", "body": body, "torrents": [t_name], - "torrent_tag": tracker["tag"], + "torrent_tag": ", ".join(tracker["tag"]), "torrent_category": t_category, "torrent_tracker": tracker["url"], "notifiarr_indexer": tracker["notifiarr"], From cbd09b95628acff6bf7db9f0dfc00518f4149309 Mon Sep 17 00:00:00 2001 From: bobokun Date: Sat, 15 Jul 2023 15:03:29 -0400 Subject: [PATCH 06/15] Fixes #356 --- VERSION | 2 +- modules/qbittorrent.py | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 234aa61..1cb97d4 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3-develop2 +4.0.3-develop3 diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index a1c223c..d467a38 100755 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -2,7 +2,6 @@ import os import sys -from qbittorrentapi import APIConnectionError from qbittorrentapi import Client from qbittorrentapi import LoginFailed from qbittorrentapi import NotFound404Error @@ -74,15 +73,10 @@ class Qbt: except LoginFailed as exc: ex = "Qbittorrent Error: Failed to login. Invalid username/password." self.config.notify(ex, "Qbittorrent") - raise Failed(ex) from exc - except APIConnectionError as exc: - ex = "Qbittorrent Error: Unable to connect to the client." - self.config.notify(ex, "Qbittorrent") - raise Failed(ex) from exc + raise Failed(exc) from exc except Exception as exc: - ex = "Qbittorrent Error: Unable to connect to the client." - self.config.notify(ex, "Qbittorrent") - raise Failed(ex) from exc + self.config.notify(exc, "Qbittorrent") + raise Failed(exc) from exc logger.separator("Getting Torrent List", space=False, border=False) self.torrent_list = self.get_torrents({"sort": "added_on"}) From 1faeef33f5120e8d372582b0c27820b09dd51289 Mon Sep 17 00:00:00 2001 From: bobokun Date: Sat, 15 Jul 2023 15:21:55 -0400 Subject: [PATCH 07/15] Fixes #355 --- VERSION | 2 +- modules/util.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 1cb97d4..70b068d 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3-develop3 +4.0.3-develop4 diff --git a/modules/util.py b/modules/util.py index 037b1a7..57bf710 100755 --- a/modules/util.py +++ b/modules/util.py @@ -384,7 +384,18 @@ def move_files(src, dest, mod=False): shutil.move(src, dest) except PermissionError as perm: logger.warning(f"{perm} : Copying files instead.") - shutil.copyfile(src, dest) + try: + shutil.copyfile(src, dest) + except Exception as ex: + logger.stacktrace() + logger.error(ex) + return to_delete + if os.path.isfile(src): + logger.warning(f"Removing original file: {src}") + try: + os.remove(src) + except OSError as e: + logger.warning(f"Error: {e.filename} - {e.strerror}.") to_delete = True except FileNotFoundError as file: logger.warning(f"{file} : source: {src} -> destination: {dest}") From b6f6db09617046093e65303c268c434601a72c37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 00:34:17 +0000 Subject: [PATCH 08/15] Bump flake8 from 6.0.0 to 6.1.0 Bumps [flake8](https://github.com/pycqa/flake8) from 6.0.0 to 6.1.0. - [Commits](https://github.com/pycqa/flake8/compare/6.0.0...6.1.0) --- updated-dependencies: - dependency-name: flake8 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 1a1b3ca..78b8ac5 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,2 @@ -flake8==6.0.0 +flake8==6.1.0 pre-commit==3.3.3 From ec2bfff106f1a38b54f3e9c7686aca9150e6143c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 03:29:55 +0000 Subject: [PATCH 09/15] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/lyz-code/yamlfix: 1.11.0 → 1.12.0](https://github.com/lyz-code/yamlfix/compare/1.11.0...1.12.0) - [github.com/asottile/pyupgrade: v3.7.0 → v3.10.1](https://github.com/asottile/pyupgrade/compare/v3.7.0...v3.10.1) - [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0) - [github.com/PyCQA/flake8: 6.0.0 → 6.1.0](https://github.com/PyCQA/flake8/compare/6.0.0...6.1.0) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89eb970..138a59e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: args: [--format, parsable, --strict] exclude: ^.github/ - repo: https://github.com/lyz-code/yamlfix - rev: 1.11.0 + rev: 1.12.0 hooks: - id: yamlfix exclude: ^.github/ @@ -36,18 +36,18 @@ repos: hooks: - id: reorder-python-imports - repo: https://github.com/asottile/pyupgrade - rev: v3.7.0 + rev: v3.10.1 hooks: - id: pyupgrade args: [--py3-plus] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black language_version: python3 args: [--line-length, '130', --preview] - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 args: [--config=.flake8] From d20d18fa98acf5c7c1455a8738fdb9533c99595d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 03:30:20 +0000 Subject: [PATCH 10/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- modules/config.py | 12 ++++-------- modules/core/recheck.py | 6 ++---- modules/core/remove_orphaned.py | 6 ++---- modules/core/remove_unregistered.py | 18 ++++++------------ modules/core/share_limits.py | 22 ++++++++-------------- modules/core/tag_nohardlinks.py | 14 +++++--------- modules/webhooks.py | 6 ++---- 7 files changed, 29 insertions(+), 55 deletions(-) diff --git a/modules/config.py b/modules/config.py index c8f1e79..6b48e4b 100755 --- a/modules/config.py +++ b/modules/config.py @@ -663,10 +663,8 @@ class Config: if empty_after_x_days <= days: num_del += 1 body += logger.print_line( - ( - f"{'Did not delete' if self.dry_run else 'Deleted'} " - f"{filename} from {folder} (Last modified {round(days)} days ago)." - ), + f"{'Did not delete' if self.dry_run else 'Deleted'} " + f"{filename} from {folder} (Last modified {round(days)} days ago).", self.loglevel, ) files += [str(filename)] @@ -679,10 +677,8 @@ class Config: for path in location_path_list: util.remove_empty_directories(path, "**/*") body += logger.print_line( - ( - f"{'Did not delete' if self.dry_run else 'Deleted'} {num_del} files " - f"({util.human_readable_size(size_bytes)}) from the {location}." - ), + f"{'Did not delete' if self.dry_run else 'Deleted'} {num_del} files " + f"({util.human_readable_size(size_bytes)}) from the {location}.", self.loglevel, ) attr = { diff --git a/modules/core/recheck.py b/modules/core/recheck.py index ab0a48e..30c31e7 100644 --- a/modules/core/recheck.py +++ b/modules/core/recheck.py @@ -64,10 +64,8 @@ class ReCheck: ) logger.debug( logger.insert_space( - ( - f"-- Seeding Time vs Max Seed Time: {timedelta(seconds=torrent.seeding_time)} < " - f"{timedelta(minutes=torrent.max_seeding_time)}" - ), + f"-- Seeding Time vs Max Seed Time: {timedelta(seconds=torrent.seeding_time)} < " + f"{timedelta(minutes=torrent.max_seeding_time)}", 4, ) ) diff --git a/modules/core/remove_orphaned.py b/modules/core/remove_orphaned.py index 601c841..d1841bb 100644 --- a/modules/core/remove_orphaned.py +++ b/modules/core/remove_orphaned.py @@ -67,10 +67,8 @@ class RemoveOrphaned: logger.print_line(f"{num_orphaned} Orphaned files found", self.config.loglevel) body += logger.print_line("\n".join(orphaned_files), self.config.loglevel) body += logger.print_line( - ( - f"{'Not moving' if self.config.dry_run else 'Moving'} {num_orphaned} Orphaned files " - f"to {self.orphaned_dir.replace(self.remote_dir,self.root_dir)}" - ), + f"{'Not moving' if self.config.dry_run else 'Moving'} {num_orphaned} Orphaned files " + f"to {self.orphaned_dir.replace(self.remote_dir,self.root_dir)}", self.config.loglevel, ) diff --git a/modules/core/remove_unregistered.py b/modules/core/remove_unregistered.py index 6060ed3..68107aa 100644 --- a/modules/core/remove_unregistered.py +++ b/modules/core/remove_unregistered.py @@ -142,28 +142,22 @@ class RemoveUnregistered: if self.stats_deleted >= 1 or self.stats_deleted_contents >= 1: if self.stats_deleted >= 1: logger.print_line( - ( - f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.stats_deleted} " - f".torrent{'s' if self.stats_deleted > 1 else ''} but not content files." - ), + f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.stats_deleted} " + f".torrent{'s' if self.stats_deleted > 1 else ''} but not content files.", self.config.loglevel, ) if self.stats_deleted_contents >= 1: logger.print_line( - ( - f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.stats_deleted_contents} " - f".torrent{'s' if self.stats_deleted_contents > 1 else ''} AND content files." - ), + f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.stats_deleted_contents} " + f".torrent{'s' if self.stats_deleted_contents > 1 else ''} AND content files.", self.config.loglevel, ) else: logger.print_line("No unregistered torrents found.", self.config.loglevel) if self.stats_untagged >= 1: logger.print_line( - ( - f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.tag_error} tags for {self.stats_untagged} " - f".torrent{'s.' if self.stats_untagged > 1 else '.'}" - ), + f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.tag_error} tags for {self.stats_untagged} " + f".torrent{'s.' if self.stats_untagged > 1 else '.'}", self.config.loglevel, ) if self.stats_tagged >= 1: diff --git a/modules/core/share_limits.py b/modules/core/share_limits.py index 2fd5076..5ce09cf 100644 --- a/modules/core/share_limits.py +++ b/modules/core/share_limits.py @@ -391,11 +391,9 @@ class ShareLimits: 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 seed time not met: {timedelta(seconds=torrent.seeding_time)} <=" - f" {timedelta(minutes=min_seeding_time)}. Removing Share Limits so qBittorrent can continue" - " seeding." - ), + f"Min seed time not met: {timedelta(seconds=torrent.seeding_time)} <=" + f" {timedelta(minutes=min_seeding_time)}. Removing Share Limits so qBittorrent can continue" + " seeding.", 8, ), self.config.loglevel, @@ -423,11 +421,9 @@ class ShareLimits: 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 number of seeds not met: Total Seeds ({torrent.num_complete}) <" - f"min_num_seeds({min_num_seeds}). Removing Share Limits so qBittorrent can continue" - " seeding." - ), + f"Min number of seeds not met: Total Seeds ({torrent.num_complete}) <" + f"min_num_seeds({min_num_seeds}). Removing Share Limits so qBittorrent can continue" + " seeding.", 8, ), self.config.loglevel, @@ -456,10 +452,8 @@ class ShareLimits: if seeding_time_limit: if (torrent.seeding_time >= seeding_time_limit * 60) and _has_reached_min_seeding_time_limit(): body += logger.insert_space( - ( - f"Seeding Time vs Max Seed Time: {timedelta(seconds=torrent.seeding_time)} >= " - f"{timedelta(minutes=seeding_time_limit)}" - ), + f"Seeding Time vs Max Seed Time: {timedelta(seconds=torrent.seeding_time)} >= " + f"{timedelta(minutes=seeding_time_limit)}", 8, ) return True diff --git a/modules/core/tag_nohardlinks.py b/modules/core/tag_nohardlinks.py index 05bac75..d4a628c 100644 --- a/modules/core/tag_nohardlinks.py +++ b/modules/core/tag_nohardlinks.py @@ -120,20 +120,16 @@ class TagNoHardLinks: self.check_previous_nohardlinks_tagged_torrents(has_nohardlinks, torrent, tracker, category) if self.stats_tagged >= 1: logger.print_line( - ( - f"{'Did not Tag' if self.config.dry_run else 'Added Tag'} for {self.stats_tagged} " - f".torrent{'s.' if self.stats_tagged > 1 else '.'}" - ), + f"{'Did not Tag' if self.config.dry_run else 'Added Tag'} for {self.stats_tagged} " + f".torrent{'s.' if self.stats_tagged > 1 else '.'}", self.config.loglevel, ) else: logger.print_line("No torrents to tag with no hardlinks.", self.config.loglevel) if self.stats_untagged >= 1: logger.print_line( - ( - f"{'Did not delete' if self.config.dry_run else 'Deleted'} " - f"{self.nohardlinks_tag} tags for {self.stats_untagged} " - f".torrent{'s.' if self.stats_untagged > 1 else '.'}" - ), + f"{'Did not delete' if self.config.dry_run else 'Deleted'} " + f"{self.nohardlinks_tag} tags for {self.stats_untagged} " + f".torrent{'s.' if self.stats_untagged > 1 else '.'}", self.config.loglevel, ) diff --git a/modules/webhooks.py b/modules/webhooks.py index 5d80245..41afd54 100755 --- a/modules/webhooks.py +++ b/modules/webhooks.py @@ -171,10 +171,8 @@ class Webhooks: def notify(self, torrents_updated=[], payload={}, group_by=""): if len(torrents_updated) > GROUP_NOTIFICATION_LIMIT: logger.trace( - ( - f"Number of torrents updated > {GROUP_NOTIFICATION_LIMIT}, grouping notifications" - f"{f' by {group_by}' if group_by else ''}" - ), + f"Number of torrents updated > {GROUP_NOTIFICATION_LIMIT}, grouping notifications" + f"{f' by {group_by}' if group_by else ''}", ) if group_by == "category": group_attr = group_notifications_by_key(payload, "torrent_category") From 04fa49046b11bdb9639f0694a469a6c3f5687068 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 02:37:28 +0000 Subject: [PATCH 11/15] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/lyz-code/yamlfix: 1.11.0 → 1.13.0](https://github.com/lyz-code/yamlfix/compare/1.11.0...1.13.0) - [github.com/asottile/pyupgrade: v3.7.0 → v3.10.1](https://github.com/asottile/pyupgrade/compare/v3.7.0...v3.10.1) - [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0) - [github.com/PyCQA/flake8: 6.0.0 → 6.1.0](https://github.com/PyCQA/flake8/compare/6.0.0...6.1.0) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89eb970..19a4d8d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: args: [--format, parsable, --strict] exclude: ^.github/ - repo: https://github.com/lyz-code/yamlfix - rev: 1.11.0 + rev: 1.13.0 hooks: - id: yamlfix exclude: ^.github/ @@ -36,18 +36,18 @@ repos: hooks: - id: reorder-python-imports - repo: https://github.com/asottile/pyupgrade - rev: v3.7.0 + rev: v3.10.1 hooks: - id: pyupgrade args: [--py3-plus] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black language_version: python3 args: [--line-length, '130', --preview] - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 args: [--config=.flake8] From 507453ef735ab8a065583f4f419d37e3d83d0c06 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 02:37:37 +0000 Subject: [PATCH 12/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- modules/config.py | 12 ++++-------- modules/core/recheck.py | 6 ++---- modules/core/remove_orphaned.py | 6 ++---- modules/core/remove_unregistered.py | 18 ++++++------------ modules/core/share_limits.py | 22 ++++++++-------------- modules/core/tag_nohardlinks.py | 14 +++++--------- modules/webhooks.py | 6 ++---- 7 files changed, 29 insertions(+), 55 deletions(-) diff --git a/modules/config.py b/modules/config.py index c8f1e79..6b48e4b 100755 --- a/modules/config.py +++ b/modules/config.py @@ -663,10 +663,8 @@ class Config: if empty_after_x_days <= days: num_del += 1 body += logger.print_line( - ( - f"{'Did not delete' if self.dry_run else 'Deleted'} " - f"{filename} from {folder} (Last modified {round(days)} days ago)." - ), + f"{'Did not delete' if self.dry_run else 'Deleted'} " + f"{filename} from {folder} (Last modified {round(days)} days ago).", self.loglevel, ) files += [str(filename)] @@ -679,10 +677,8 @@ class Config: for path in location_path_list: util.remove_empty_directories(path, "**/*") body += logger.print_line( - ( - f"{'Did not delete' if self.dry_run else 'Deleted'} {num_del} files " - f"({util.human_readable_size(size_bytes)}) from the {location}." - ), + f"{'Did not delete' if self.dry_run else 'Deleted'} {num_del} files " + f"({util.human_readable_size(size_bytes)}) from the {location}.", self.loglevel, ) attr = { diff --git a/modules/core/recheck.py b/modules/core/recheck.py index ab0a48e..30c31e7 100644 --- a/modules/core/recheck.py +++ b/modules/core/recheck.py @@ -64,10 +64,8 @@ class ReCheck: ) logger.debug( logger.insert_space( - ( - f"-- Seeding Time vs Max Seed Time: {timedelta(seconds=torrent.seeding_time)} < " - f"{timedelta(minutes=torrent.max_seeding_time)}" - ), + f"-- Seeding Time vs Max Seed Time: {timedelta(seconds=torrent.seeding_time)} < " + f"{timedelta(minutes=torrent.max_seeding_time)}", 4, ) ) diff --git a/modules/core/remove_orphaned.py b/modules/core/remove_orphaned.py index 601c841..d1841bb 100644 --- a/modules/core/remove_orphaned.py +++ b/modules/core/remove_orphaned.py @@ -67,10 +67,8 @@ class RemoveOrphaned: logger.print_line(f"{num_orphaned} Orphaned files found", self.config.loglevel) body += logger.print_line("\n".join(orphaned_files), self.config.loglevel) body += logger.print_line( - ( - f"{'Not moving' if self.config.dry_run else 'Moving'} {num_orphaned} Orphaned files " - f"to {self.orphaned_dir.replace(self.remote_dir,self.root_dir)}" - ), + f"{'Not moving' if self.config.dry_run else 'Moving'} {num_orphaned} Orphaned files " + f"to {self.orphaned_dir.replace(self.remote_dir,self.root_dir)}", self.config.loglevel, ) diff --git a/modules/core/remove_unregistered.py b/modules/core/remove_unregistered.py index 6060ed3..68107aa 100644 --- a/modules/core/remove_unregistered.py +++ b/modules/core/remove_unregistered.py @@ -142,28 +142,22 @@ class RemoveUnregistered: if self.stats_deleted >= 1 or self.stats_deleted_contents >= 1: if self.stats_deleted >= 1: logger.print_line( - ( - f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.stats_deleted} " - f".torrent{'s' if self.stats_deleted > 1 else ''} but not content files." - ), + f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.stats_deleted} " + f".torrent{'s' if self.stats_deleted > 1 else ''} but not content files.", self.config.loglevel, ) if self.stats_deleted_contents >= 1: logger.print_line( - ( - f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.stats_deleted_contents} " - f".torrent{'s' if self.stats_deleted_contents > 1 else ''} AND content files." - ), + f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.stats_deleted_contents} " + f".torrent{'s' if self.stats_deleted_contents > 1 else ''} AND content files.", self.config.loglevel, ) else: logger.print_line("No unregistered torrents found.", self.config.loglevel) if self.stats_untagged >= 1: logger.print_line( - ( - f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.tag_error} tags for {self.stats_untagged} " - f".torrent{'s.' if self.stats_untagged > 1 else '.'}" - ), + f"{'Did not delete' if self.config.dry_run else 'Deleted'} {self.tag_error} tags for {self.stats_untagged} " + f".torrent{'s.' if self.stats_untagged > 1 else '.'}", self.config.loglevel, ) if self.stats_tagged >= 1: diff --git a/modules/core/share_limits.py b/modules/core/share_limits.py index 2fd5076..5ce09cf 100644 --- a/modules/core/share_limits.py +++ b/modules/core/share_limits.py @@ -391,11 +391,9 @@ class ShareLimits: 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 seed time not met: {timedelta(seconds=torrent.seeding_time)} <=" - f" {timedelta(minutes=min_seeding_time)}. Removing Share Limits so qBittorrent can continue" - " seeding." - ), + f"Min seed time not met: {timedelta(seconds=torrent.seeding_time)} <=" + f" {timedelta(minutes=min_seeding_time)}. Removing Share Limits so qBittorrent can continue" + " seeding.", 8, ), self.config.loglevel, @@ -423,11 +421,9 @@ class ShareLimits: 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 number of seeds not met: Total Seeds ({torrent.num_complete}) <" - f"min_num_seeds({min_num_seeds}). Removing Share Limits so qBittorrent can continue" - " seeding." - ), + f"Min number of seeds not met: Total Seeds ({torrent.num_complete}) <" + f"min_num_seeds({min_num_seeds}). Removing Share Limits so qBittorrent can continue" + " seeding.", 8, ), self.config.loglevel, @@ -456,10 +452,8 @@ class ShareLimits: if seeding_time_limit: if (torrent.seeding_time >= seeding_time_limit * 60) and _has_reached_min_seeding_time_limit(): body += logger.insert_space( - ( - f"Seeding Time vs Max Seed Time: {timedelta(seconds=torrent.seeding_time)} >= " - f"{timedelta(minutes=seeding_time_limit)}" - ), + f"Seeding Time vs Max Seed Time: {timedelta(seconds=torrent.seeding_time)} >= " + f"{timedelta(minutes=seeding_time_limit)}", 8, ) return True diff --git a/modules/core/tag_nohardlinks.py b/modules/core/tag_nohardlinks.py index 05bac75..d4a628c 100644 --- a/modules/core/tag_nohardlinks.py +++ b/modules/core/tag_nohardlinks.py @@ -120,20 +120,16 @@ class TagNoHardLinks: self.check_previous_nohardlinks_tagged_torrents(has_nohardlinks, torrent, tracker, category) if self.stats_tagged >= 1: logger.print_line( - ( - f"{'Did not Tag' if self.config.dry_run else 'Added Tag'} for {self.stats_tagged} " - f".torrent{'s.' if self.stats_tagged > 1 else '.'}" - ), + f"{'Did not Tag' if self.config.dry_run else 'Added Tag'} for {self.stats_tagged} " + f".torrent{'s.' if self.stats_tagged > 1 else '.'}", self.config.loglevel, ) else: logger.print_line("No torrents to tag with no hardlinks.", self.config.loglevel) if self.stats_untagged >= 1: logger.print_line( - ( - f"{'Did not delete' if self.config.dry_run else 'Deleted'} " - f"{self.nohardlinks_tag} tags for {self.stats_untagged} " - f".torrent{'s.' if self.stats_untagged > 1 else '.'}" - ), + f"{'Did not delete' if self.config.dry_run else 'Deleted'} " + f"{self.nohardlinks_tag} tags for {self.stats_untagged} " + f".torrent{'s.' if self.stats_untagged > 1 else '.'}", self.config.loglevel, ) diff --git a/modules/webhooks.py b/modules/webhooks.py index 5d80245..41afd54 100755 --- a/modules/webhooks.py +++ b/modules/webhooks.py @@ -171,10 +171,8 @@ class Webhooks: def notify(self, torrents_updated=[], payload={}, group_by=""): if len(torrents_updated) > GROUP_NOTIFICATION_LIMIT: logger.trace( - ( - f"Number of torrents updated > {GROUP_NOTIFICATION_LIMIT}, grouping notifications" - f"{f' by {group_by}' if group_by else ''}" - ), + f"Number of torrents updated > {GROUP_NOTIFICATION_LIMIT}, grouping notifications" + f"{f' by {group_by}' if group_by else ''}", ) if group_by == "category": group_attr = group_notifications_by_key(payload, "torrent_category") From 99efdbf3eaec9e060785fc711fd6b7ca26436188 Mon Sep 17 00:00:00 2001 From: bobokun Date: Tue, 8 Aug 2023 21:08:55 -0400 Subject: [PATCH 13/15] Fixes #370 Bug causing min_num_seeds not being respected when cleanup set to false --- VERSION | 2 +- modules/core/share_limits.py | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index 70b068d..024a1e3 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3-develop4 +4.0.3-develop5 diff --git a/modules/core/share_limits.py b/modules/core/share_limits.py index 5ce09cf..ee39fef 100644 --- a/modules/core/share_limits.py +++ b/modules/core/share_limits.py @@ -55,6 +55,7 @@ class ShareLimits: "torrent_max_ratio": group_config["max_ratio"], "torrent_max_seeding_time": group_config["max_seeding_time"], "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"], } if len(self.torrents_updated) > 0: @@ -196,6 +197,7 @@ class ShareLimits: "Config Max Seeding Time vs Torrent Max Seeding Time: " f"{group_config['max_seeding_time']} vs {torrent.max_seeding_time}" ) + logger.trace(f"Config Min Num Seeds vs Torrent Num Seeds: {group_config['min_num_seeds']} vs {torrent.num_complete}") logger.trace(f"check_max_seeding_time: {check_max_seeding_time}") logger.trace( "Config Limit Upload Speed vs Torrent Limit Upload Speed: " @@ -218,17 +220,17 @@ class ShareLimits: self.stats_tagged += 1 self.torrents_updated.append(t_name) + tor_reached_seed_limit = self.has_reached_seed_limit( + torrent=torrent, + max_ratio=group_config["max_ratio"], + max_seeding_time=group_config["max_seeding_time"], + min_seeding_time=group_config["min_seeding_time"], + min_num_seeds=group_config["min_num_seeds"], + resume_torrent=group_config["resume_torrent_after_change"], + tracker=tracker["url"], + ) # Cleanup torrents if the torrent meets the criteria for deletion and cleanup is enabled if group_config["cleanup"]: - tor_reached_seed_limit = self.has_reached_seed_limit( - torrent=torrent, - max_ratio=group_config["max_ratio"], - max_seeding_time=group_config["max_seeding_time"], - min_seeding_time=group_config["min_seeding_time"], - min_num_seeds=group_config["min_num_seeds"], - resume_torrent=group_config["resume_torrent_after_change"], - tracker=tracker["url"], - ) if tor_reached_seed_limit: if t_hash not in self.tdel_dict: self.tdel_dict[t_hash] = {} @@ -421,7 +423,7 @@ class ShareLimits: 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 number of seeds not met: Total Seeds ({torrent.num_complete}) <" + f"Min number of seeds not met: Total Seeds ({torrent.num_complete}) < " f"min_num_seeds({min_num_seeds}). Removing Share Limits so qBittorrent can continue" " seeding.", 8, From 761f0e15ab209fc6802dcae081af608fc67388c2 Mon Sep 17 00:00:00 2001 From: bobokun Date: Fri, 11 Aug 2023 17:06:34 -0400 Subject: [PATCH 14/15] potential fix for #363 --- VERSION | 2 +- modules/util.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 024a1e3..464f31c 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3-develop5 +4.0.3-develop6 diff --git a/modules/util.py b/modules/util.py index 57bf710..291eeb2 100755 --- a/modules/util.py +++ b/modules/util.py @@ -512,12 +512,12 @@ class CheckHardLinks: continue file_size = os.stat(files).st_size file_no_hardlinks = os.stat(files).st_nlink - logger.trace(f"Checking file: {file}") - logger.trace(f"Checking file inum: {os.stat(file).st_ino}") + logger.trace(f"Checking file: {files}") + logger.trace(f"Checking file inum: {os.stat(files).st_ino}") logger.trace(f"Checking file size: {file_size}") logger.trace(f"Checking no of hard links: {file_no_hardlinks}") - logger.trace(f"Checking inode_count dict: {self.inode_count.get(os.stat(file).st_ino)}") - if file_no_hardlinks - self.inode_count.get(os.stat(file).st_ino, 1) > 0 and file_size >= ( + logger.trace(f"Checking inode_count dict: {self.inode_count.get(os.stat(files).st_ino)}") + if file_no_hardlinks - self.inode_count.get(os.stat(files).st_ino, 1) > 0 and file_size >= ( largest_file_size * threshold ): check_for_hl = False From 941160f26ef1b45795b7ae45f31905ba2781efdd Mon Sep 17 00:00:00 2001 From: bobokun Date: Mon, 14 Aug 2023 20:01:13 -0400 Subject: [PATCH 15/15] 4.0.3 --- CHANGELOG | 17 ++++++++--------- VERSION | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e752dbd..b7acdcb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,13 +1,12 @@ # Requirements Updated -- qbitorrent-api updated to 2023.6.50 -- ruamel.yaml updated to 0.17.32 -# New Features -- Adds min_num_seeds condition to share_limits (Closes [#321](https://github.com/StuffAnThings/qbit_manage/issues/321)) +- qbitorrent-api updated to 2023.7.52 # Bug Fixes -Fixes [#333](https://github.com/StuffAnThings/qbit_manage/issues/333) -Fixes [#340](https://github.com/StuffAnThings/qbit_manage/issues/340) -Fixes [#343](https://github.com/StuffAnThings/qbit_manage/issues/343) -Fixes bug when checking tags in torrents +- Fixes a few webhook bugs with Notifiarr +- Fixes [#355](https://github.com/StuffAnThings/qbit_manage/issues/355) +- Fixes [#356](https://github.com/StuffAnThings/qbit_manage/issues/356) +- Fixes [#363](https://github.com/StuffAnThings/qbit_manage/issues/363) +- Fixes [#370](https://github.com/StuffAnThings/qbit_manage/issues/370) -**Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v4.0.1...v4.0.2 + +**Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v4.0.2...v4.0.3 diff --git a/VERSION b/VERSION index 464f31c..c4e41f9 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3-develop6 +4.0.3