Skip to content

Commit

Permalink
[patch] Added config option to allow qbittorrent v5
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Nov 27, 2024
1 parent d61c33c commit 7262b39
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
3 changes: 3 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ UserName = "CHANGE_ME"
# If you set "Bypass authentication on localhost or whitelisted IPs" remove this field.
Password = "CHANGE_ME"

# Set to true to allow abittorrent v5 (Some API calls will not work as expected due to qbittorrent API issues not qBitrr)
v5 = false


[Sonarr-TV]
# Toggle whether to manage the Servarr instance torrents.
Expand Down
1 change: 1 addition & 0 deletions qBitrr/env_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class qBit:
port = environ.var(None, converter=Converter.int)
username = environ.var(None)
password = environ.var(None)
v5 = environ.var(False)

overrides: Overrides = environ.group(Overrides)
settings: Settings = environ.group(Settings)
Expand Down
6 changes: 6 additions & 0 deletions qBitrr/gen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ def _add_qbit_section(config: TOMLDocument):
"Password",
ENVIRO_CONFIG.qbit.password or "CHANGE_ME",
)
_gen_default_line(
qbit,
"Set to true to allow abittorrent v5 (Some API calls will not work as expected due to qbittorrent API issues not qBitrr)",
"v5",
ENVIRO_CONFIG.qbit.v5 or False,
)
config.add("qBit", qbit)


Expand Down
34 changes: 23 additions & 11 deletions qBitrr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __init__(self):
self.qBit_Port = CONFIG.get("qBit.Port", fallback=8105)
self.qBit_UserName = CONFIG.get("qBit.UserName", fallback=None)
self.qBit_Password = CONFIG.get("qBit.Password", fallback=None)
self.qBit_v5 = CONFIG.get("qBit.v5", fallback=False)
self.logger = logging.getLogger(f"qBitrr.{self._name}")
if ENABLE_LOGS:
logs_folder = HOME_PATH.joinpath("logs")
Expand Down Expand Up @@ -127,17 +128,28 @@ def __init__(self):
run_logs(self.logger)

def _version_validator(self):
if self.min_supported_version <= self.current_qbit_version <= self.max_supported_version:
if self._validated_version:
self.logger.info(
"Current qBitTorrent version is supported: %s", self.current_qbit_version
)
else:
self.logger.warning(
"Could not validate current qBitTorrent version, assuming: %s",
self.current_qbit_version,
)
time.sleep(10)
validated = False
if self.qBit_v5:
if self.min_supported_version <= self.current_qbit_version:
validated = True
else:
if (
self.min_supported_version
<= self.current_qbit_version
<= self.max_supported_version
):
validated = True

if self._validated_version and validated:
self.logger.info(
"Current qBitTorrent version is supported: %s", self.current_qbit_version
)
elif not self._validated_version and validated:
self.logger.warning(
"Could not validate current qBitTorrent version, assuming: %s",
self.current_qbit_version,
)
time.sleep(10)
else:
self.logger.critical(
"You are currently running qBitTorrent version %s, "
Expand Down

0 comments on commit 7262b39

Please sign in to comment.