changed readme and added more tornotify functions
This commit is contained in:
		
							
								
								
									
										17
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								README.md
									
									
									
									
									
								
							| @@ -8,16 +8,16 @@ The objective is to filter torrents based on the following criteria: | |||||||
| - ratio | - ratio | ||||||
| - state | - 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 | 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 | qlist.py | ||||||
|  |  | ||||||
| The third file shall contain logging and email communication. | Logging and push notification communication. | ||||||
| qlogging.py | qlogging.py | ||||||
|  |  | ||||||
| The fourth file shall be logic to process torrents. | Logic to process torrents. | ||||||
| qprocess.py | qprocess.py | ||||||
|  |  | ||||||
| You will need a config.json in the root directory. | You will need a config.json in the root directory. | ||||||
| @@ -30,9 +30,12 @@ It should look something like this: | |||||||
|     "password": "admin", |     "password": "admin", | ||||||
|     "loglevel": "INFO", |     "loglevel": "INFO", | ||||||
|     "logpath": "./qc.log", |     "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. | age - is a number in seconds for how long we keep torrents from IPTORRENTS. | ||||||
| @@ -7,6 +7,7 @@ | |||||||
|     "logpath": "./qc.log", |     "logpath": "./qc.log", | ||||||
|     "age": 2419200, |     "age": 2419200, | ||||||
|     "use_pushover": true, |     "use_pushover": true, | ||||||
|  |     "use_log": true, | ||||||
|     "po_key": "", |     "po_key": "", | ||||||
|     "po_token": "" |     "po_token": "" | ||||||
| } | } | ||||||
							
								
								
									
										13
									
								
								qbit-maid.py
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								qbit-maid.py
									
									
									
									
									
								
							| @@ -24,12 +24,13 @@ class Qbt: | |||||||
|         # Create the logging object |         # Create the logging object | ||||||
|         self.tl = logging |         self.tl = logging | ||||||
|         self.po = pushover |         self.po = pushover | ||||||
|         self.use_pushover= self.config["use_pushover"] |         self.use_pushover = self.config["use_pushover"] | ||||||
|         self.po_key=self.config["po_key"] |         self.use_log = self.config["use_log"] | ||||||
|         self.po_token=self.config["po_token"] |         self.po_key = self.config["po_key"] | ||||||
|  |         self.po_token = self.config["po_token"] | ||||||
|         # Variables torlog uses from config.json |         # Variables torlog uses from config.json | ||||||
|         self.logpath=self.config["logpath"] |         self.logpath = self.config["logpath"] | ||||||
|         self.loglevel=self.config["loglevel"] |         self.loglevel = self.config["loglevel"] | ||||||
|         torlog(self) |         torlog(self) | ||||||
|         tornotify(self) |         tornotify(self) | ||||||
|         self.t = time |         self.t = time | ||||||
| @@ -55,6 +56,8 @@ class Qbt: | |||||||
|         torrentcount(self) |         torrentcount(self) | ||||||
|         torprocessor(self) |         torprocessor(self) | ||||||
|         printprocessor(self) |         printprocessor(self) | ||||||
|  |         if self.use_pushover: | ||||||
|  |             tornotifysummary(self) | ||||||
|         tordelete(self) |         tordelete(self) | ||||||
|  |  | ||||||
| if  __name__== "__main__": | if  __name__== "__main__": | ||||||
|   | |||||||
							
								
								
									
										19
									
								
								qlogging.py
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								qlogging.py
									
									
									
									
									
								
							| @@ -1,15 +1,24 @@ | |||||||
| #The third file shall contain logging and email communication. | #The third file shall contain logging and email communication. | ||||||
|  |  | ||||||
| def torlog(self): | def torlog(self): | ||||||
|     if self.loglevel == 'DEBUG': |     if self.use_log: | ||||||
|         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 == '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.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.INFO) |         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): | def tornotify(self): | ||||||
|     if self.use_pushover: |     if self.use_pushover: | ||||||
|         self.poc = self.po.Client(self.po_key, api_token=self.po_token) |         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): | def getunixtimestamp(self): | ||||||
|     self.uts = self.t.time() |     self.uts = self.t.time() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user