added dragnet function

This commit is contained in:
jblu 2022-08-31 10:56:37 -05:00
parent 4cd1c519e2
commit 81ad9e3d13
4 changed files with 12 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
*.log
*.json
*.csv
# Byte-compiled / optimized / DLL files
__pycache__/

View File

@ -9,6 +9,7 @@ import time
import datetime
import logging
from collections import Counter
import csv
class Qbt:
def __init__(self):
@ -30,6 +31,7 @@ class Qbt:
self.tl = logging
self.po = pushover
self.ct = Counter
self.cv = csv
# Variables torlog uses from config.json
self.use_pushover = self.config["use_pushover"]
self.use_log = self.config["use_log"]
@ -63,7 +65,6 @@ class Qbt:
except qbittorrentapi.APIError as e:
self.tl.exception(e)
self.po.send_message(e, title="qbit-maid API ERROR")
# self.torrentlist = {}
# Pulling all torrent data
self.torrentlist = self.qbt_client.torrents_info()
#Main process block

View File

@ -32,7 +32,7 @@ def torprocessor(self):
if self.use_log:
self.tl.info(f'Submitted ["{canidate["name"][0:20]}..."] for deletion.')
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.up_tor_counter += 1
continue
@ -69,5 +69,11 @@ def isnonprotectedtor(setnonprotectedtag, tortags):
if setnonprotectedtag in tortags:
return True
def dragnet(state,ratio,tags,added,age,time,thash,tname):
pass
def dragnet(self,state,ratio,tags,added,age,time,thash,tname):
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)

View File

@ -85,8 +85,6 @@ class TestQbitmaid(unittest.TestCase):
def test_isnonprotectedtor(self):
pass
pass
# def test__sanity(self):
# pass