Public API for controlling torrent downloads.
This is the entrypoint you should use from other applications.
Start a download with download/1 and poll stats with stats/2.
Public functions
main/1- starts the CLI loop used by the escriptversion/0- returns this client's peer ID/version stringdownload/1- starts downloading a.torrentfrom diskstats/2- fetches selected runtime stats for a torrentget/2- low-level raw getter kept for compatibilitylist_files/1- lists files with per-file download progressremove/2- stops a torrent and optionally deletes its data
Summary
Functions
Starts downloading a .torrent file from the given local path.
Low-level getter that proxies to the internal torrent model getter through the torrent pid.
Lists files in a torrent with per-file download progress.
Starts the CLI loop used by the escript entrypoint.
Stops a torrent and removes it from the active session.
Returns selected runtime stats for a running torrent process.
Returns the peer ID/version string advertised by this client.
Types
@type file_entry() :: %{ index: non_neg_integer(), path: String.t(), name: String.t(), length: non_neg_integer(), downloaded: non_neg_integer(), progress: float(), complete?: boolean() }
Per-file progress entry returned by list_files/1.
Keys: :index, :path, :name, :length, :downloaded, :progress, :complete?.
@type info_hash() :: binary()
20-byte torrent info hash.
Functions
Starts downloading a .torrent file from the given local path.
Returns the same value as Torrents.download/1:
{:ok, pid} on success or {:error, reason}.
Example:
{:ok, pid} = ElixirTorrent.download("/tmp/file.torrent")
Low-level getter that proxies to the internal torrent model getter through the torrent pid.
Prefer stats/2 when you need runtime statistics as a map.
@spec list_files(info_hash()) :: [file_entry()]
Lists files in a torrent with per-file download progress.
See file_entry/0 for the shape of each returned entry.
Starts the CLI loop used by the escript entrypoint.
Stops a torrent and removes it from the active session.
Pass delete_data: true to also delete downloaded files from disk.
Returns selected runtime stats for a running torrent process.
By default it returns:
:name, :speed, :downloaded, :bytes_size.
You can request custom fields, for example:
ElixirTorrent.stats(pid, [:name, :speed, :downloaded, :bytes_size])Result shape:
{:ok,
%{
name: "ubuntu.iso",
speed: %{download: 1200, upload: 80},
downloaded: 1048576,
bytes_size: 4294967296
}}
Returns the peer ID/version string advertised by this client.