From d557a3a420e44e83c14c8de78a0a7de53c55255c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jan 2022 00:49:17 +0000 Subject: [PATCH 1/9] Bump requests from 2.27.0 to 2.27.1 Bumps [requests](https://github.com/psf/requests) from 2.27.0 to 2.27.1. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](https://github.com/psf/requests/compare/v2.27.0...v2.27.1) --- updated-dependencies: - dependency-name: requests 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 a601306..43281a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ qbittorrent-api==2021.12.26 schedule==1.1.0 retrying==1.3.3 alive_progress==2.1.0 -requests==2.27.0 \ No newline at end of file +requests==2.27.1 \ No newline at end of file From 2e8cfa4798b02f9bc03a0f17dac94d39d8dbd0dc Mon Sep 17 00:00:00 2001 From: bobokun Date: Thu, 6 Jan 2022 10:58:48 -0500 Subject: [PATCH 2/9] 3.1.5 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b532f3d..97ceee1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.4 \ No newline at end of file +3.1.5 \ No newline at end of file From 1fb198f613a167cb814df9fbd8d0ba32b56f0ef8 Mon Sep 17 00:00:00 2001 From: bobokun Date: Thu, 6 Jan 2022 12:13:59 -0500 Subject: [PATCH 3/9] Bug Fix: Create Category if missing in qbittorrent --- modules/qbittorrent.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index 3403916..7a9d2b6 100644 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -1,5 +1,5 @@ import logging, os -from qbittorrentapi import Client, LoginFailed, APIConnectionError, NotFound404Error +from qbittorrentapi import Client, LoginFailed, APIConnectionError, NotFound404Error, Conflict409Error from modules import util from modules.util import Failed, print_line, print_multiline, separator from datetime import timedelta @@ -132,7 +132,14 @@ class Qbt: if torrent.category == '': new_cat = self.config.get_category(torrent.save_path) tracker = self.config.get_tags([x.url for x in torrent.trackers if x.url.startswith('http')]) - if not dry_run: torrent.set_category(category=new_cat) + if not dry_run: + try: + torrent.set_category(category=new_cat) + except Conflict409Error: + e = print_line(f'Existing category "{new_cat}" not found for save path {torrent.save_path}, category will be created.', loglevel) + self.config.notify(e, 'Update Category', False) + self.client.torrent_categories.create_category(name=new_cat, save_path=torrent.save_path) + torrent.set_category(category=new_cat) body = [] body += print_line(util.insert_space(f'Torrent Name: {torrent.name}', 3), loglevel) body += print_line(util.insert_space(f'New Category: {new_cat}', 3), loglevel) From 14390b34502a49b1954d373a0ce19be14184cb37 Mon Sep 17 00:00:00 2001 From: bobokun Date: Thu, 6 Jan 2022 13:18:56 -0500 Subject: [PATCH 4/9] breaking config change: category Category save_path must be exact match and not keyword --- modules/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/config.py b/modules/config.py index 9f16e1d..c1df50e 100644 --- a/modules/config.py +++ b/modules/config.py @@ -293,9 +293,10 @@ class Config: if "cat" in self.data and self.data["cat"] is not None: cat_path = self.data["cat"] for cat, save_path in cat_path.items(): - if save_path in path: + if save_path == path: category = cat break + if not category: default_cat = path.split('/')[-2] category = str(default_cat) From 307959cd3cde857643b6abe28ce3d7094ff75f6d Mon Sep 17 00:00:00 2001 From: bobokun Date: Fri, 7 Jan 2022 08:10:15 -0500 Subject: [PATCH 5/9] Bug fix: Incorrect category when missing trailing slash --- modules/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/config.py b/modules/config.py index c1df50e..aaf5ef1 100644 --- a/modules/config.py +++ b/modules/config.py @@ -293,7 +293,7 @@ class Config: if "cat" in self.data and self.data["cat"] is not None: cat_path = self.data["cat"] for cat, save_path in cat_path.items(): - if save_path == path: + if os.path.join(save_path, '') == path: category = cat break From 931613877296035040580d1b8753af402c7f46d7 Mon Sep 17 00:00:00 2001 From: bobokun Date: Fri, 7 Jan 2022 12:58:18 -0500 Subject: [PATCH 6/9] added ignore_msg in BHD integration --- modules/qbittorrent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index 7a9d2b6..2ffa4bf 100644 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -423,6 +423,9 @@ class Qbt: 'RETITLED', 'TRUNCATED' ] + ignore_msgs = [ + 'YOU HAVE REACHED THE CLIENT LIMIT FOR THIS TORRENT' + ] for torrent in self.torrentvalid: check_tags = util.get_list(torrent.tags) # Remove any potential unregistered torrents Tags that are no longer unreachable. @@ -443,7 +446,7 @@ class Qbt: # Tag any potential unregistered torrents if not any(m in msg_up for m in unreg_msgs) and x.status == 4 and 'issue' not in check_tags: # Check for unregistered torrents using BHD API if the tracker is BHD - if 'tracker.beyond-hd.me' in tracker['url'] and self.config.BeyondHD is not None: + if 'tracker.beyond-hd.me' in tracker['url'] and self.config.BeyondHD is not None and all(x not in msg_up for x in ignore_msgs): json = {"info_hash": torrent.hash} response = self.config.BeyondHD.search(json) if response['total_results'] <= 1: From 3b99fcb6b7ee916c9d7d2d40ff3e9db6ce190d84 Mon Sep 17 00:00:00 2001 From: bobokun Date: Fri, 7 Jan 2022 14:48:22 -0500 Subject: [PATCH 7/9] Update API Compatibility check for breaking v4.4.0 --- modules/qbittorrent.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index 2ffa4bf..54da01e 100644 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -1,4 +1,4 @@ -import logging, os +import logging, os, sys from qbittorrentapi import Client, LoginFailed, APIConnectionError, NotFound404Error, Conflict409Error from modules import util from modules.util import Failed, print_line, print_multiline, separator @@ -11,6 +11,8 @@ logger = logging.getLogger("qBit Manage") class Qbt: + SUPPORTED_VERSION = 'v4.3.9' + def __init__(self, config, params): self.config = config config_handler.set_global(bar=None, receipt_text=False) @@ -21,13 +23,27 @@ class Qbt: try: self.client = Client(host=self.host, username=self.username, password=self.password) self.client.auth_log_in() + logger.debug(f'qBittorrent: {self.client.app.version}') + logger.debug(f'qBittorrent Web API: {self.client.app.web_api_version}') + logger.debug(f'qbit_manage support version: {self.SUPPORTED_VERSION}') + if self.client.app.version > self.SUPPORTED_VERSION: + e = f"Qbittorrent Error: qbit_manage is only comaptible with {self.SUPPORTED_VERSION} or lower. You are currently on {self.client.app.version}" + self.config.notify(e, "Qbittorrent Error") + print_line(e, 'CRITICAL') + sys.exit(0) logger.info("Qbt Connection Successful") except LoginFailed: - raise Failed("Qbittorrent Error: Failed to login. Invalid username/password.") + e = "Qbittorrent Error: Failed to login. Invalid username/password." + self.config.notify(e, "Qbittorrent Error") + raise Failed(e) except APIConnectionError: - raise Failed("Qbittorrent Error: Unable to connect to the client.") + e = "Qbittorrent Error: Unable to connect to the client." + self.config.notify(e, "Qbittorrent Error") + raise Failed(e) except Exception: - raise Failed("Qbittorrent Error: Unable to connect to the client.") + e = "Qbittorrent Error: Unable to connect to the client." + self.config.notify(e, "Qbittorrent Error") + raise Failed(e) separator("Getting Torrent List", space=False, border=False) self.torrent_list = self.get_torrents({'sort': 'added_on'}) From 9ea244d4267fb980e618da12ed4c753b0ecbfaea Mon Sep 17 00:00:00 2001 From: bobokun Date: Fri, 7 Jan 2022 14:54:33 -0500 Subject: [PATCH 8/9] Minor adjustments to error title --- modules/qbittorrent.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index 54da01e..4c90b10 100644 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -28,21 +28,21 @@ class Qbt: logger.debug(f'qbit_manage support version: {self.SUPPORTED_VERSION}') if self.client.app.version > self.SUPPORTED_VERSION: e = f"Qbittorrent Error: qbit_manage is only comaptible with {self.SUPPORTED_VERSION} or lower. You are currently on {self.client.app.version}" - self.config.notify(e, "Qbittorrent Error") + self.config.notify(e, "Qbittorrent") print_line(e, 'CRITICAL') sys.exit(0) logger.info("Qbt Connection Successful") except LoginFailed: e = "Qbittorrent Error: Failed to login. Invalid username/password." - self.config.notify(e, "Qbittorrent Error") + self.config.notify(e, "Qbittorrent") raise Failed(e) except APIConnectionError: e = "Qbittorrent Error: Unable to connect to the client." - self.config.notify(e, "Qbittorrent Error") + self.config.notify(e, "Qbittorrent") raise Failed(e) except Exception: e = "Qbittorrent Error: Unable to connect to the client." - self.config.notify(e, "Qbittorrent Error") + self.config.notify(e, "Qbittorrent") raise Failed(e) separator("Getting Torrent List", space=False, border=False) self.torrent_list = self.get_torrents({'sort': 'added_on'}) From 15075cac07627d03606412b41ae571348b13fad1 Mon Sep 17 00:00:00 2001 From: bobokun Date: Fri, 7 Jan 2022 15:38:06 -0500 Subject: [PATCH 9/9] check compatibility only on major release versions --- modules/qbittorrent.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index 4c90b10..c365d73 100644 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -11,7 +11,7 @@ logger = logging.getLogger("qBit Manage") class Qbt: - SUPPORTED_VERSION = 'v4.3.9' + SUPPORTED_VERSION = 'v4.3' def __init__(self, config, params): self.config = config @@ -26,8 +26,9 @@ class Qbt: logger.debug(f'qBittorrent: {self.client.app.version}') logger.debug(f'qBittorrent Web API: {self.client.app.web_api_version}') logger.debug(f'qbit_manage support version: {self.SUPPORTED_VERSION}') - if self.client.app.version > self.SUPPORTED_VERSION: - e = f"Qbittorrent Error: qbit_manage is only comaptible with {self.SUPPORTED_VERSION} or lower. You are currently on {self.client.app.version}" + current_version = ".".join(self.client.app.version.split(".")[:2]) + if current_version > self.SUPPORTED_VERSION: + e = f"Qbittorrent Error: qbit_manage is only comaptible with {self.SUPPORTED_VERSION}.* or lower. You are currently on {self.client.app.version}" self.config.notify(e, "Qbittorrent") print_line(e, 'CRITICAL') sys.exit(0)