From 4908d62999a0ae44a45be0fc2d7e5a0a7a3ee34d Mon Sep 17 00:00:00 2001 From: jblu Date: Wed, 20 Jul 2022 09:57:22 -0500 Subject: [PATCH] added tor notify --- config.json.example | 5 ++++- qbit-maid.py | 6 ++++++ qlogging.py | 7 ++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/config.json.example b/config.json.example index 6661697..9fe06d8 100644 --- a/config.json.example +++ b/config.json.example @@ -5,5 +5,8 @@ "password": "admin", "loglevel": "INFO", "logpath": "./qc.log", - "age": 2419200 + "age": 2419200, + "use_pushover": true, + "po_key": "", + "po_token": "" } \ No newline at end of file diff --git a/qbit-maid.py b/qbit-maid.py index c278a6b..5556ada 100644 --- a/qbit-maid.py +++ b/qbit-maid.py @@ -1,5 +1,6 @@ #The first file shall contain an client to the qbit api and the processing of the torrents. import qbittorrentapi +import pushover from json import load from qlist import * from qlogging import * @@ -22,10 +23,15 @@ class Qbt: ) # Create the logging object self.tl = logging + self.po = pushover + self.use_pushover= self.config["use_pushover"] + self.po_key=self.config["po_key"] + self.po_token=self.config["po_token"] # Variables torlog uses from config.json self.logpath=self.config["logpath"] self.loglevel=self.config["loglevel"] torlog(self) + tornotify(self) self.t = time f = open('./tracker-whitelist.json') self.tracker_whitelist = load(f) diff --git a/qlogging.py b/qlogging.py index 01385df..f8cc6ee 100644 --- a/qlogging.py +++ b/qlogging.py @@ -1,14 +1,15 @@ #The third file shall contain logging and email communication. def torlog(self): - if self.loglevel == 'DEBUG': self.tl.basicConfig(filename=self.logpath, format='%(asctime)s:%(levelname)s:%(message)s', encoding='utf-8', datefmt='%m/%d/%Y %I:%M:%S %p',level=self.tl.DEBUG) if self.loglevel == 'INFO': self.tl.basicConfig(filename=self.logpath, format='%(asctime)s:%(levelname)s:%(message)s', encoding='utf-8', datefmt='%m/%d/%Y %I:%M:%S %p',level=self.tl.INFO) -def toremail(self): - pass +def tornotify(self): + if self.use_pushover: + self.poc = self.po.Client(self.po_key, api_token=self.po_token) + self.poc.send_message("Test Message", title="qbit-maid") def getunixtimestamp(self): self.uts = self.t.time()