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:
-
announce_list
(list[list[str]] | None
) –List of lists of announce URIs.
-
comment
(str | None
) –Return the comment of the torrent.
-
creation_date
(datetime
) –Return the creation time of the torrent.
-
info
(dict | None
) –Struct which contains data from Info dictionary.
-
mode
(str | None
) –File mode of the torrent.
Source code in src/aria2p/downloads.py
27 28 29 30 31 32 33 |
|
announce_list property
¤
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:
-
datetime
–The creation date.
Download ¤
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:
-
completed_length_string
–Return the completed length as string.
-
copy_files
–Copy downloaded files to another directory.
-
download_speed_string
–Return the download speed as string.
-
eta_string
–Return the Estimated Time of Arrival as a string.
-
move
–Move the download in the queue, relatively.
-
move_down
–Move the download down in the queue.
-
move_files
–Move downloaded files to another directory.
-
move_to
–Move the download in the queue, absolutely.
-
move_to_bottom
–Move the download to the bottom of the queue.
-
move_to_top
–Move the download to the top of the queue.
-
move_up
–Move the download up in the queue.
-
pause
–Pause the download.
-
piece_length_string
–Return the piece length as string.
-
progress_string
–Return the progress percentage as string.
-
purge
–Purge itself from the results.
-
remove
–Remove the download from the queue (even if active).
-
resume
–Resume the download.
-
total_length_string
–Return the total length as string.
-
update
–Update the internal values of the download with more recent values.
-
update_options
–Re-fetch the options from the remote.
-
upload_length_string
–Return the upload length as string.
-
upload_speed_string
–Return the upload speed as string.
-
verified_length_string
–Return the verified length as string.
Attributes:
-
belongs_to
(Download | None
) –Parent download.
-
belongs_to_id
(str | None
) –GID of a parent download.
-
bitfield
(str | None
) –Hexadecimal representation of the download progress.
-
bittorrent
(BitTorrent | None
) –Struct which contains information retrieved from the .torrent (file).
-
completed_length
(int
) –Completed length of the download in bytes.
-
connections
(int
) –Return the number of peers/servers aria2 has connected to.
-
control_file_path
(Path
) –Return the path to the aria2 control file for this download.
-
dir
(Path
) –Directory to save files.
-
download_speed
(int
) –Download speed of this download measured in bytes/sec.
-
error_code
(str | None
) –Return the code of the last error for this item, if any.
-
error_message
(str | None
) –Return the (hopefully) human readable error message associated to errorCode.
-
eta
(timedelta
) –Return the Estimated Time of Arrival (a timedelta).
-
files
(list[File]
) –Return the list of files.
-
followed_by
(list[Download]
) –List of downloads generated as the result of this download.
-
followed_by_ids
(list[str]
) –List of GIDs which are generated as the result of this download.
-
following
(Download | None
) –Return the download this download is following.
-
following_id
(str | None
) –Return the reverse link for followedBy.
-
gid
(str
) –GID of the download.
-
has_failed
(bool
) –Return True if download has errored.
-
info_hash
(str | None
) –Return the InfoHash.
-
is_active
(bool
) –Return True if download is active.
-
is_complete
(bool
) –Return True if download is complete.
-
is_metadata
(bool
) –Return True if this download is only composed of metadata, and no actual files.
-
is_paused
(bool
) –Return True if download is paused.
-
is_removed
(bool
) –Return True if download was removed.
-
is_torrent
(bool
) –Return true if this download is a torrent.
-
is_waiting
(bool
) –Return True if download is waiting.
-
live
(Download
) –Return the same object with updated data.
-
name
(str
) –Return the name of the download.
-
num_pieces
(int
) –Return the number of pieces.
-
num_seeders
(int
) –Return the number of seeders aria2 has connected to.
-
options
(Options
) –Options specific to this download.
-
piece_length
(int
) –Piece length in bytes.
-
progress
(float
) –Return the progress of the download as float.
-
root_files_paths
(list[Path]
) –Return the unique set of directories/files for this download.
-
seeder
(bool
) –Return True if the local endpoint is a seeder, otherwise false.
-
status
(str
) –Return the status of the download.
-
total_length
(int
) –Total length of the download in bytes.
-
upload_length
(int
) –Return the uploaded length of the download in bytes.
-
upload_speed
(int
) –Upload speed of this download measured in bytes/sec.
-
verified_length
(int
) –Return the number of verified number of bytes while the files are being hash checked.
-
verify_integrity_pending
(bool | None
) –Return True if this download is waiting for the hash check in a queue.
Source code in src/aria2p/downloads.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
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:
-
BitTorrent | None
–A BitTorrent instance or
None
.
connections property
¤
connections: int
Return the number of peers/servers aria2 has connected to.
Returns:
-
int
–The number of connected peers/servers.
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
¤
followed_by property
¤
followed_by_ids property
¤
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:
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.
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.
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_seeders property
¤
num_seeders: int
Return the number of seeders aria2 has connected to.
BitTorrent only.
Returns:
-
int
–The numbers of seeders.
root_files_paths property
¤
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
orremoved
.
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 ¤
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 |
|
copy_files ¤
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 |
|
download_speed_string ¤
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 |
|
eta_string ¤
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 |
|
move ¤
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 |
|
move_down ¤
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 |
|
move_files ¤
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 |
|
move_to ¤
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 |
|
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 |
|
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 |
|
move_up ¤
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 |
|
pause ¤
Pause the download.
Parameters:
-
force
(bool
, default:False
) –Whether to force pause (don't contact servers).
Returns:
-
bool
–Always True (raises exception otherwise).
Raises:
-
ClientException
–When pausing failed.
Source code in src/aria2p/downloads.py
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 |
|
piece_length_string ¤
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 |
|
progress_string ¤
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 |
|
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 |
|
remove ¤
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:
-
ClientException
–When removal failed.
Source code in src/aria2p/downloads.py
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
|
resume ¤
resume() -> bool
Resume the download.
Returns:
-
bool
–Always True (raises exception otherwise).
Raises:
-
ClientException
–When resuming failed.
Source code in src/aria2p/downloads.py
978 979 980 981 982 983 984 985 986 987 988 989 990 |
|
total_length_string ¤
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 |
|
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 |
|
update_options ¤
update_options() -> None
Re-fetch the options from the remote.
Source code in src/aria2p/downloads.py
354 355 356 |
|
upload_length_string ¤
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 |
|
upload_speed_string ¤
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 |
|
verified_length_string ¤
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 |
|
File ¤
File(struct: dict)
Information about a download's file.
Parameters:
-
struct
(dict
) –A dictionary Python object returned by the JSON-RPC client.
Methods:
-
completed_length_string
–Return the completed length as string.
-
length_string
–Return the length as string.
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 |
|
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.
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
¤
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 ¤
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 |
|
length_string ¤
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 |
|