Skip to content

downloads ¤

This module defines the BitTorrent, File and Download classes.

They respectively hold structured information about torrent files, files and downloads in aria2c.

Classes:

  • BitTorrent

    Information retrieved from a torrent file.

  • Download

    Class containing all information about a download, as retrieved with the client.

  • File

    Information about a download's file.

BitTorrent ¤

BitTorrent(struct: dict)

Information retrieved from a torrent file.

Parameters:

  • struct (dict) –

    A dictionary Python object returned by the JSON-RPC client.

Attributes:

Source code in src/aria2p/downloads.py
27
28
29
30
31
32
33
def __init__(self, struct: dict) -> None:
    """Initialize the object.

    Parameters:
        struct: A dictionary Python object returned by the JSON-RPC client.
    """
    self._struct = struct or {}

announce_list property ¤

announce_list: list[list[str]] | None

List of lists of announce URIs.

If the torrent contains announce and no announce-list, announce is converted to the announce-list format.

Returns:

comment property ¤

comment: str | None

Return the comment of the torrent.

comment.utf-8 is used if available.

Returns:

  • str | None

    The torrent's comment.

creation_date property ¤

creation_date: datetime

Return the creation time of the torrent.

The value is an integer since the epoch, measured in seconds.

Returns:

info property ¤

info: dict | None

Struct which contains data from Info dictionary.

It contains the name key: name in info dictionary. name.utf-8 is used if available.

Returns:

  • dict | None

    The torrent's info.

mode property ¤

mode: str | None

File mode of the torrent.

The value is either single or multi.

Returns:

  • str | None

    The file mode.

Download ¤

Download(api: API, struct: dict)

Class containing all information about a download, as retrieved with the client.

Parameters:

  • api (API) –

    The reference to an API instance.

  • struct (dict) –

    A dictionary Python object returned by the JSON-RPC client.

Methods:

Attributes:

Source code in src/aria2p/downloads.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
def __init__(self, api: API, struct: dict) -> None:
    """Initialize the object.

    Parameters:
        api: The reference to an [`API`][aria2p.api.API] instance.
        struct: A dictionary Python object returned by the JSON-RPC client.
    """
    self.api = api
    self._struct = struct or {}
    self._files: list[File] = []
    self._root_files_paths: list[Path] = []
    self._bittorrent: BitTorrent | None = None
    self._name = ""
    self._options: Options | None = None
    self._followed_by: list[Download] | None = None
    self._following: Download | None = None
    self._belongs_to: Download | None = None

belongs_to property ¤

belongs_to: Download | None

Parent download.

Returns:

belongs_to_id property ¤

belongs_to_id: str | None

GID of a parent download.

Some downloads are a part of another download. For example, if a file in a Metalink has BitTorrent resources, The downloads of ".torrent" files are parts of that parent. If this download has no parent, this key will not be included in the response.

Returns:

  • str | None

    The GID of the parent download.

bitfield property ¤

bitfield: str | None

Hexadecimal representation of the download progress.

The highest bit corresponds to the piece at index 0. Any set bits indicate loaded pieces, while unset bits indicate not yet loaded and/or missing pieces. Any overflow bits at the end are set to zero. When the download was not started yet, this key will not be included in the response.

Returns:

  • str | None

    The hexadecimal representation of the download progress.

bittorrent property ¤

bittorrent: BitTorrent | None

Struct which contains information retrieved from the .torrent (file).

BitTorrent only.

Returns:

completed_length property ¤

completed_length: int

Completed length of the download in bytes.

Returns:

  • int

    The completed length in bytes.

connections property ¤

connections: int

Return the number of peers/servers aria2 has connected to.

Returns:

  • int

    The number of connected peers/servers.

control_file_path property ¤

control_file_path: Path

Return the path to the aria2 control file for this download.

Returns:

  • Path

    The control file path.

dir property ¤

dir: Path

Directory to save files.

Returns:

  • Path

    The directory where the files are saved.

download_speed property ¤

