diff --git a/qbit-maid.py b/qbit-maid.py old mode 100755 new mode 100644 index 6341ea4..a8e7faf --- a/qbit-maid.py +++ b/qbit-maid.py @@ -6,6 +6,7 @@ from qlist import * from qlogging import * from qprocess import * import time +import datetime import logging from collections import Counter @@ -13,6 +14,7 @@ class Qbt: def __init__(self): """Main object, should be calling functions from qlist.py, qlogging.py and qprocess.py""" # Open the config. Needs a json file with the data in config.json.example + self.st = datetime.datetime.now() c = open('./config.json') self.config = load(c) w = open('./category-whitelist.json') @@ -65,6 +67,7 @@ class Qbt: # Pulling all torrent data self.torrentlist = self.qbt_client.torrents_info() #Main process block + #debugpremecal(self) if self.use_log: listqbitapiinfo(self) listfirsttor(self) @@ -76,11 +79,12 @@ class Qbt: torprocessor(self) if self.use_log: printprocessor(self) - if self.use_pushover: - tornotifysummary(self) if self.config["delete_torrents"]: tordelete(self) - + self.et = datetime.datetime.now() + getscriptruntime(self) + if self.use_pushover: + tornotifysummary(self) # Run if __name__== "__main__": Qbt() \ No newline at end of file diff --git a/qlist.py b/qlist.py index 63b5577..6d6cfc7 100644 --- a/qlist.py +++ b/qlist.py @@ -9,7 +9,7 @@ def buildtorlist(self): torrent = self.torrentlist.pop() if self.use_log: self.tl.debug(f'["{torrent["name"][0:20]}..."] {torrent["infohash_v1"]}') - if torrent['added_on'] + self.minimum_age <= self.t.time(): + if torrent['added_on'] + self.minimum_age >= self.t.time(): self.preme_tor_counter += 1 continue if torrent['category'] in self.cat_whitelist.values(): diff --git a/qlogging.py b/qlogging.py index 5c6627d..3b36379 100644 --- a/qlogging.py +++ b/qlogging.py @@ -39,7 +39,8 @@ def tornotifysummary(self): Protected: {self.c[self.tracker_protected_tag]}\n\ Non-protected: {self.c[self.tracker_non_protected_tag]}\n\ Orphaned: {self.up_tor_counter}\n\ - Marked for deletion: {len(self.torrent_hash_delete_list)}", title="--- qbit-maid summary ---") + Marked for deletion: {len(self.torrent_hash_delete_list)}\n\ + {self.extm}", title="--- qbit-maid summary ---") def getunixtimestamp(self): """Used for debuging and development related to unixtimestamps, not used in main script but useful""" @@ -72,4 +73,17 @@ def torrentcount(self): self.tl.debug(f'torrents that aren\'t protected {self.tracker_list.count("public")}') def torlisttags(self): - pass \ No newline at end of file + pass + +def debugpremecal(self): + for torrent in self.torrentlist: + if torrent['infohash_v1'] == 'a89b484ea375094af53ce89ecbea14bf086d6284': + print(torrent["name"][0:20]) + print(torrent['added_on'] + self.minimum_age >= self.t.time()) + +def getscriptruntime(self): + elapsed_time = self.et - self.st + if self.use_log: + self.tl.info(f'Execution time: [{elapsed_time}]') + if self.use_pushover: + self.extm = f"Execution time: [{elapsed_time}]" \ No newline at end of file