Warden as main handler for current simple selection logic

This commit is contained in:
2022-01-26 21:35:36 +01:00
parent a73aa0a091
commit 74ee1948d2

42
src/warden.py Normal file
View File

@@ -0,0 +1,42 @@
from pprint import pprint
def acceptableSeedCount(torrent):
return int(torrent.seed) > 1
def unacceptable4K(torrent):
name = torrent.name.lower()
return '2160p' in name or '4k' in name
def unacceptableSmall(torrent):
cutoff = 6500000000 # 6.5 GB
return torrent.bytes < cutoff
def unacceptableLarge(torrent):
cutoff = 25000000000 # 25 GB
return torrent.bytes > cutoff
def findBest(torrents):
if len(torrents) == 0:
return None
startingLength = len(torrents)
candidates = torrents.copy()
for torrent in torrents:
if not acceptableSeedCount(torrent):
candidates.remove(torrent)
elif unacceptable4K(torrent):
candidates.remove(torrent)
elif unacceptableSmall(torrent):
candidates.remove(torrent)
elif unacceptableLarge(torrent):
candidates.remove(torrent)
candidates = sorted(candidates, reverse=True)
print('Found {} candidates from {} torrents'.format(len(candidates), startingLength))
pprint(candidates)
return candidates[0]