download_speed: int

Download speed of this download measured in bytes/sec.

Returns:

  • int

    The download speed in bytes/sec.

error_code property ¤

error_code: str | None

Return the code of the last error for this item, if any.

The value is a string. The error codes are defined in the EXIT STATUS section. This value is only available for stopped/completed downloads.

Returns:

  • str | None

    The error code.

error_message property ¤

error_message: str | None

Return the (hopefully) human readable error message associated to errorCode.

Returns:

  • str | None

    The error message.

eta property ¤

eta: timedelta

Return the Estimated Time of Arrival (a timedelta).

Returns:

  • timedelta

    ETA or timedelta.max if unknown.

files property ¤

files: list[File]

Return the list of files.

The elements of this list are the same structs used in aria2.getFiles() method.

Returns:

  • list[File]

    The files of this download.

followed_by property ¤

followed_by: list[Download]

List of downloads generated as the result of this download.

Returns:

followed_by_ids property ¤

followed_by_ids: list[str]

List of GIDs which are generated as the result of this download.

For example, when aria2 downloads a Metalink file, it generates downloads described in the Metalink (see the --follow-metalink option). This value is useful to track auto-generated downloads. If there are no such downloads, this key will not be included in the response.

Returns:

  • list[str]

    The children downloads IDs.

following property ¤

following: Download | None

Return the download this download is following.

Returns:

following_id property ¤

following_id: str | None

Return the reverse link for followedBy.

A download included in followedBy has this object's GID in its following value.

Returns:

  • str | None

    The parent download ID.

gid property ¤

gid: str

GID of the download.

Returns:

  • str

    The download GID.

has_failed property ¤

has_failed: bool

Return True if download has errored.

Returns:

  • bool

    If this download has failed.

info_hash property ¤

info_hash: str | None

Return the InfoHash.

BitTorrent only.

Returns:

  • str | None

    The InfoHash.

is_active property ¤

is_active: bool

Return True if download is active.

Returns:

  • bool

    If this download is active.

is_complete property ¤

is_complete: bool

Return True if download is complete.

Returns:

  • bool

    If this download is complete.

is_metadata property ¤

is_metadata: bool

Return True if this download is only composed of metadata, and no actual files.

Returns:

  • bool

    If this is a metadata download.

is_paused property ¤

is_paused: bool

Return True if download is paused.

Returns:

  • bool

    If this download is paused.

is_removed property ¤

is_removed: bool

Return True if download was removed.

Returns:

  • bool

    If this download was removed.

is_torrent property ¤

is_torrent: bool

Return true if this download is a torrent.

Returns:

  • bool

    If this is a torrent downlaod.

is_waiting property ¤

is_waiting: bool

Return True if download is waiting.

Returns:

  • bool

    If this download is waiting.

live property ¤

live: Download

Return the same object with updated data.

Returns:

name property ¤

name: str

Return the name of the download.

Name is the name of the file if single-file, first file's directory name if multi-file.

Returns:

  • str

    The download name.

num_pieces property ¤

num_pieces: int

Return the number of pieces.

Returns:

  • int

    The number of pieces.

num_seeders property ¤

num_seeders: int

Return the number of seeders aria2 has connected to.

BitTorrent only.

Returns:

  • int

    The numbers of seeders.

options property writable ¤

options: Options

Options specific to this download.

Returns:

  • Options

    The download options.

piece_length property ¤

piece_length: int

Piece length in bytes.

Returns:

  • int

    The piece length in bytes.

progress property ¤

progress: float

Return the progress of the download as float.

Returns:

  • float

    Progress percentage.

root_files_paths property ¤

root_files_paths: list[Path]

Return the unique set of directories/files for this download.

Instead of returning all the leaves like self.files, return the relative root directories if any, and relative root files.

This property is useful when we need to list the directories and files in order to move or copy them. We don't want to copy files one by one, but rather entire directories at once when possible.

Returns:

Examples:

Download directory is /a/b.

