Is there a way to generate .torrent file from a magnet link using the MonoTorrent .Net library? If so can someone explain with an example? I searched the site as well as googled but cant find a solution. if it is not possible are there any other windows commnd line utility that will get the job done? thanks and appreciate ur help in advance!
2 Answers
yes, It could be done using the monotorrent library.
you could take the hash value from the magnet link and use it to create a torrent manager that will create a torrent file before downloading.
if this were the magnet link:
magnet:?xt=urn:btih:18981bc9759950b4715ad46adcaf514e6a773cfe
hash=18981bc9759950b4715ad46adcaf514e6a773cfe;
manager = new TorrentManager(InfoHash.FromHex(hash), downloadsPath, torrentDefaults, downloadsPathForTorrent);
this should download a torrent file to 'downloadsPathForTorrent', and you can stop the download as soon as it begins.
hope this helped.
for more information on how to implement this checkout the monotorrent documentation:

- 66
- 5
-
Thank you!! appreciate your answer. I thought it was not possible. I am going to try it later as I have to brush up on that part of code again on my project :) – user1715559 Nov 12 '13 at 22:19
-
1Unfortunately there's no constructor like the one you mentioned, and still, i've tried using most of the constructors for TorrentManager, but it doesn't starts to download... I suspect there's more to do for it to start... – Gabriel Duarte Jan 03 '16 at 05:19
I know this is answered few years ago, still I solved it by using a website :
http://torcache.net/torrent/18981BC9759950B4715AD46ADCAF514E6A773CFE.torrent
Just put the hash after the slash.
for exaple will download the same hash as dani gave above.
Work for me, much easier to archive.
Edit:
As @Gabriel Duarte mention, this work only on torrent that uploaded to the site, still I'm using this way because most of the biggest sites upload their torrents to this site, if I even need a better accuracy, I will probably use DHT search engine like this, even though it don't generate .torrent file but it supply .torrent info.
For me start complete Torrent client only for grab torrent file is too much resources I can provide.

- 1,053
- 1
- 19
- 25
-
1This would just work with torrents that the site have in cache... If the torrent comes from a private tracker for example it will give you a 404 error... – Gabriel Duarte Dec 21 '15 at 18:37
-
@GabrielDuarte Look [here](https://wiki.theory.org/BitTorrentSpecification#Info_Dictionary), Under `private`. All the private trackers mark it. – Remy Dec 21 '15 at 21:23
-
Still, it just works if you add the torrent to their cache through the following page: http://torcache.net/ . Try it with the hash "E7C9B57ED0EEABAF6286C0EDE546D8865BDB77B3" for example. It won't work because it isn't in their cache... – Gabriel Duarte Dec 22 '15 at 22:20
-
1@GabrielDuarte I understand what did you meant, I edited my answere to explain my attitude. – Remy Dec 24 '15 at 19:12
-
1Update: since Torcache.net has been dead, use *iTorrents.org* from now on. – David Refoua May 12 '17 at 01:04