tribler.core.libtorrent.torrentdef

Attributes

BLOCK_SIZE

Classes

TorrentDef

This object acts as a wrapper around some libtorrent metadata.

Functions

best_info_hash(→ bytes)

Get the best bytes representation of available info hash material.

Module Contents

tribler.core.libtorrent.torrentdef.BLOCK_SIZE = 16384
tribler.core.libtorrent.torrentdef.best_info_hash(info_hashes: libtorrent.info_hash_t, info_hash: libtorrent.sha1_hash) bytes

Get the best bytes representation of available info hash material.

class tribler.core.libtorrent.torrentdef.TorrentDef(atp: libtorrent.add_torrent_params)

This object acts as a wrapper around some libtorrent metadata. It can be used to create new torrents, or analyze existing ones.

atp
__str__() str

We are essentially the ATP dictionary itself.

property name: str

Get the name of this torrent.

property description: str

Get the description of this torrent.

property torrent_info: libtorrent.torrent_info | None

Get the libtorrent torrent info instance or load it from our metainfo.

property infohash: bytes

Convenient way to get the info_hash as bytes.

static _threaded_load_job(filepath: str) TorrentDef

Perform the actual loading of the torrent.

Called from a thread: don’t call this directly!

static load(filepath: str) TorrentDef
Async:

Create a TorrentDef object from a .torrent file.

Parameters:

filepath – The path to the .torrent file

static load_from_memory(bencoded_data: bytes) TorrentDef

Load some bencoded data into a TorrentDef.

Parameters:

bencoded_data – The bencoded data to decode and use as metainfo

get_file_indices() list[int]

Get the actual torrent file indices of our files.

_get_piece_range_from_file_idx(fstorage: libtorrent.file_storage, file_idx: int) collections.abc.Sequence[int]

Get the piece range from a file index.

get_v2_piece_hash(piece_index: int, piece_buffer: bytes) bytes

Get the (32-byte) SHA-256 hash for the specified piece from its buffer.

get_v2_piece_indices_per_layer() dict[bytes, list[int]]

Get the piece indices per file root hash.