Merge pull request #17 from jonbranan/dragnet_support

moved dragnet to config file
This commit is contained in:
jonbranan 2022-09-02 19:23:50 -05:00 committed by GitHub
commit d4e4aff64d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 274 additions and 263 deletions

View File

@ -46,6 +46,8 @@ Config.json
"po_key": "",
"po_token": "",
"delete_torrents": false
"enable_dragnet": false,
"dragnet_outfile": "./orphaned.csv"
}
```
@ -75,3 +77,4 @@ You will need a category-whitelist.json in the root directory. This will ignore
| po_key | pushover key |
| po_token | pushover api token |
| delete_torrents | true or false to enable or disable deletion. Useful for dry-runs |
| enable_dragnet | true or false to enable dragnet functionality. Useful for debugging |

View File

@ -13,5 +13,7 @@
"use_log": true,
"po_key": "",
"po_token": "",
"delete_torrents": false
"delete_torrents": false,
"enable_dragnet": true,
"dragnet_outfile": "./orphaned.csv"
}

View File

@ -43,6 +43,8 @@ class Qbt:
self.tracker_non_protected_tag = self.config["non_protected_tag"]
self.minimum_age = self.config["minimum_age"]
self.age = self.config["age"]
self.enable_dragnet = self.config["enable_dragnet"]
self.dragnet_outfile = self.config["dragnet_outfile"]
# Calling log and notify functions
torlog(self)
tornotify(self)

View File

@ -1,3 +1,6 @@
from cgitb import enable
def torprocessor(self):
"""Main logic to sort through both self.tracker_nonprotected_list and self.tracker_protected_list
If torrent meets criteria for deletion, its infohash_v1 will be appended to self.torrent_hash_delete_list
@ -32,6 +35,7 @@ def torprocessor(self):
if self.use_log:
self.tl.info(f'Submitted ["{canidate["name"][0:20]}..."] for deletion.')
else:
if self.enable_dragnet:
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
@ -72,7 +76,7 @@ def isnonprotectedtor(setnonprotectedtag, tortags):
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:
with open(self.dragnet_outfile, 'w', encoding='UTF8', newline='') as f:
writer = self.cv.writer(f)
if f.tell() == 0:
writer.writerow(header)