示例#1
0
        protected string GetMessage(DownloadStationTask task)
        {
            if (task.StatusExtra != null)
            {
                if (task.Status == DownloadStationTaskStatus.Extracting)
                {
                    return($"Extracting: {int.Parse(task.StatusExtra["unzip_progress"])}%");
                }

                if (task.Status == DownloadStationTaskStatus.Error)
                {
                    return(task.StatusExtra["error_detail"]);
                }
            }

            return(null);
        }
        protected TimeSpan?GetRemainingTime(DownloadStationTask torrent)
        {
            var  speedString = torrent.Additional.Transfer["speed_download"];
            long downloadSpeed;

            if (speedString.IsNullOrWhiteSpace() || !long.TryParse(speedString, out downloadSpeed))
            {
                _logger.Debug("Torrent {0} has invalid speed_download: {1}", torrent.Title, speedString);
                downloadSpeed = 0;
            }

            if (downloadSpeed <= 0)
            {
                return(null);
            }

            var remainingSize = GetRemainingSize(torrent);

            return(TimeSpan.FromSeconds(remainingSize / downloadSpeed));
        }
示例#3
0
        protected DownloadItemStatus GetStatus(DownloadStationTask torrent)
        {
            switch (torrent.Status)
            {
            case DownloadStationTaskStatus.Waiting:
                return(torrent.Size == 0 || GetRemainingSize(torrent) > 0 ? DownloadItemStatus.Queued : DownloadItemStatus.Completed);

            case DownloadStationTaskStatus.Paused:
                return(DownloadItemStatus.Paused);

            case DownloadStationTaskStatus.Finished:
            case DownloadStationTaskStatus.Seeding:
                return(DownloadItemStatus.Completed);

            case DownloadStationTaskStatus.Error:
                return(DownloadItemStatus.Failed);
            }

            return(DownloadItemStatus.Downloading);
        }
 protected bool IsCompleted(DownloadStationTask torrent)
 {
     return(torrent.Status == DownloadStationTaskStatus.Seeding || IsFinished(torrent) || (torrent.Status == DownloadStationTaskStatus.Waiting && torrent.Size != 0 && GetRemainingSize(torrent) <= 0));
 }
 protected bool IsFinished(DownloadStationTask torrent)
 {
     return(torrent.Status == DownloadStationTaskStatus.Finished);
 }
 protected bool IsFinished(DownloadStationTask task)
 {
     return(task.Status == DownloadStationTaskStatus.Finished);
 }