Skip to content

Commit

Permalink
Move new stalled logic to function
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Jul 1, 2024
1 parent 0ed057a commit 2423946
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -3975,27 +3975,12 @@ def _process_single_torrent_trackers(self, torrent: qbittorrentapi.TorrentDictio
if add_tags:
torrent.add_tags(add_tags)

def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
if torrent.category != RECHECK_CATEGORY:
self.manager.qbit_manager.cache[torrent.hash] = torrent.category
self._process_single_torrent_trackers(torrent)
self.manager.qbit_manager.name_cache[torrent.hash] = torrent.name
time_now = time.time()
leave_alone, _tracker_max_eta, remove_torrent = self._should_leave_alone(torrent)
self.logger.trace(
"Torrent [%s]: Leave Alone (allow seeding): %s, Max ETA: %s, State[%s]",
torrent.name,
leave_alone,
_tracker_max_eta,
torrent.state_enum,
)
maximum_eta = _tracker_max_eta

def stalled_check(self, torrent: qbittorrentapi.TorrentDictionary, time_now: float) -> bool:
stalled_ignore = True
self.logger.trace(
"Stalled check: %s [Current:%s][Added:%s][Limit:%s]",
torrent.name,
datetime.fromtimestamp(time.time()),
datetime.fromtimestamp(time_now),
datetime.fromtimestamp(torrent.added_on),
datetime.fromtimestamp(
torrent.added_on + timedelta(minutes=self.stalled_delay).seconds
Expand Down Expand Up @@ -4025,7 +4010,7 @@ def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
) and self.allowed_stalled:
if (
self.stalled_delay > 0
and time.time() >= torrent.added_on + timedelta(minutes=self.stalled_delay).seconds
and time_now >= torrent.added_on + timedelta(minutes=self.stalled_delay).seconds
):
stalled_ignore = False
self.logger.trace(
Expand Down Expand Up @@ -4056,6 +4041,25 @@ def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
"Not stalled: %s",
torrent.name,
)
return stalled_ignore

def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
if torrent.category != RECHECK_CATEGORY:
self.manager.qbit_manager.cache[torrent.hash] = torrent.category
self._process_single_torrent_trackers(torrent)
self.manager.qbit_manager.name_cache[torrent.hash] = torrent.name
time_now = time.time()
leave_alone, _tracker_max_eta, remove_torrent = self._should_leave_alone(torrent)
self.logger.trace(
"Torrent [%s]: Leave Alone (allow seeding): %s, Max ETA: %s, State[%s]",
torrent.name,
leave_alone,
_tracker_max_eta,
torrent.state_enum,
)
maximum_eta = _tracker_max_eta

stalled_ignore = self.stalled_check(torrent, time_now)

if "qBitrr-ignored" in torrent.tags:
torrent.remove_tags(
Expand Down

0 comments on commit 2423946

Please sign in to comment.