Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get the total size of a torrent in libtorrent?

How do you get the total size of the files in a torrent?

And is there any way to get the number of files in a torrent and the size of each one?

like image 312
Sheik797 Avatar asked Nov 29 '25 17:11

Sheik797


2 Answers

h = ses.add_torrent(params)
s = h.status()
while (not h.is_seed()):
    print s.total_wanted   # prints total size wanted after meta data is obtained, before that 0 is printed.
like image 52
Sheik797 Avatar answered Dec 01 '25 05:12

Sheik797


If you take a look at the C++ API you will find that the torrent-info and file_iterator methods a little down the page give you the information you are looking for. The python bindings section states:

The python interface is nearly identical to the C++ interface.

So you should be able to get at these methods with a little effort.

like image 28
Steve Barnes Avatar answered Dec 01 '25 05:12

Steve Barnes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!