Skip to content

Commit

Permalink
Changed up config attributes and added initial changes for re-searchi…
Browse files Browse the repository at this point in the history
…ng functionality
  • Loading branch information
Feramance committed Jul 1, 2024
1 parent 0e7d3af commit 7d9f817
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
24 changes: 12 additions & 12 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ MaximumDeletablePercentage = 0.99
# Ignore slow torrents.
DoNotRemoveSlow = true

# Allow stalled torrents
AllowStalled = false
# Re-search stalled torrents
ReSearchStalled = false

# Maximum allowed time for allowed stalled torrents in minutes
# Maximum allowed time for allowed stalled torrents in minutes (-1 = Disabled, 0 = Infinite)
StalledDelay = -1


Expand Down Expand Up @@ -417,10 +417,10 @@ MaximumDeletablePercentage = 0.99
# Ignore slow torrents.
DoNotRemoveSlow = true

# Allow stalled torrents
AllowStalled = false
# Re-search stalled torrents
ReSearchStalled = false

# Maximum allowed time for allowed stalled torrents in minutes
# Maximum allowed time for allowed stalled torrents in minutes (-1 = Disabled, 0 = Infinite)
StalledDelay = -1


Expand Down Expand Up @@ -616,10 +616,10 @@ MaximumDeletablePercentage = 0.99
# Ignore slow torrents.
DoNotRemoveSlow = true

# Allow stalled torrents
AllowStalled = false
# Re-search stalled torrents
ReSearchStalled = false

# Maximum allowed time for allowed stalled torrents in minutes
# Maximum allowed time for allowed stalled torrents in minutes (-1 = Disabled, 0 = Infinite)
StalledDelay = -1


Expand Down Expand Up @@ -828,10 +828,10 @@ MaximumDeletablePercentage = 0.99
# Ignore slow torrents.
DoNotRemoveSlow = true

# Allow stalled torrents
AllowStalled = false
# Re-search stalled torrents
ReSearchStalled = false

# Maximum allowed time for allowed stalled torrents in minutes
# Maximum allowed time for allowed stalled torrents in minutes (-1 = Disabled, 0 = Infinite)
StalledDelay = -1


Expand Down
35 changes: 24 additions & 11 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ def __init__(
)

self.do_not_remove_slow = CONFIG.get(f"{name}.Torrent.DoNotRemoveSlow", fallback=False)
self.allowed_stalled = CONFIG.get(f"{name}.Torrent.AllowStalled", fallback=False)
self.re_search_stalled = CONFIG.get(f"{name}.Torrent.ReSearchStalled", fallback=False)
self.stalled_delay = CONFIG.get(f"{name}.Torrent.StalledDelay", fallback=0)
self.allowed_stalled = True if self.stalled_delay != -1 else False

self.search_current_year = None
if self.search_in_reverse:
self._delta = 1
Expand Down Expand Up @@ -846,16 +848,19 @@ def _process_imports(self) -> None:
self.sent_to_scan.add(path)
self.import_torrents.clear()

def _process_failed_individual(self, hash_: str, entry: int, skip_blacklist: set[str]) -> None:
if hash_ not in skip_blacklist:
self.logger.debug(
"Blocklisting: %s (%s)",
hash_,
self.manager.qbit_manager.name_cache.get(hash_, "Deleted"),
)
self.delete_from_queue(id_=entry, blacklist=True)
else:
self.delete_from_queue(id_=entry, blacklist=False)
def _process_failed_individual(
self, hash_: str, entry: int, skip_blacklist: set[str], stalled: bool = False
) -> None:
if not stalled:
if hash_ not in skip_blacklist:
self.logger.debug(
"Blocklisting: %s (%s)",
hash_,
self.manager.qbit_manager.name_cache.get(hash_, "Deleted"),
)
self.delete_from_queue(id_=entry, blacklist=True)
else:
self.delete_from_queue(id_=entry, blacklist=False)
if hash_ in self.recently_queue:
del self.recently_queue[hash_]
object_id = self.requeue_cache.get(entry)
Expand Down Expand Up @@ -4068,6 +4073,14 @@ def _process_single_torrent(self, torrent: qbittorrentapi.TorrentDictionary):
]
)

if "qBitrr-allowed_stalled" in torrent.tags and self.re_search_stalled:
payload = self.process_entries([torrent.hash])
if payload:
for entry, hash_ in payload:
self._process_failed_individual(
hash_=hash_, entry=entry, skip_blacklist=set(), stalled=True
)

if (
self.custom_format_unmet_search
and self.custom_format_unmet_check(torrent)
Expand Down
4 changes: 2 additions & 2 deletions qBitrr/gen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ 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, "Re-search stalled torrents", "ReSearchStalled", False)
_gen_default_line(
torrent_table,
"Maximum allowed time for allowed stalled torrents in minutes",
"Maximum allowed time for allowed stalled torrents in minutes (-1 = Disabled, 0 = Infinite)",
"StalledDelay",
-1,
)
Expand Down

0 comments on commit 7d9f817

Please sign in to comment.