0
votes

I am using libtorrent for python 3.6 . I just want to get any file names that downloaded with a session, e.g. the folder name, the files name etc. I searched around the web didn't come across anything. I am using the follow example:

https://www.libtorrent.org/python_binding.html

So when the download progress finish, i want to know what files this session downloaded. How can achieve that? Thanks in advance!

1

1 Answers

1
votes

Finally found the answer, the code is:

handle = libtorrent.add_magnet_uri(session, magnetLink,params)

    session.start_dht()                

    while not handle.has_metadata():
        time.sleep(1)          

    torinfo = handle.get_torrent_info()

    for x in range(torinfo.files().num_files()):
        print(torinfo.files().file_path(x))

The code above prints the file names that came with the magnet file.