Skip to content

Commit

Permalink
feat(torrent): add .trackers property with type
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Oct 10, 2022
1 parent 6a3f32f commit e7a99b1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions transmission_rpc/torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import datetime
from typing import TYPE_CHECKING, Any, Dict, List, Union, Optional

from typing_extensions import TypedDict

from transmission_rpc.utils import format_timedelta
from transmission_rpc.constants import PRIORITY, IDLE_LIMIT, RATIO_LIMIT
from transmission_rpc.lib_types import File, Field, _Timeout
Expand Down Expand Up @@ -62,6 +64,13 @@ def __new__(cls, raw: str) -> "Status":
return obj


class Tracker(TypedDict):
id: int
announce: str
scrape: str
tier: int


class Torrent:
"""
Torrent is a class holding the data received from Transmission regarding a bittorrent transfer.
Expand Down Expand Up @@ -617,6 +626,10 @@ def queue_position(self, position: str) -> None:
else:
pass

@property
def trackers(self) -> List[Tracker]:
return self.__getattr__("trackers")

def update(self, timeout: _Timeout = None) -> None:
"""Update the torrent information."""
self._push()
Expand Down

0 comments on commit e7a99b1

Please sign in to comment.