Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling torrent clients without deleting config #103

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion utils/confighandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def configureTorrents(self) -> None:
clients = {"rtorrent": RTorrent, "deluge": Deluge, "qbittorrent": Qbittorrent}
for client in clients:
try:
if client in self.conf:
if client in self.conf and not self.get(client, "disable", False):
settings = dict(self.conf[client]) # type: ignore
clientType = clients[client]
self.torrent_clients.append(clientType(settings))
Expand Down
18 changes: 11 additions & 7 deletions webui/webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def index():
@settings_page.route("/settings/<page>", methods=["GET", "POST"])
def settings(page):
template_context = {}
enable = page in conf and not conf.get(page, "disable", False)
match page:
case "backend":
template_context["settings_option"] = "your stash-empornium backend"
Expand All @@ -39,7 +40,6 @@ def settings(page):
form = StashSettings(url=conf.get(page, "url", ""), api_key=conf.get(page, "api_key", ""))
case "redis":
template_context["settings_option"] = "your redis server"
enable = "redis" in conf
form = RedisSettings(
enable_form=enable,
host=conf.get(page, "host", ""),
Expand All @@ -50,7 +50,6 @@ def settings(page):
)
case "rtorrent":
template_context["settings_option"] = "your rTorrent client"
enable = "rtorrent" in conf
form = RTorrentSettings(
enable_form=enable,
host=conf.get(page, "host", ""),
Expand All @@ -63,7 +62,6 @@ def settings(page):
)
case "deluge":
template_context["settings_option"] = "your Deluge client"
enable = "deluge" in conf
form = DelugeSettings(
enable_form=enable,
host=conf.get(page, "host", ""),
Expand All @@ -73,7 +71,6 @@ def settings(page):
)
case "qbittorrent":
template_context["settings_option"] = "your qBittorrent client"
enable = "qbittorrent" in conf
form = QBittorrentSettings(
enable_form=enable,
host=conf.get(page, "host", ""),
Expand Down Expand Up @@ -105,6 +102,7 @@ def settings(page):
conf.update_file()
case "redis":
if form.data["enable_form"]:
conf.set(page, "disable", False)
conf.set(page, "host", form.data["host"])
conf.set(page, "port", int(form.data["port"]))
conf.set(page, "ssl", form.data["ssl"])
Expand All @@ -121,6 +119,7 @@ def settings(page):
conf.update_file()
case "rtorrent":
if form.data["enable_form"]:
conf.set(page, "disable", False)
conf.set(page, "host", form.data["host"])
conf.set(page, "port", int(form.data["port"]))
conf.set(page, "ssl", form.data["ssl"])
Expand All @@ -138,11 +137,13 @@ def settings(page):
else:
conf.delete(page, "label")
else:
conf.delete(page)
if page in conf:
conf.set(page, "disable", True)
conf.configureTorrents()
conf.update_file()
case "deluge":
if form.data["enable_form"]:
conf.set(page, "disable", False)
conf.set(page, "host", form.data["host"])
conf.set(page, "port", int(form.data["port"]))
conf.set(page, "ssl", form.data["ssl"])
Expand All @@ -151,11 +152,13 @@ def settings(page):
else:
conf.delete(page, "password")
else:
conf.delete(page)
if page in conf:
conf.set(page, "disable", True)
conf.configureTorrents()
conf.update_file()
case "qbittorrent":
if form.data["enable_form"]:
conf.set(page, "disable", False)
conf.set(page, "host", form.data["host"])
conf.set(page, "port", int(form.data["port"]))
conf.set(page, "ssl", form.data["ssl"])
Expand All @@ -172,7 +175,8 @@ def settings(page):
else:
conf.delete(page, "label")
else:
conf.delete(page)
if page in conf:
conf.set(page, "disable", True)
conf.configureTorrents()
conf.update_file()
case _:
Expand Down