static void Main(string[] args) { LogFile log = new LogFile(); string torrentHash = args[0].ToString(); if (!string.IsNullOrEmpty(torrentHash)) { uTorrentAPI api = new uTorrentAPI(log, torrentHash); var label = api.GetLabel(); if (label == "sick" || label == "couchpotato") { api.StopTorrent(); var files = api.GetFiles(); var folder = api.GetFolder(); foreach (var f in files) { string sourceFile = System.IO.Path.Combine(folder, f); string destFile = System.IO.Path.Combine(Constants.basedir + @"\" + label, f); File.Move(sourceFile, destFile); } } else { log.Write("Do nothing (label: " + label + ")");//wrong label } } else { log.Write("hash parameter empty"); } log.Close(); }
public uTorrentAPI(LogFile log, string hash) { rest = new RestCommunicator(Constants.APIurl, "_utorrent"); rest.Authenticate(Constants.UserName, Constants.PassWord); _log = log; _hash = hash; _token = GetToken(); _torrents = GetTorrents(_hash, _token); }