>>> self.files
["/a/b/c/1.txt", "/a/b/c/2.txt", "/a/b/3.txt"]
>>> self.root_files_paths
["/a/b/c", "/a/b/3.txt"]

seeder property ¤

seeder: bool

Return True if the local endpoint is a seeder, otherwise false.

BitTorrent only.

Returns:

  • bool

    If the local endpoint is a seeder.

status property ¤

status: str

Return the status of the download.

Returns:

  • str

    active, waiting, paused, error, complete or removed.

total_length property ¤

total_length: int

Total length of the download in bytes.

Returns:

  • int

    The total length in bytes.

upload_length property ¤

upload_length: int

Return the uploaded length of the download in bytes.

Returns:

  • int

    The uploaded length in bytes.

upload_speed property ¤

upload_speed: int

Upload speed of this download measured in bytes/sec.

Returns:

  • int

    The upload speed in bytes/sec.

verified_length property ¤

verified_length: int

Return the number of verified number of bytes while the files are being hash checked.

This key exists only when this download is being hash checked.

Returns:

  • int

    The verified length.

verify_integrity_pending property ¤

verify_integrity_pending: bool | None

Return True if this download is waiting for the hash check in a queue.

This key exists only when this download is in the queue.

Returns:

  • bool | None

    Whether this download is waiting for the hash check.

completed_length_string ¤

completed_length_string(human_readable: bool = True) -> str

Return the completed length as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The completed length string.

Source code in src/aria2p/downloads.py
479
480
481
482
483
484
485
486
487
488
489
490
def completed_length_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the completed length as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The completed length string.
    """
    if human_readable:
        return human_readable_bytes(self.completed_length, delim=" ")
    return str(self.completed_length) + " B"

copy_files ¤

copy_files(
    to_directory: str | Path, force: bool = False
) -> bool

Copy downloaded files to another directory.

Parameters:

  • to_directory (str | Path) –

    The target directory to copy files into.

  • force (bool, default: False ) –

    Whether to move files even if download is not complete.

Returns:

  • bool

    Success or failure of the operation.

Source code in src/aria2p/downloads.py
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
def copy_files(self, to_directory: str | Path, force: bool = False) -> bool:  # noqa: FBT001,FBT002
    """Copy downloaded files to another directory.

    Parameters:
        to_directory: The target directory to copy files into.
        force: Whether to move files even if download is not complete.

    Returns:
        Success or failure of the operation.
    """
    return self.api.copy_files([self], to_directory, force)[0]

download_speed_string ¤

download_speed_string(human_readable: bool = True) -> str

Return the download speed as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The download speed string.

Source code in src/aria2p/downloads.py
536
537
538
539
540
541
542
543
544
545
546
547
def download_speed_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the download speed as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The download speed string.
    """
    if human_readable:
        return human_readable_bytes(self.download_speed, delim=" ", postfix="/s")
    return str(self.download_speed) + " B/s"

eta_string ¤

eta_string(precision: int = 0) -> str

Return the Estimated Time of Arrival as a string.

Parameters:

  • precision (int, default: 0 ) –

    The precision to use, see [aria2p.utils.human_readable_timedelta].

Returns:

  • str

    The Estimated Time of Arrival as a string.

Source code in src/aria2p/downloads.py
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
def eta_string(self, precision: int = 0) -> str:
    """Return the Estimated Time of Arrival as a string.

    Parameters:
        precision: The precision to use, see [aria2p.utils.human_readable_timedelta].

    Returns:
        The Estimated Time of Arrival as a string.
    """
    eta = self.eta

    if eta == timedelta.max:
        return "-"

    return human_readable_timedelta(eta, precision=precision)

move ¤

move(pos: int) -> int

Move the download in the queue, relatively.

Parameters:

  • pos (int) –

    Number of times to move.

Returns:

  • int

    The new position of the download.

