Skip to content

Commit

Permalink
Added new fields AllowStalled and StalledDelay
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Jun 24, 2024
1 parent 5b9d61b commit b73ab06
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
24 changes: 24 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ MaximumDeletablePercentage = 0.99
# Ignore slow torrents.
DoNotRemoveSlow = true

# Allow stalled torrents
AllowStalled = false

# Maximum allowed time for allowed stalled torrents
StalledDelay = 0


[Sonarr-TV.Torrent.SeedingMode]
# Set the maximum allowed download rate for torrents
Expand Down Expand Up @@ -411,6 +417,12 @@ MaximumDeletablePercentage = 0.99
# Ignore slow torrents.
DoNotRemoveSlow = true

# Allow stalled torrents
AllowStalled = false

# Maximum allowed time for allowed stalled torrents
StalledDelay = 0


[Sonarr-Anime.Torrent.SeedingMode]
# Set the maximum allowed download rate for torrents
Expand Down Expand Up @@ -604,6 +616,12 @@ MaximumDeletablePercentage = 0.99
# Ignore slow torrents.
DoNotRemoveSlow = true

# Allow stalled torrents
AllowStalled = false

# Maximum allowed time for allowed stalled torrents
StalledDelay = 0


[Radarr-1080.Torrent.SeedingMode]
# Set the maximum allowed download rate for torrents
Expand Down Expand Up @@ -810,6 +828,12 @@ MaximumDeletablePercentage = 0.99
# Ignore slow torrents.
DoNotRemoveSlow = true

# Allow stalled torrents
AllowStalled = false

# Maximum allowed time for allowed stalled torrents
StalledDelay = 0


[Radarr-4K.Torrent.SeedingMode]
# Set the maximum allowed download rate for torrents
Expand Down
35 changes: 24 additions & 11 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ def __init__(
)

self.do_not_remove_slow = CONFIG.get(f"{name}.Torrent.DoNotRemoveSlow", fallback=False)
self.allow_stalled = CONFIG.get(f"{name}.Torrent.AllowStalled", fallback=False)
self.stalled_delay = CONFIG.get(f"{name}.Torrent.StalledDelay", fallback=0)
self.search_current_year = None
if self.search_in_reverse:
self._delta = 1
Expand Down Expand Up @@ -491,7 +493,8 @@ def __init__(
[
"qBitrr-allowed_seeding",
"qBitrr-ignored",
"qbitrr-imported",
"qBitrr-imported",
"qBitrr-allow_stalled"
]
)
self.search_setup_completed = False
Expand Down Expand Up @@ -3777,16 +3780,11 @@ def _should_leave_alone(
seeding_time_limit = max(seeding_time_limit_dat, seeding_time_limit_tor)
ratio_limit = max(ratio_limit_dat, ratio_limit_tor)

if self.seeding_mode_global_remove_torrent != -1 and self.remove_torrent(
torrent, seeding_time_limit, ratio_limit
):
remove_torrent = True
return_value = False
if self.seeding_mode_global_remove_torrent != -1:
remove_torrent = self.torrent_limit_check(torrent, seeding_time_limit, ratio_limit)
else:
if torrent.ratio >= ratio_limit and ratio_limit != -5:
return_value = False # Seeding ratio met - Can be cleaned up.
if torrent.seeding_time >= seeding_time_limit and seeding_time_limit != -5:
return_value = False # Seeding time met - Can be cleaned up.
remove_torrent = False
return_value = not self.torrent_limit_check(torrent, seeding_time_limit, ratio_limit)
if data_settings.get("super_seeding", False) or data_torrent.get("super_seeding", False):
return_value = True
if "qBitrr-free_space_paused" in torrent.tags:
Expand Down Expand Up @@ -3978,6 +3976,11 @@ def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
"qBitrr-free_space_paused",
]
)
if (
"qBitrr-allow_stalled" in torrent.tags
and torrent.added_on >= int(time.time()+(self.stalled_delay*60))
):
torrent.remove_tags(["qBitrr-allow_stalled"])
if (
self.custom_format_unmet_search
and self.custom_format_unmet_check(torrent)
Expand All @@ -4003,6 +4006,7 @@ def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
)
and "qBitrr-ignored" not in torrent.tags
and "qBitrr-free_space_paused" not in torrent.tags
and "qBitrr-allow_stalled" not in torrent.tags
):
self._process_single_torrent_stalled_torrent(torrent, "Stalled State")
elif (
Expand All @@ -4023,6 +4027,7 @@ def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
and self.is_complete_state(torrent) is False
and "qBitrr-ignored" not in torrent.tags
and "qBitrr-free_space_paused" not in torrent.tags
and "qBitrr-allow_stalled" not in torrent.tags
) and torrent.hash in self.cleaned_torrents:
self._process_single_torrent_percentage_threshold(torrent, maximum_eta)
# Resume monitored downloads which have been paused.
Expand Down Expand Up @@ -4078,6 +4083,7 @@ def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
and not self.do_not_remove_slow
and "qBitrr-ignored" not in torrent.tags
and "qBitrr-free_space_paused" not in torrent.tags
and "qBitrr-allow_stalled" not in torrent.tags
):
self._process_single_torrent_delete_slow(torrent)
# Process uncompleted torrents
Expand All @@ -4094,6 +4100,7 @@ def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
and self.is_downloading_state(torrent)
and "qBitrr-ignored" not in torrent.tags
and "qBitrr-free_space_paused" not in torrent.tags
and "qBitrr-allow_stalled" not in torrent.tags
):
self._process_single_torrent_stalled_torrent(torrent, "Unavailable")
else:
Expand Down Expand Up @@ -4224,7 +4231,7 @@ def custom_format_unmet_check(self, torrent: qbittorrentapi.TorrentDictionary) -
except KeyError:
pass

def remove_torrent(
def torrent_limit_check(
self, torrent: qbittorrentapi.TorrentDictionary, seeding_time_limit, ratio_limit
) -> bool:
if (
Expand All @@ -4244,6 +4251,12 @@ def remove_torrent(
return True
elif self.seeding_mode_global_remove_torrent == 1 and torrent.ratio >= ratio_limit:
return True
elif (
self.seeding_mode_global_remove_torrent == -1
and (torrent.ratio >= ratio_limit
or torrent.seeding_time >= seeding_time_limit)
):
return True
else:
return False

Expand Down
2 changes: 2 additions & 0 deletions qBitrr/gen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ def _gen_default_torrent_table(category: str, cat_default: Table):
0.99,
)
_gen_default_line(torrent_table, "Ignore slow torrents.", "DoNotRemoveSlow", True)
_gen_default_line(torrent_table, "Allow stalled torrents", "AllowStalled", False)
_gen_default_line(torrent_table, "Maximum allowed time for allowed stalled torrents", "StalledDelay", 0)
_gen_default_seeding_table(category, torrent_table)
_gen_default_tracker_tables(category, torrent_table)

Expand Down

0 comments on commit b73ab06

Please sign in to comment.