public void FillInfo(TorrentInfo torrent)
        {
            string torrentInfo = _transmissionRemoteWrapper.ExecuteCommand(string.Format("-t {0} -i", torrent.Id));

            foreach (string line in torrentInfo.Split(new [] { Environment.NewLine }, StringSplitOptions.None))
            {
                string attribute = line.Trim();
                if (attribute.StartsWith("Location:"))
                {
                    torrent.Location = attribute.Replace("Location: ", string.Empty);
                }
            }
            _logger.DebugFormat("Obtained the information of the torrent \"{0}\".", torrent.FileName);
        }
        public bool Remove(TorrentInfo torrent)
        {
            string output = _transmissionRemoteWrapper.ExecuteCommand(string.Format("-t {0} -r", torrent.Id));
            bool   ret    = output.TrimEnd().EndsWith("responded: \"success\"");

            if (!ret)
            {
                _logger.ErrorFormat("The torrent \"{0}\" cannot be removed: {1}.", torrent.FileName, output);
            }
            else
            {
                _logger.DebugFormat("The torrent \"{0}\" has been removed properly.", torrent.FileName);
            }
            return(ret);
        }
예제 #3
0
        public List <TorrentInfo> GetTorrents()
        {
            List <TorrentInfo> ret    = new List <TorrentInfo> ();
            string             output = _transmissionRemoteWrapper.ExecuteCommand("-l");

            string[] outputLines = output.Split(new [] { Environment.NewLine }, StringSplitOptions.None);
            if (outputLines[0].StartsWith("ID"))
            {
                for (int line = 1; line < outputLines.Length - 2; line++)
                {
                    ret.Add(parseTorrentInfo(outputLines [line]));
                }
            }
            return(ret);
        }