I have read through the manual and I cannot find the answer. Given a magnet link I would like to generate a torrent file so that it can be loaded on the next startup to avoid redownloading the metadata. I have tried the fast resume feature, but I still have to fetch meta data when I do it and that can take quite a bit of time. Examples that I have seen are for creating torrent files for a new torrent, where as I would like to create one matching a magnet uri.
Share
Solution found here:
http://code.google.com/p/libtorrent/issues/detail?id=165#c5
See creating torrent:
http://www.rasterbar.com/products/libtorrent/make_torrent.html
Modify first lines:
To this:
“handle” is from here:
Also before creating torrent you have to make sure that metadata has been downloaded, do this by calling
handle.has_metadata().UPDATE
Seems like libtorrent python api is missing some of important c++ api that is required to create torrent from magnets, the example above won’t work in python cause
create_torrentpython class does not accept torrent_info as parameter (c++ has it available).So I tried it another way, but also encountered a brick wall that makes it impossible, here is the code:
There is an error thrown on this line:
It expects hash to be
const char*buttorrent_info.hash_for_piece(int)returns classbig_numberwhich has no api to convert it back to const char*.When I find some time I will report this missing api bug to libtorrent developers, as currently it is impossible to create a .torrent file from a magnet uri when using python bindings.
torrent_info.orig_files()is also missing in python bindings, I’m not sure whethertorrent_info.files()is sufficient.UPDATE 2
I’ve created an issue on this, see it here:
http://code.google.com/p/libtorrent/issues/detail?id=294
Star it so they fix it fast.
UPDATE 3
It is fixed now, there is a 0.16.0 release. Binaries for windows are also available.