python-libtorrent torrent_info method

527 Views Asked by At

I've been using python-libtorrent to check what pieces belong to a file in a torrent containing multiple files.

I'm using the below code to iterate over the torrent file

info = libtorrent.torrent_info('~/.torrent')
for f in info.files():
    print f

But this returns <libtorrent.file_entry object at 0x7f0eda4fdcf0> and I don't know how to extract information from this.

I'm unaware of the torrent_info property which would return piece value information of various files. Some help is appreciated.

2

There are 2 best solutions below

0
On

the API is documented here and here. Obviously the python API can't always be exactly as the C++ one. But generally the interface takes a file index and returns some property of that file.

1
On
info = libtorrent.torrent_info('~/.torrent')
for f in info.files():
    # print f  
    print (f.path) 

You will get the important message...