Revert transmission to check torrent lists by name rather than object (#46190)
parent
884df40951
commit
67ab86443e
|
@ -397,42 +397,49 @@ class TransmissionData:
|
||||||
|
|
||||||
def check_completed_torrent(self):
|
def check_completed_torrent(self):
|
||||||
"""Get completed torrent functionality."""
|
"""Get completed torrent functionality."""
|
||||||
|
old_completed_torrent_names = {
|
||||||
|
torrent.name for torrent in self._completed_torrents
|
||||||
|
}
|
||||||
|
|
||||||
current_completed_torrents = [
|
current_completed_torrents = [
|
||||||
torrent for torrent in self._torrents if torrent.status == "seeding"
|
torrent for torrent in self._torrents if torrent.status == "seeding"
|
||||||
]
|
]
|
||||||
freshly_completed_torrents = set(current_completed_torrents).difference(
|
|
||||||
self._completed_torrents
|
|
||||||
)
|
|
||||||
self._completed_torrents = current_completed_torrents
|
|
||||||
|
|
||||||
for torrent in freshly_completed_torrents:
|
for torrent in current_completed_torrents:
|
||||||
self.hass.bus.fire(
|
if torrent.name not in old_completed_torrent_names:
|
||||||
EVENT_DOWNLOADED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
self.hass.bus.fire(
|
||||||
)
|
EVENT_DOWNLOADED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
||||||
|
)
|
||||||
|
|
||||||
|
self._completed_torrents = current_completed_torrents
|
||||||
|
|
||||||
def check_started_torrent(self):
|
def check_started_torrent(self):
|
||||||
"""Get started torrent functionality."""
|
"""Get started torrent functionality."""
|
||||||
|
old_started_torrent_names = {torrent.name for torrent in self._started_torrents}
|
||||||
|
|
||||||
current_started_torrents = [
|
current_started_torrents = [
|
||||||
torrent for torrent in self._torrents if torrent.status == "downloading"
|
torrent for torrent in self._torrents if torrent.status == "downloading"
|
||||||
]
|
]
|
||||||
freshly_started_torrents = set(current_started_torrents).difference(
|
|
||||||
self._started_torrents
|
|
||||||
)
|
|
||||||
self._started_torrents = current_started_torrents
|
|
||||||
|
|
||||||
for torrent in freshly_started_torrents:
|
for torrent in current_started_torrents:
|
||||||
self.hass.bus.fire(
|
if torrent.name not in old_started_torrent_names:
|
||||||
EVENT_STARTED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
self.hass.bus.fire(
|
||||||
)
|
EVENT_STARTED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
||||||
|
)
|
||||||
|
|
||||||
|
self._started_torrents = current_started_torrents
|
||||||
|
|
||||||
def check_removed_torrent(self):
|
def check_removed_torrent(self):
|
||||||
"""Get removed torrent functionality."""
|
"""Get removed torrent functionality."""
|
||||||
freshly_removed_torrents = set(self._all_torrents).difference(self._torrents)
|
current_torrent_names = {torrent.name for torrent in self._torrents}
|
||||||
self._all_torrents = self._torrents
|
|
||||||
for torrent in freshly_removed_torrents:
|
for torrent in self._all_torrents:
|
||||||
self.hass.bus.fire(
|
if torrent.name not in current_torrent_names:
|
||||||
EVENT_REMOVED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
self.hass.bus.fire(
|
||||||
)
|
EVENT_REMOVED_TORRENT, {"name": torrent.name, "id": torrent.id}
|
||||||
|
)
|
||||||
|
|
||||||
|
self._all_torrents = self._torrents.copy()
|
||||||
|
|
||||||
def start_torrents(self):
|
def start_torrents(self):
|
||||||
"""Start all torrents."""
|
"""Start all torrents."""
|
||||||
|
|
Loading…
Reference in New Issue