Torrents (elixir_torrent v0.1.2)

Copy Markdown View Source

Internal runtime facade used by ElixirTorrent.

Use ElixirTorrent as the preferred public API.

Summary

Functions

Starts a new torrent download from a local .torrent path.

Stops a running torrent and removes it from the active list.

Returns a default set of runtime stats for a torrent process.

Returns selected runtime fields for a torrent process as a map keyed by field.

Functions

child_spec(_)

download(path)

@spec download(Path.t()) :: DynamicSupervisor.on_start_child()

Starts a new torrent download from a local .torrent path.

Returns {:ok, pid} on success.

remove(hash, opts \\ [])

@spec remove(
  binary(),
  keyword()
) :: :ok | {:error, term()}

Stops a running torrent and removes it from the active list.

When :delete_data is true, downloaded files are deleted from disk after the torrent process has been stopped.

stats(pid)

@spec stats(pid()) :: {:ok, map()} | {:error, :torrent_not_found}

Returns a default set of runtime stats for a torrent process.

The default fields are: [:name, :speed, :downloaded, :bytes_size].

stats(pid, fields)

@spec stats(pid(), [atom()]) :: {:ok, map()} | {:error, :torrent_not_found}

Returns selected runtime fields for a torrent process as a map keyed by field.

Example:

Torrents.stats(pid, [:name, :speed, :downloaded, :bytes_size])