Refactor conditions #14
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,5 +1,6 @@
 | 
				
			|||||||
*.log
 | 
					*.log
 | 
				
			||||||
*.json
 | 
					*.json
 | 
				
			||||||
 | 
					*.csv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Byte-compiled / optimized / DLL files
 | 
					# Byte-compiled / optimized / DLL files
 | 
				
			||||||
__pycache__/
 | 
					__pycache__/
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,7 @@ import time
 | 
				
			|||||||
import datetime
 | 
					import datetime
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
from collections import Counter
 | 
					from collections import Counter
 | 
				
			||||||
 | 
					import csv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Qbt:
 | 
					class Qbt:
 | 
				
			||||||
    def __init__(self):
 | 
					    def __init__(self):
 | 
				
			||||||
@@ -30,6 +31,7 @@ class Qbt:
 | 
				
			|||||||
        self.tl = logging
 | 
					        self.tl = logging
 | 
				
			||||||
        self.po = pushover
 | 
					        self.po = pushover
 | 
				
			||||||
        self.ct = Counter
 | 
					        self.ct = Counter
 | 
				
			||||||
 | 
					        self.cv = csv
 | 
				
			||||||
        # Variables torlog uses from config.json
 | 
					        # Variables torlog uses from config.json
 | 
				
			||||||
        self.use_pushover = self.config["use_pushover"]
 | 
					        self.use_pushover = self.config["use_pushover"]
 | 
				
			||||||
        self.use_log = self.config["use_log"]
 | 
					        self.use_log = self.config["use_log"]
 | 
				
			||||||
@@ -63,7 +65,6 @@ class Qbt:
 | 
				
			|||||||
        except qbittorrentapi.APIError as e:
 | 
					        except qbittorrentapi.APIError as e:
 | 
				
			||||||
            self.tl.exception(e)
 | 
					            self.tl.exception(e)
 | 
				
			||||||
            self.po.send_message(e, title="qbit-maid API ERROR")
 | 
					            self.po.send_message(e, title="qbit-maid API ERROR")
 | 
				
			||||||
        # self.torrentlist = {}
 | 
					 | 
				
			||||||
        # Pulling all torrent data
 | 
					        # Pulling all torrent data
 | 
				
			||||||
        self.torrentlist = self.qbt_client.torrents_info()
 | 
					        self.torrentlist = self.qbt_client.torrents_info()
 | 
				
			||||||
        #Main process block
 | 
					        #Main process block
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								qprocess.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								qprocess.py
									
									
									
									
									
								
							@@ -32,7 +32,7 @@ def torprocessor(self):
 | 
				
			|||||||
            if self.use_log:   
 | 
					            if self.use_log:   
 | 
				
			||||||
                self.tl.info(f'Submitted ["{canidate["name"][0:20]}..."] for deletion.')
 | 
					                self.tl.info(f'Submitted ["{canidate["name"][0:20]}..."] for deletion.')
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            dragnet(canidate['state'],canidate['ratio'],canidate["tags"],canidate['added_on'],self.age,self.t.time(),canidate['infohash_v1'],canidate["name"][0:20])
 | 
					            dragnet(self,canidate['state'],canidate['ratio'],canidate["tags"],canidate['added_on'],self.age,self.t.time(),canidate['infohash_v1'],canidate["name"][0:20])
 | 
				
			||||||
            self.tl.info(f'["{canidate["name"][0:20]}..."] is orphaned.')
 | 
					            self.tl.info(f'["{canidate["name"][0:20]}..."] is orphaned.')
 | 
				
			||||||
            self.up_tor_counter += 1
 | 
					            self.up_tor_counter += 1
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
@@ -69,5 +69,11 @@ def isnonprotectedtor(setnonprotectedtag, tortags):
 | 
				
			|||||||
    if setnonprotectedtag in tortags:
 | 
					    if setnonprotectedtag in tortags:
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def dragnet(state,ratio,tags,added,age,time,thash,tname):
 | 
					def dragnet(self,state,ratio,tags,added,age,time,thash,tname):
 | 
				
			||||||
    pass
 | 
					    header = ['state','ratio','tags','added','age','time','thash','tname']
 | 
				
			||||||
 | 
					    row = [state,ratio,tags,added,age,time,thash,tname]
 | 
				
			||||||
 | 
					    with open('./orphanedtorrents.csv', 'w', encoding='UTF8', newline='') as f:
 | 
				
			||||||
 | 
					        writer = self.cv.writer(f)
 | 
				
			||||||
 | 
					        if f.tell() == 0:
 | 
				
			||||||
 | 
					            writer.writerow(header)
 | 
				
			||||||
 | 
					        writer.writerow(row)
 | 
				
			||||||
@@ -85,8 +85,6 @@ class TestQbitmaid(unittest.TestCase):
 | 
				
			|||||||
    def test_isnonprotectedtor(self):
 | 
					    def test_isnonprotectedtor(self):
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pass
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # def test__sanity(self):
 | 
					    # def test__sanity(self):
 | 
				
			||||||
    #     pass
 | 
					    #     pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user