コード例 #1
0
        public TorrentInfo GetTorrentInfo(SSHClient sshClient, string torrentid)
        {
            string     command  = GetTorrentInfoCommand(torrentid);
            SshCommand response = sshClient.RunCommand(command);
            string     result   = response.Result;

            if (response.Result.StartsWith("Failed to connect"))
            {
                throw new Exception(response.Result);
            }
            TorrentInfo info = new TorrentInfo();

            foreach (string item in result.Split('\n'))
            {
                if (item.StartsWith("Name: "))
                {
                    info.Name = item.Substring(5).TrimStart();
                }
                else if (item.StartsWith("ID: "))
                {
                    info.ID = item.Substring(3).TrimStart();
                }
                else if (item.StartsWith("State: "))
                {
                    info.State = item.Substring(6).TrimStart();
                }
                else if (item.StartsWith("Size: "))
                {
                    info.Size = item.Substring(5).TrimStart();
                }
                else if (item.StartsWith("Seed time: "))
                {
                    info.SeedTime = item.Substring(10).TrimStart();
                }
                else if (item.StartsWith("Tracker status: "))
                {
                    info.TrackerStatus = item.Substring(15).TrimStart();
                }
                else if (item.StartsWith("Progress: "))
                {
                    info.Progress = item.Substring(9).TrimStart();
                }
                else if (item.StartsWith("Seeds: "))
                {
                    info.Seeds = item.Substring(6).TrimStart();
                }
            }
            return(info);
        }
コード例 #2
0
        public void AddTorrent(SSHClient sshClient, string saveLocation, string torrentPath)
        {
            string command = GetAddTorrentCommand(saveLocation, torrentPath);

            sshClient.RunCommand(command);
        }