Category whitelist #10
@ -14,7 +14,7 @@ class Qbt:
|
|||||||
# Open the config. Needs a json file with the data in config.json.example
|
# Open the config. Needs a json file with the data in config.json.example
|
||||||
c = open('./config.json')
|
c = open('./config.json')
|
||||||
self.config = load(c)
|
self.config = load(c)
|
||||||
w = open('./config.json')
|
w = open('./category-whitelist.json')
|
||||||
self.cat_whitelist = load(w)
|
self.cat_whitelist = load(w)
|
||||||
# Create the api object
|
# Create the api object
|
||||||
self.qbt_client = qbittorrentapi.Client(
|
self.qbt_client = qbittorrentapi.Client(
|
||||||
|
8
qlist.py
8
qlist.py
@ -4,13 +4,11 @@ def buildtorlist(self):
|
|||||||
V2 will certainly be more performant. The reason two lists were used was so that torrents
|
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.
|
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:
|
while self.torrentlist:
|
||||||
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 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]}..."]')
|
self.tl.info(f'Ignored torrent:["{torrent["name"][0:20]}..."]')
|
||||||
continue
|
continue
|
||||||
if torrent['tracker'] == '':
|
if torrent['tracker'] == '':
|
||||||
@ -20,13 +18,11 @@ def buildtorlist(self):
|
|||||||
if torrent['tracker'].split('/')[2] in self.tracker_whitelist.values():
|
if torrent['tracker'].split('/')[2] in self.tracker_whitelist.values():
|
||||||
if self.use_log:
|
if self.use_log:
|
||||||
self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
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.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash'])
|
||||||
self.tracker_protected_list.append(torrent)
|
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:
|
if self.use_log:
|
||||||
self.tl.debug(f'Non-protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
|
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.qbt_client.torrents_add_tags(self.tracker_non_protected_tag,torrent['hash'])
|
||||||
self.tracker_nonprotected_list.append(torrent)
|
self.tracker_nonprotected_list.append(torrent)
|
||||||
|
|
||||||
|
@ -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
|
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:
|
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:
|
if self.use_log:
|
||||||
self.tl.warning(f'["{canidate["name"][0:20]}..."] was in non-protected list.')
|
self.tl.warning(f'["{canidate["name"][0:20]}..."] was in non-protected list.')
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user