diff --git a/README.md b/README.md index 1f67568..a1902d0 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ The objective is to filter torrents based on the following criteria: - ratio - state -The first file shall contain an client to the qbit api and the processing of the torrents. +Client to the qbit api and the processing of the torrents. qbit-clean.py -The second file shall contain functions to build out a list of torrents. +Functions to build out a list of torrents. qlist.py -The third file shall contain logging and email communication. +Logging and push notification communication. qlogging.py -The fourth file shall be logic to process torrents. +Logic to process torrents. qprocess.py You will need a config.json in the root directory. @@ -30,9 +30,12 @@ It should look something like this: "password": "admin", "loglevel": "INFO", "logpath": "./qc.log", - "age": 2419200 + "age": 2419200, + "use_pushover": true, + "po_key": "", + "po_token": "" } -loglevel is what log messages are written to the log file. It only accepts INFO or DEBUG. +loglevel - is what log messages are written to the log file. It only accepts INFO or DEBUG. -Age is a number in seconds for how long we keep torrents from IPTORRENTS. \ No newline at end of file +age - is a number in seconds for how long we keep torrents from IPTORRENTS. \ No newline at end of file diff --git a/config.json.example b/config.json.example index 9fe06d8..e8e1b15 100644 --- a/config.json.example +++ b/config.json.example @@ -7,6 +7,7 @@ "logpath": "./qc.log", "age": 2419200, "use_pushover": true, + "use_log": true, "po_key": "", "po_token": "" } \ No newline at end of file diff --git a/qbit-maid.py b/qbit-maid.py index 5556ada..e319710 100644 --- a/qbit-maid.py +++ b/qbit-maid.py @@ -24,12 +24,13 @@ 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"] + self.use_pushover = self.config["use_pushover"] + self.use_log = self.config["use_log"] + 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"] + self.logpath = self.config["logpath"] + self.loglevel = self.config["loglevel"] torlog(self) tornotify(self) self.t = time @@ -55,6 +56,8 @@ class Qbt: torrentcount(self) torprocessor(self) printprocessor(self) + if self.use_pushover: + tornotifysummary(self) tordelete(self) if __name__== "__main__": diff --git a/qlogging.py b/qlogging.py index f8cc6ee..ff3c2f1 100644 --- a/qlogging.py +++ b/qlogging.py @@ -1,15 +1,24 @@ #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) + if self.use_log: + 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) + elif 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 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 tornotifytest(self): + self.poc.send_message("Test Message", title="qbit-maid") + +def tornotifysummary(self): + self.poc.send_message(f' Protected torrents: {len(self.tracker_protected_list)}\n\ + Non-protected torrents: {len(self.tracker_nonprotected_list)}\n\ + Total torrents set for deletion: {len(self.torrent_hash_delete_list)}', title="qbit-maid summary") + def getunixtimestamp(self): self.uts = self.t.time()