#15 added tag whitelisting

This commit is contained in:
jblu 2022-09-02 20:22:04 -05:00
parent 0135f7c13b
commit 0977b12fe1
4 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1,5 @@
{
"first":"first",
"second":"second",
"third":"third"
}

View File

@ -20,6 +20,8 @@ class Qbt:
self.config = load(c) self.config = load(c)
w = open('./category-whitelist.json') w = open('./category-whitelist.json')
self.cat_whitelist = load(w) self.cat_whitelist = load(w)
tg = open('./ignored_tags.json')
self.ignored_tags = load(tg)
# Create the api object # Create the api object
self.qbt_client = qbittorrentapi.Client( self.qbt_client = qbittorrentapi.Client(
host=self.config["host"], host=self.config["host"],

View File

@ -9,6 +9,9 @@ def buildtorlist(self):
torrent = self.torrentlist.pop() torrent = self.torrentlist.pop()
if self.use_log: if self.use_log:
self.tl.debug(f'["{torrent["name"][0:20]}..."] {torrent["infohash_v1"]}') self.tl.debug(f'["{torrent["name"][0:20]}..."] {torrent["infohash_v1"]}')
if isignoredtag(self.ignored_tags.values(),torrent['tags']):
self.ignored_counter += 1
continue
# if torrent['added_on'] + self.minimum_age >= self.t.time(): # if torrent['added_on'] + self.minimum_age >= self.t.time():
if ispreme(torrent['added_on'], self.minimum_age, self.t.time()): if ispreme(torrent['added_on'], self.minimum_age, self.t.time()):
self.preme_tor_counter += 1 self.preme_tor_counter += 1
@ -64,3 +67,7 @@ def istagblank(tag):
if tag == '': if tag == '':
return True return True
def isignoredtag(igtags, tortags):
for igt in igtags:
if igt in tortags:
return True

View File

@ -1,5 +1,5 @@
import unittest import unittest
from qlist import ispreme,iscatignored,istrackerblank,isprotectedtracker,isnotprotectedtracker,istagblank from qlist import ispreme,iscatignored,istrackerblank,isprotectedtracker,isnotprotectedtracker,istagblank,isignoredtag
from qprocess import isdownloading,isprotectedunderratio,isoldtor,isprotectedoverratio,isnonprotectedtor from qprocess import isdownloading,isprotectedunderratio,isoldtor,isprotectedoverratio,isnonprotectedtor
class TestQbitmaid(unittest.TestCase): class TestQbitmaid(unittest.TestCase):
@ -87,6 +87,12 @@ class TestQbitmaid(unittest.TestCase):
def test_isnonprotectedtor(self): def test_isnonprotectedtor(self):
pass pass
def test_isignoredtag_sanity(self):
self.assertTrue(isignoredtag(['a','b','c'], 'first,second,third,a'))
def test_isignoredtag_sanity(self):
self.assertTrue(isignoredtag(['a','b','c'], 'first,second,third,a'))
# def test__sanity(self): # def test__sanity(self):
# pass # pass