feat(dl): allow --slow to accept custom delay range

--slow now supports an optional MIN-MAX range (e.g., --slow 20-40) for custom delay between title downloads. Bare --slow retains the original 60-120s default. Minimum delay enforced at 20 seconds.
This commit is contained in:
imSp4rky
2026-03-30 16:25:29 -06:00
parent c7fd2a904c
commit 47b3390bd0
5 changed files with 51 additions and 9 deletions
+18
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
import re
from pathlib import Path
import click
@@ -29,6 +30,23 @@ class Services(click.MultiCommand):
# Click-specific methods
def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]:
"""Preprocess --slow to support optional range value before Click parses args."""
processed = []
i = 0
while i < len(args):
if args[i] == "--slow":
if i + 1 < len(args) and re.match(r"^\d+-\d+$", args[i + 1]):
processed.append(f"--slow={args[i + 1]}")
i += 2
else:
processed.append("--slow=60-120")
i += 1
else:
processed.append(args[i])
i += 1
return super().parse_args(ctx, processed)
def list_commands(self, ctx: click.Context) -> list[str]:
"""Returns a list of all available Services as command names for Click.