mirror of
https://github.com/KevinMidboe/seasonedWarden.git
synced 2025-10-29 09:50:14 +00:00
Warden as main handler for current simple selection logic
This commit is contained in:
42
src/warden.py
Normal file
42
src/warden.py
Normal 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]
|
||||||
Reference in New Issue
Block a user