Source code in src/aria2p/downloads.py
883
884
885
886
887
888
889
890
891
892
def move(self, pos: int) -> int:
    """Move the download in the queue, relatively.

    Parameters:
        pos: Number of times to move.

    Returns:
        The new position of the download.
    """
    return self.api.move(self, pos)

move_down ¤

move_down(pos: int = 1) -> int

Move the download down in the queue.

Parameters:

  • pos (int, default: 1 ) –

    Number of times to move down.

Returns:

  • int

    The new position of the download.

Source code in src/aria2p/downloads.py
916
917
918
919
920
921
922
923
924
925
def move_down(self, pos: int = 1) -> int:
    """Move the download down in the queue.

    Parameters:
        pos: Number of times to move down.

    Returns:
        The new position of the download.
    """
    return self.api.move_down(self, pos)

move_files ¤

move_files(
    to_directory: str | Path, force: bool = False
) -> bool

Move downloaded files to another directory.

Parameters:

  • to_directory (str | Path) –

    The target directory to move files to.

  • force (bool, default: False ) –

    Whether to move files even if download is not complete.

Returns:

  • bool

    Success or failure of the operation.

Source code in src/aria2p/downloads.py
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
def move_files(self, to_directory: str | Path, force: bool = False) -> bool:  # noqa: FBT001,FBT002
    """Move downloaded files to another directory.

    Parameters:
        to_directory: The target directory to move files to.
        force: Whether to move files even if download is not complete.

    Returns:
        Success or failure of the operation.
    """
    return self.api.move_files([self], to_directory, force)[0]

move_to ¤

move_to(pos: int) -> int

Move the download in the queue, absolutely.

Parameters:

  • pos (int) –

    The absolute position in the queue to take.

Returns:

  • int

    The new position of the download.

Source code in src/aria2p/downloads.py
894
895
896
897
898
899
900
901
902
903
def move_to(self, pos: int) -> int:
    """Move the download in the queue, absolutely.

    Parameters:
        pos: The absolute position in the queue to take.

    Returns:
        The new position of the download.
    """
    return self.api.move_to(self, pos)

move_to_bottom ¤

move_to_bottom() -> int

Move the download to the bottom of the queue.

Returns:

  • int

    The new position of the download.

Source code in src/aria2p/downloads.py
935
936
937
938
939
940
941
def move_to_bottom(self) -> int:
    """Move the download to the bottom of the queue.

    Returns:
        The new position of the download.
    """
    return self.api.move_to_bottom(self)

move_to_top ¤

move_to_top() -> int

Move the download to the top of the queue.

Returns:

  • int

    The new position of the download.

Source code in src/aria2p/downloads.py
927
928
929
930
931
932
933
def move_to_top(self) -> int:
    """Move the download to the top of the queue.

    Returns:
        The new position of the download.
    """
    return self.api.move_to_top(self)

move_up ¤

move_up(pos: int = 1) -> int

Move the download up in the queue.

Parameters:

  • pos (int, default: 1 ) –

    Number of times to move up.

Returns:

  • int

    The new position of the download.

Source code in src/aria2p/downloads.py
905
906
907
908
909
910
911
912
913
914
def move_up(self, pos: int = 1) -> int:
    """Move the download up in the queue.

    Parameters:
        pos: Number of times to move up.

    Returns:
        The new position of the download.
    """
    return self.api.move_up(self, pos)

pause ¤

pause(force: bool = False) -> bool

Pause the download.

