sane-bt-search: fix tracker typos

This commit is contained in:
Colin 2023-09-15 11:14:29 +00:00
parent e03ae48ef6
commit c73246d7c6

View File

@ -73,9 +73,9 @@ def parse_time(t: str) -> datetime:
# preference, best to worst # preference, best to worst
TRACKER_RANKS = [ TRACKER_RANKS = [
'bakabt', 'bakabt',
'subsplease' 'subsplease',
'nyaa.si', 'nyaa.si',
'miobt' 'miobt',
'yts', 'yts',
'internet archive', 'internet archive',
'the pirate bay', 'the pirate bay',
@ -84,9 +84,10 @@ TRACKER_RANKS = [
'kickasstorrents.to', 'kickasstorrents.to',
] ]
def tracker_rank(tracker: str): def tracker_rank(tracker: str):
if tracker.lower() in TRACKER_RANKS: tracker_ = tracker.lower()
return TRACKER_RANKS.index(tracker.lower()) if tracker_ in TRACKER_RANKS:
logger.warn(f"unknown tracker: {tracker!r}") return TRACKER_RANKS.index(tracker_)
logger.warn(f"unknown tracker: {tracker_!r}")
return len(TRACKER_RANKS) return len(TRACKER_RANKS)
DROP_CATS = { "dvd", "hd", "misc", "other", "sd", "uhd" } DROP_CATS = { "dvd", "hd", "misc", "other", "sd", "uhd" }
@ -196,9 +197,9 @@ class Torrent:
logger.info(f"invalid magnet: {magnet}") logger.info(f"invalid magnet: {magnet}")
magnet = None magnet = None
if http_dl_uri: if tracker_uri:
# quirk: bakabt's post-login redirection fails if the slashes aren't just right # quirk: bakabt's post-login redirection fails if the slashes aren't just right
http_dl_uri = http_dl_uri.replace('https://bakabt.me//', 'https://bakabt.me/') tracker_uri = tracker_uri.replace('https://bakabt.me//', 'https://bakabt.me/')
if seeders is not None and pub_date is not None and title is not None and (magnet is not None or http_dl_uri is not None): if seeders is not None and pub_date is not None and title is not None and (magnet is not None or http_dl_uri is not None):
pub_date = parse_time(pub_date) pub_date = parse_time(pub_date)