refactored the main processes

This commit is contained in:
2022-08-26 17:28:47 -05:00
parent a224b03a7d
commit 9fc77d3ea0
3 changed files with 126 additions and 28 deletions

View File

@@ -9,27 +9,58 @@ def buildtorlist(self):
torrent = self.torrentlist.pop()
if self.use_log:
self.tl.debug(f'["{torrent["name"][0:20]}..."] {torrent["infohash_v1"]}')
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()):
self.preme_tor_counter += 1
continue
if torrent['category'] in self.cat_whitelist.values():
# if torrent['category'] in self.cat_whitelist.values():
if iscatignored(torrent['category'], self.cat_whitelist.values()):
self.tl.info(f'Ignored torrent:["{torrent["name"][0:20]}..."]')
self.ignored_counter += 1
continue
if torrent['tracker'] == '':
# if torrent['tracker'] == '':
if istrackerblank(torrent['tracker']):
if self.use_log:
self.tl.warning(f'Torrent doesn\'t have a tracker ["{torrent["name"][0:20]}..."] [{torrent["tracker"]}]hash: {torrent["hash"]}')
self.ignored_counter += 1
continue
if torrent['tracker'].split('/')[2] in self.tracker_whitelist.values():
# if torrent['tracker'].split('/')[2] in self.tracker_whitelist.values():
if isprotectedtracker(torrent['tracker'], self.tracker_whitelist.values()):
if self.use_log:
self.tl.debug(f'Protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
if torrent['tags'] == '':
# if torrent['tags'] == '':
if istagblank(torrent['tags']):
self.qbt_client.torrents_add_tags(self.tracker_protected_tag,torrent['hash'])
self.tracker_list.append(torrent)
if torrent['tracker'].split('/')[2] not in self.tracker_whitelist.values():
if isnotprotectedtracker(torrent['tracker'], self.tracker_whitelist.values()):
if self.use_log:
self.tl.debug(f'Non-protected torrent: {torrent["tracker"]}hash: {torrent["hash"]}')
if torrent['tags'] == '':
# if torrent['tags'] == '':
if istagblank(torrent['tags']):
self.qbt_client.torrents_add_tags(self.tracker_non_protected_tag,torrent['hash'])
self.tracker_list.append(torrent)
self.tracker_list.append(torrent)
def ispreme(added, minage, time):
if added + minage >= time:
return True
def iscatignored(cat, catlist):
if cat in catlist:
return True
def istrackerblank(tracker):
if tracker == '':
return True
def isprotectedtracker(tracker, trackerlist):
if tracker.split('/')[2] in trackerlist:
return True
def isnotprotectedtracker(tracker, trackerlist):
if tracker.split('/')[2] not in trackerlist:
return True
def istagblank(tag):
if tag == '':
return True