- read [ignored_tags] instead of [ignored_domains], so tag-based ignoring
actually works
- match ignored tags as whole tags, not substrings ('ipt' no longer matches
'iptorrents')
- send the login-error notification through the Pushover client instead of
the non-existent module-level send_message()
- handle an empty torrent list instead of raising IndexError before any
summary is sent
- tag a new torrent once instead of once per code path
- honour toml_path without DOCKER in AppriseClient
- close replaced log handlers so the file descriptor is released
Also add the missing [telemetry] section to config.toml.example, which
qbit-maid.py requires at startup.
The tests that pinned each bug now assert the fixed behaviour, and the
suite still reports 100% coverage.
38 lines
1.4 KiB
Python
Executable File
38 lines
1.4 KiB
Python
Executable File
import requests as r
|
|
from tomllib import load
|
|
import os
|
|
|
|
def apprise_notify(req_obj, host, port, aurls, title, body):
|
|
payload = {'urls': aurls,'title': title,'body': body,}
|
|
url = f'http://{host}:{port}/notify/'
|
|
apprise_response = req_obj.post(url, json = payload ,verify=False)
|
|
return apprise_response
|
|
|
|
class AppriseClient:
|
|
def __init__(self):
|
|
self.config = ''
|
|
if os.environ.get("DOCKER"):
|
|
self.host = os.environ["host"]
|
|
self.port = os.environ["port"]
|
|
self.aurls = os.environ["aurls"]
|
|
self.title = os.environ["title"]
|
|
self.body = os.environ["body"]
|
|
if os.environ.get("toml_path"):
|
|
config_file_path=os.environ["toml_path"]
|
|
with open(config_file_path, 'rb') as c:
|
|
self.config = load(c)
|
|
if os.path.exists('./config.toml'):
|
|
config_file_path = './config.toml'
|
|
with open(config_file_path, 'rb') as c:
|
|
self.config = load(c)
|
|
if self.config:
|
|
self.host = self.config["apprise"]["host"]
|
|
self.port = self.config["apprise"]["port"]
|
|
self.aurls = self.config["apprise"]["aurls"]
|
|
self.title = self.config["apprise"]["title"]
|
|
self.body = self.config["apprise"]["body"]
|
|
self.apprise_response = apprise_notify(r,self.host,self.port,self.aurls,self.title,self.body)
|
|
|
|
if __name__ == "__main__":
|
|
AppriseClient()
|