tribler.core.libtorrent.restapi.downloads_endpoint

Attributes

TOTAL

LOADED

ALL_LOADED

logger

Classes

JSONFilesInfo

A JSON dict to describe file info.

DownloadsEndpoint

This endpoint is responsible for all requests regarding downloads. Examples include getting all downloads,

TorrentStreamResponse

A response object to stream the contents of a download.

Module Contents

tribler.core.libtorrent.restapi.downloads_endpoint.TOTAL = 'total'
tribler.core.libtorrent.restapi.downloads_endpoint.LOADED = 'loaded'
tribler.core.libtorrent.restapi.downloads_endpoint.ALL_LOADED = 'all_loaded'
tribler.core.libtorrent.restapi.downloads_endpoint.logger
class tribler.core.libtorrent.restapi.downloads_endpoint.JSONFilesInfo

Bases: TypedDict

A JSON dict to describe file info.

index: int
name: str
size: int
included: bool
progress: float
class tribler.core.libtorrent.restapi.downloads_endpoint.DownloadsEndpoint(download_manager: tribler.core.libtorrent.download_manager.download_manager.DownloadManager, tunnel_community: tribler.core.tunnel.community.TriblerTunnelCommunity | None = None)

Bases: tribler.core.restapi.rest_endpoint.RESTEndpoint

This endpoint is responsible for all requests regarding downloads. Examples include getting all downloads, starting, pausing and stopping downloads.

path = '/api/downloads'
download_manager
tunnel_community = None
static return_404(message: str = 'this download does not exist') tribler.core.restapi.rest_endpoint.RESTResponse

Returns a 404 response code if your channel has not been created.

create_dconfig_from_params(parameters: dict) tuple[tribler.core.libtorrent.download_manager.download_config.DownloadConfig, None] | tuple[None, str]

Create a download configuration based on some given parameters.

Possible parameters are: - anon_hops: the number of hops for the anonymous download. 0 hops is equivalent to a plain download - safe_seeding: whether the seeding of the download should be anonymous or not (0 = off, 1 = on) - destination: the destination path of the torrent (where it is saved on disk)

static get_files_info_json(download: tribler.core.libtorrent.download_manager.download.Download) list[JSONFilesInfo]

Return file information as JSON from a specified download.

async get_downloads(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse

Return all downloads, both active and inactive.

_post_handle_events(download: tribler.core.libtorrent.download_manager.download.Download) None

Schedule all the configured events that need to happen after this download receives a handle.

async add_download(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse

Start a download from a provided URI.

async delete_download(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse

Remove a specific download.

async update_download(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse

Update a specific download.

async get_torrent(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse

Return the .torrent file associated with the specified download.

async add_tracker(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse

Return the .torrent file associated with the specified download.

async remove_tracker(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse

Return the .torrent file associated with the specified download.

async tracker_force_announce(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse

Forcefully announce to the given tracker.

async get_files(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse

Return file information of a specific download.

_get_extended_status(download: tribler.core.libtorrent.download_manager.download.Download) tribler.core.libtorrent.download_manager.download_state.DownloadStatus

This function filters the original download status to possibly add tunnel-related status. Extracted from DownloadState to remove coupling between DownloadState and Tunnels.

async stream(request: aiohttp.web_request.Request) aiohttp.web.StreamResponse

Stream the contents of a file that is being downloaded.

class tribler.core.libtorrent.restapi.downloads_endpoint.TorrentStreamResponse(download: tribler.core.libtorrent.download_manager.download.Download, file_index: int, **kwargs)

Bases: aiohttp.web_response.StreamResponse

A response object to stream the contents of a download.

_download
_file_index
async prepare(request: aiohttp.abc.BaseRequest) aiohttp.abc.AbstractStreamWriter | None

Prepare the response.