Parameters:

  • force (bool, default: False ) –

    Whether to force pause (don't contact servers).

Returns:

  • bool

    Always True (raises exception otherwise).

Raises:

Source code in src/aria2p/downloads.py
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
def pause(self, force: bool = False) -> bool:  # noqa: FBT001,FBT002
    """Pause the download.

    Parameters:
        force: Whether to force pause (don't contact servers).

    Returns:
        Always True (raises exception otherwise).

    Raises:
        ClientException: When pausing failed.
    """
    result = self.api.pause([self], force=force)[0]
    if not result:
        raise result  # type: ignore  # we know it's a ClientException
    return True

piece_length_string ¤

piece_length_string(human_readable: bool = True) -> str

Return the piece length as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The piece length string.

Source code in src/aria2p/downloads.py
613
614
615
616
617
618
619
620
621
622
623
624
def piece_length_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the piece length as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The piece length string.
    """
    if human_readable:
        return human_readable_bytes(self.piece_length, delim=" ")
    return str(self.piece_length) + " B"

progress_string ¤

progress_string(digits: int = 2) -> str

Return the progress percentage as string.

Parameters:

  • digits (int, default: 2 ) –

    Number of decimal digits to use.

Returns:

  • str

    The progress percentage.

Source code in src/aria2p/downloads.py
844
845
846
847
848
849
850
851
852
853
def progress_string(self, digits: int = 2) -> str:
    """Return the progress percentage as string.

    Parameters:
        digits: Number of decimal digits to use.

    Returns:
        The progress percentage.
    """
    return f"{self.progress:.{digits}f}%"

purge ¤

purge() -> bool

Purge itself from the results.

Returns:

  • bool

    Success or failure of the operation.

Source code in src/aria2p/downloads.py
992
993
994
995
996
997
998
def purge(self) -> bool:
    """Purge itself from the results.

    Returns:
        Success or failure of the operation.
    """
    return self.api.client.remove_download_result(self.gid) == "OK"

remove ¤

remove(force: bool = False, files: bool = False) -> bool

Remove the download from the queue (even if active).

Parameters:

  • force (bool, default: False ) –

    Whether to force removal.

  • files (bool, default: False ) –

    Whether to remove files as well.

Returns:

  • bool

    Always True (raises exception otherwise).

Raises:

Source code in src/aria2p/downloads.py
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
def remove(self, force: bool = False, files: bool = False) -> bool:  # noqa: FBT001,FBT002
    """Remove the download from the queue (even if active).

    Parameters:
        force: Whether to force removal.
        files: Whether to remove files as well.

    Returns:
        Always True (raises exception otherwise).

    Raises:
        ClientException: When removal failed.
    """
    result = self.api.remove([self], force=force, files=files)[0]
    if not result:
        raise result  # type: ignore  # we know it's a ClientException
    return True

resume ¤

resume() -> bool

Resume the download.

Returns:

  • bool

    Always True (raises exception otherwise).

Raises:

Source code in src/aria2p/downloads.py
978
979
980
981
982
983
984
985
986
987
988
989
990
def resume(self) -> bool:
    """Resume the download.

    Returns:
        Always True (raises exception otherwise).

    Raises:
        ClientException: When resuming failed.
    """
    result = self.api.resume([self])[0]
    if not result:
        raise result  # type: ignore  # we know it's a ClientException
    return True

total_length_string ¤

total_length_string(human_readable: bool = True) -> str

Return the total length as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The total length string.

Source code in src/aria2p/downloads.py
457
458
459
460
461
462
463
464
465
466
467
468
def total_length_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the total length as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The total length string.
    """
    if human_readable:
        return human_readable_bytes(self.total_length, delim=" ")
    return str(self.total_length) + " B"

update ¤

update() -> None

Update the internal values of the download with more recent values.

Source code in src/aria2p/downloads.py
243
244
245
246
247
248
249
250
251
252
253
def update(self) -> None:
    """Update the internal values of the download with more recent values."""
    self._struct = self.api.client.tell_status(self.gid)

    self._files = []
    self._name = ""
    self._bittorrent = None
    self._followed_by = None
    self._following = None
    self._belongs_to = None
    self._options = None

update_options ¤

update_options() -> None

Re-fetch the options from the remote.

Source code in src/aria2p/downloads.py
354
355
356
def update_options(self) -> None:
    """Re-fetch the options from the remote."""
    self._options = self.api.get_options(downloads=[self])[0]

upload_length_string ¤

upload_length_string(human_readable: bool = True) -> str

Return the upload length as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The upload length string.

Source code in src/aria2p/downloads.py
501
502
503
504
505
506
507
508
509
510
511
512
def upload_length_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the upload length as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The upload length string.
    """
    if human_readable:
        return human_readable_bytes(self.upload_length, delim=" ")
    return str(self.upload_length) + " B"

upload_speed_string ¤

upload_speed_string(human_readable: bool = True) -> str

Return the upload speed as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The upload speed string.

Source code in src/aria2p/downloads.py
558
559
560
561
562
563
564
565
566
567
568
569
def upload_speed_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the upload speed as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The upload speed string.
    """
    if human_readable:
        return human_readable_bytes(self.upload_speed, delim=" ", postfix="/s")
    return str(self.upload_speed) + " B/s"

verified_length_string ¤

verified_length_string(human_readable: bool = True) -> str

Return the verified length as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The verified length string.

Source code in src/aria2p/downloads.py
808
809
810
811
812
813
814
815
816
817
818
819
def verified_length_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the verified length as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The verified length string.
    """
    if human_readable:
        return human_readable_bytes(self.verified_length, delim=" ")
    return str(self.verified_length) + " B"

File ¤

File(struct: dict)

Information about a download's file.

Parameters:

  • struct (dict) –

    A dictionary Python object returned by the JSON-RPC client.

Methods:

Attributes:

  • completed_length (int) –

    Completed length of this file in bytes.

  • index (int) –

    Index of the file, starting at 1, in the same order as files appear in the multi-file torrent.

  • is_metadata (bool) –

    Return True if this file is aria2 metadata and not an actual file.

  • length (int) –

    Return the file size in bytes.

  • path (Path) –

    File path.

  • selected (bool) –

    Return True if this file is selected by --select-file option.

  • uris (list[dict]) –

    Return a list of URIs for this file.

Source code in src/aria2p/downloads.py
 97
 98
 99
100
101
102
103
def __init__(self, struct: dict) -> None:
    """Initialize the object.

    Parameters:
        struct: A dictionary Python object returned by the JSON-RPC client.
    """
    self._struct = struct or {}

completed_length property ¤

completed_length: int

Completed length of this file in bytes.

Please note that it is possible that sum of completedLength is less than the completedLength returned by the aria2.tellStatus() method. This is because completedLength in aria2.getFiles() only includes completed pieces. On the other hand, completedLength in aria2.tellStatus() also includes partially completed pieces.

Returns:

  • int

    The completed length.

index property ¤

index: int

Index of the file, starting at 1, in the same order as files appear in the multi-file torrent.

Returns:

  • int

    The index of the file.

is_metadata property ¤

is_metadata: bool

Return True if this file is aria2 metadata and not an actual file.

Returns:

  • bool

    If the file is metadata.

length property ¤

length: int

Return the file size in bytes.

Returns:

  • int

    The file size in bytes.

path property ¤

path: Path

File path.

Returns:

  • Path

    The file path.

selected property ¤

selected: bool

Return True if this file is selected by --select-file option.

If --select-file is not specified or this is single-file torrent or not a torrent download at all, this value is always true. Otherwise false.

Returns:

  • bool

    If this file is selected.

uris property ¤

uris: list[dict]

Return a list of URIs for this file.

The element type is the same struct used in the client.get_uris() method.

Returns:

completed_length_string ¤

completed_length_string(human_readable: bool = True) -> str

Return the completed length as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The completed length string.

Source code in src/aria2p/downloads.py
175
176
177
178
179
180
181
182
183
184
185
186
def completed_length_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the completed length as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The completed length string.
    """
    if human_readable:
        return human_readable_bytes(self.completed_length, delim=" ")
    return str(self.completed_length) + " B"

length_string ¤

length_string(human_readable: bool = True) -> str

Return the length as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The length string.

Source code in src/aria2p/downloads.py
149
150
151
152
153
154
155
156
157
158
159
160
def length_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the length as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The length string.
    """
    if human_readable:
        return human_readable_bytes(self.length, delim=" ")
    return str(self.length) + " B"