I have been creating libtorrent client python to download torrent directly into Google drive in google colab.
Everything works fine, but I want to download specific files from some big torrent but because of colab limited storage use, I found out that using handle.file_priority(x, 0) I can set to not download that file where x is file index number and 0 to dont download , And it works fine too by downloading by given priority, The problem is i have to do that (set handle.file_priority(x, 0)) without knowing index.
And to know index from torrent_info() i use this code
torinfo = handle.get_torrent_info()
for x in range(torinfo.files().num_files()):
print(torinfo.files().file_path(x))
But to use that i first have to set handle, where it goes wrong. whenever i set handle for
either:
handle = ses.add_torrent(params) - for .torrent file
or:
handle = lt.add_magnet_uri(ses, magnet_link, params) - for magnet link
the torrent starts downloading. So, i have to set file priority without knowing index.
My problems :
How to set handle without starting download or to know index of files before starting.
My current method (setting file_priority without knowing index and put this code below handle code to work correctly) works fine by downloading specific files, but the last cell which i use to see download progress is in loop even though it says finished. it shows complete when i download torrent fully but not when using files priority (is it bcuz i download only some files but not completely ?) and it loops on handle.status_seed and sleep(1).
MY Code : https://colab.research.google.com/drive/108mMw_y0ZHAD80KHIfDmVaZnImwuc1Df?usp=sharing
Any help is appreciated, Thanks in advance