Category whitelist #10

Merged
jonbranan merged 4 commits from category-whitelist into main 2022-07-23 01:10:24 -05:00
3 changed files with 4 additions and 8 deletions
Showing only changes of commit 972e9bc517 - Show all commits

View File

@ -14,7 +14,7 @@ class Qbt:
# Open the config. Needs a json file with the data in config.json.example
c = open('./config.json')
self.config = load(c)
w = open('./config.json')
w = open('./category-whitelist.json')
self.cat_whitelist = load(w)
# Create the api object
self.qbt_client = qbittorrentapi.Client(

View File

@ -4,13 +4,11 @@ def buildtorlist(self):
V2 will certainly be more performant. The reason two lists were used was so that torrents
that are in public trackers woudln't be around as long as torrents from a private tracker.
"""
self.protected_count = 0
self.nonprotected_count = 0
while self.torrentlist:
torrent = self.torrentlist.pop()
if self.use_log:
self.tl.debug(f'["{torrent["name"][0:20]}..."] {torrent["infohash_v1"]}')
if torrent['tags'] in self.cat_whitelist.values():
if torrent['category'] in self.cat_whitelist.values():
self.tl.info(f'Ignored torrent:["{torrent["name"][0:20]}..."]')
continue
if torrent['tracker'] == '':
@ -20,13 +18,11 @@ def buildtorlist(self):
if torrent['tracker'].split('/')[2] in self.tracker_whitelist.values():
if self.use_log:
self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
self.protected_count += 1
self.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash'])
self.tracker_protected_list.append(torrent)
elif torrent['tracker'].split('/')[2] not in self.tracker_whitelist.values():
if torrent['tracker'].split('/')[2] not in self.tracker_whitelist.values():
if self.use_log:
self.tl.debug(f'Non-protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
self.nonprotected_count += 1
self.qbt_client.torrents_add_tags(self.tracker_non_protected_tag,torrent['hash'])
self.tracker_nonprotected_list.append(torrent)

View File

@ -3,7 +3,7 @@ def torprocessor(self):
If torrent meets criteria for deletion, its infohash_v1 will be appended to self.torrent_hash_delete_list
"""
for canidate in self.tracker_nonprotected_list:
if canidate['tags'] in self.cat_whitelist.values():
if self.config["protected_tag"] in canidate['tags']:
if self.use_log:
self.tl.warning(f'["{canidate["name"][0:20]}..."] was in non-protected list.')
continue