Limit and sort transmission torrents_info attribute (#35411)

This commit is contained in:
Gleb Sinyavskiy
2020-06-28 13:56:54 +02:00
committed by GitHub
parent 15165a3c93
commit 4a374f0378
8 changed files with 114 additions and 27 deletions

View File

@ -1,10 +1,30 @@
"""Constants for the Transmission Bittorent Client component."""
DOMAIN = "transmission"
SWITCH_TYPES = {"on_off": "Switch", "turtle_mode": "Turtle Mode"}
ORDER_NEWEST_FIRST = "newest_first"
ORDER_OLDEST_FIRST = "oldest_first"
ORDER_BEST_RATIO_FIRST = "best_ratio_first"
ORDER_WORST_RATIO_FIRST = "worst_ratio_first"
SUPPORTED_ORDER_MODES = {
ORDER_NEWEST_FIRST: lambda torrents: sorted(
torrents, key=lambda t: t.addedDate, reverse=True
),
ORDER_OLDEST_FIRST: lambda torrents: sorted(torrents, key=lambda t: t.addedDate),
ORDER_WORST_RATIO_FIRST: lambda torrents: sorted(torrents, key=lambda t: t.ratio),
ORDER_BEST_RATIO_FIRST: lambda torrents: sorted(
torrents, key=lambda t: t.ratio, reverse=True
),
}
CONF_LIMIT = "limit"
CONF_ORDER = "order"
DEFAULT_DELETE_DATA = False
DEFAULT_LIMIT = 10
DEFAULT_ORDER = ORDER_OLDEST_FIRST
DEFAULT_NAME = "Transmission"
DEFAULT_PORT = 9091
DEFAULT_SCAN_INTERVAL = 120