2024-05-24 08:22:29 +02:00
|
|
|
"""Constants for the Transmission Bittorrent Client component."""
|
2024-03-08 16:35:23 +01:00
|
|
|
|
2023-10-12 22:20:39 +02:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from collections.abc import Callable
|
|
|
|
|
|
|
|
from transmission_rpc import Torrent
|
|
|
|
|
2019-09-26 12:14:57 +03:00
|
|
|
DOMAIN = "transmission"
|
|
|
|
|
2020-06-28 13:56:54 +02:00
|
|
|
ORDER_NEWEST_FIRST = "newest_first"
|
|
|
|
ORDER_OLDEST_FIRST = "oldest_first"
|
|
|
|
ORDER_BEST_RATIO_FIRST = "best_ratio_first"
|
|
|
|
ORDER_WORST_RATIO_FIRST = "worst_ratio_first"
|
|
|
|
|
2023-10-12 22:20:39 +02:00
|
|
|
SUPPORTED_ORDER_MODES: dict[str, Callable[[list[Torrent]], list[Torrent]]] = {
|
2020-06-28 13:56:54 +02:00
|
|
|
ORDER_NEWEST_FIRST: lambda torrents: sorted(
|
2023-11-07 10:04:59 +02:00
|
|
|
torrents, key=lambda t: t.added_date, reverse=True
|
2020-06-28 13:56:54 +02:00
|
|
|
),
|
2023-11-07 10:04:59 +02:00
|
|
|
ORDER_OLDEST_FIRST: lambda torrents: sorted(torrents, key=lambda t: t.added_date),
|
2020-06-28 13:56:54 +02:00
|
|
|
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
|
|
|
|
),
|
|
|
|
}
|
2022-10-30 13:00:47 +02:00
|
|
|
CONF_ENTRY_ID = "entry_id"
|
2020-06-28 13:56:54 +02:00
|
|
|
CONF_LIMIT = "limit"
|
|
|
|
CONF_ORDER = "order"
|
|
|
|
|
2020-04-20 15:07:26 +02:00
|
|
|
DEFAULT_DELETE_DATA = False
|
2020-06-28 13:56:54 +02:00
|
|
|
DEFAULT_LIMIT = 10
|
|
|
|
DEFAULT_ORDER = ORDER_OLDEST_FIRST
|
2019-09-26 12:14:57 +03:00
|
|
|
DEFAULT_NAME = "Transmission"
|
2024-03-21 11:05:36 +01:00
|
|
|
DEFAULT_SSL = False
|
2019-09-26 12:14:57 +03:00
|
|
|
DEFAULT_PORT = 9091
|
2024-03-21 11:05:36 +01:00
|
|
|
DEFAULT_PATH = "/transmission/rpc"
|
2019-09-26 12:14:57 +03:00
|
|
|
DEFAULT_SCAN_INTERVAL = 120
|
|
|
|
|
2019-10-28 02:20:59 -07:00
|
|
|
STATE_ATTR_TORRENT_INFO = "torrent_info"
|
2020-04-20 15:07:26 +02:00
|
|
|
|
|
|
|
ATTR_DELETE_DATA = "delete_data"
|
2019-09-26 12:14:57 +03:00
|
|
|
ATTR_TORRENT = "torrent"
|
2020-04-20 15:07:26 +02:00
|
|
|
|
2019-09-26 12:14:57 +03:00
|
|
|
SERVICE_ADD_TORRENT = "add_torrent"
|
2020-04-20 15:07:26 +02:00
|
|
|
SERVICE_REMOVE_TORRENT = "remove_torrent"
|
2021-01-13 17:44:57 +01:00
|
|
|
SERVICE_START_TORRENT = "start_torrent"
|
|
|
|
SERVICE_STOP_TORRENT = "stop_torrent"
|
2019-09-26 12:14:57 +03:00
|
|
|
|
2020-04-20 15:07:26 +02:00
|
|
|
EVENT_STARTED_TORRENT = "transmission_started_torrent"
|
|
|
|
EVENT_REMOVED_TORRENT = "transmission_removed_torrent"
|
|
|
|
EVENT_DOWNLOADED_TORRENT = "transmission_downloaded_torrent"
|
2023-03-05 14:12:30 -07:00
|
|
|
|
|
|
|
STATE_UP_DOWN = "up_down"
|
|
|
|
STATE_SEEDING = "seeding"
|
|
|
|
STATE_DOWNLOADING = "downloading"
|