1

I have a magnetic link to a torrent. So I add the torrent to uTorrent using AddUrl method:

using(var client = new UTorrentClient(apiurl, userName, password))
     client.Torrents.AddUrl(magneticLink, savePath);

But I want to assign a specific label for this torrent. There are no overloads for AddUrl method that take label as an argument. Or how can I find the torrent by magnetic link afterwards? UtorrentApi.Torrent object does not store used magnetic link.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Dmytro
  • 16,668
  • 27
  • 80
  • 130

1 Answers1

0

I'd suggest you to use this uTorrent api for .NET. It's more fresh and has a nuget package even (naed UTorrentClientApi). Unfortunately I cannot test myself at this moment if the code below works, but here is a little snippet of how you might do what you want with that library. First it seems that you need to execute "setprops" action, but this library does not know about it. However, it's somewhat extensible, so first implement custom request class which does not check actions:

class MyRequest : Request {
    protected override bool CheckAction(UrlAction action) {
        return true;
    }
}

Then you can try:

var client = new UTorrentClient(IPAddress.Loopback, 80, "user", "password");
var torrent = client.AddUrlTorrent("your magent link").AddedTorrent;
var request = new MyRequest();
request.SetAction(UrlAction.Create("SETPROPS"));            
request.SetTorrentHash(torrent.Hash);
request.SetSetting("label", "your label");
client.ProcessRequest(request);

Note that I did not test this code (not even ran it), but maybe it will still help you.

Evk
  • 98,527
  • 8
  • 141
  • 191