0

Is there a way to do it? I already tried with monotorrent, but due to the lack of up-to-date documentation i coudn't get it to work. I've already tried this with monotorrent, but still i can't find a way to get the .torrent file or even start the download to get the .torrent ...

The following piece of code was made that question as base, but it doesn't save anything to "D:\A" or to "D:\TorrentSave"

    private void GerarTorrent(string magnet)
    {
        MonoTorrent.Client.TorrentManager b = new MonoTorrent.Client.TorrentManager(new MonoTorrent.MagnetLink(magnet), "D:\\A", new MonoTorrent.Client.TorrentSettings(), "D:\\TorrentSave");
        MonoTorrent.Client.EngineSettings engineSettings = new MonoTorrent.Client.EngineSettings();
        MonoTorrent.Client.ClientEngine clientEngine = new MonoTorrent.Client.ClientEngine(engineSettings);
        clientEngine.Register(b);
        clientEngine.StartAll();
        b.Start();
    }

To generate the .torrent, it doesn't have to be monotorrent, in fact the only usage of this api would be for that, generating .torrent files from a magnet link...

EDIT: Updated code with my attempt on doing what Fᴀʀʜᴀɴ Aɴᴀᴍ said:

    private void GerarTorrent(string hash)
    {
        MonoTorrent.Client.TorrentManager b = new MonoTorrent.Client.TorrentManager(MonoTorrent.InfoHash.FromHex(hash), "D:\\A", new MonoTorrent.Client.TorrentSettings(), "D:\\TorrentSave", new List<List<string>>());
        MonoTorrent.Client.EngineSettings engineSettings = new MonoTorrent.Client.EngineSettings();
        MonoTorrent.Client.ClientEngine clientEngine = new MonoTorrent.Client.ClientEngine(engineSettings);
        clientEngine.Register(b);
        clientEngine.StartAll();
        b.Start();
    }

Hash used = "5FC86BA08451CF4221E0091F31AF1A52C2219009"

Community
  • 1
  • 1
Gabriel Duarte
  • 974
  • 1
  • 13
  • 28

1 Answers1

-1

You need to pass only the hash and not the entire magnet link to the TorrentManager constructor.

A magnet link looks like this:

magnet:?xt=urn:btih:18981bc9759950b4715ad46adcaf514e6a773cfe

So, a more generalized form:

magnet:?xt=urn:btih:<hash>

You need to extract this <hash> and pass it to the constructor:

manager = new TorrentManager(InfoHash.FromHex(hash), downloadsPath, torrentDefaults, downloadsPathForTorrent, new List<List<string>>());
Fᴀʀʜᴀɴ Aɴᴀᴍ
  • 6,131
  • 5
  • 31
  • 52
  • That constructor doesn't exist... the one that is more close to this is with an addicional List>() in the end, but it still doesn't do nothing... i've updated the code with what i tried to do – Gabriel Duarte Dec 21 '15 at 21:18
  • That constructor doesn't exists for me... It just have 4 of them, which are: public TorrentManager(Torrent torrent, string savePath, TorrentSettings settings); public TorrentManager(MagnetLink magnetLink, string savePath, TorrentSettings settings, string torrentSave); public TorrentManager(Torrent torrent, string savePath, TorrentSettings settings, string baseDirectory); public TorrentManager(InfoHash infoHash, string savePath, TorrentSettings settings, string torrentSave, List> announces); – Gabriel Duarte Dec 21 '15 at 21:27
  • @GabrielDuarte I closed the parenthesis before it was to be closed. now see it. and whatever list/collection it says, just initialize it an pass it to the constructor. – Fᴀʀʜᴀɴ Aɴᴀᴍ Dec 21 '15 at 21:29
  • @GabrielDuarte Ok, so now please see the latest edit. It should work :/ – Fᴀʀʜᴀɴ Aɴᴀᴍ Dec 21 '15 at 21:30
  • but i've already tried the exact same constructor in my first attempt that i've put as an edit to the question and it didn't work... Am i doing it right? do i have to start anything or just create the object like you put in the answear? – Gabriel Duarte Dec 21 '15 at 21:34