Skip to content

remove ¤

Command to remove downloads.

Functions:

  • remove

    Remove subcommand.

remove ¤

remove(
    api: API,
    gids: list[str] | None = None,
    do_all: bool = False,
    force: bool = False,
) -> int

Remove subcommand.

Parameters:

  • api (API) –

    The API instance to use.

  • gids (list[str] | None, default: None ) –

    The GIDs of the downloads to remove.

  • do_all (bool, default: False ) –

    Pause all downloads if True.

  • force (bool, default: False ) –

    Force pause or not (see API.remove).

Returns:

  • int ( int ) –

    0 if all success, 1 if one failure.

Source code in src/aria2p/cli/commands/remove.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def remove(
    api: API,
    gids: list[str] | None = None,
    do_all: bool = False,  # noqa: FBT001,FBT002
    force: bool = False,  # noqa: FBT001,FBT002
) -> int:
    """Remove subcommand.

    Parameters:
        api: The API instance to use.
        gids: The GIDs of the downloads to remove.
        do_all: Pause all downloads if True.
        force: Force pause or not (see API.remove).

    Returns:
        int: 0 if all success, 1 if one failure.
    """
    if do_all:
        if api.remove_all():
            return 0
        return 1

    try:
        downloads = api.get_downloads(gids)
    except ClientException as error:
        print(str(error), file=sys.stderr)
        return 1

    ok = True
    result = api.remove(downloads, force=force)

    if all(result):
        return 0 if ok else 1

    for item in result:
        if isinstance(item, ClientException):
            print(item, file=sys.stderr)

    return 1