示例#1
0
        public async Task <TorrentProperties> TorrentProperties(String hash)
        {
            var savePath = await AppDefaultSavePath();

            var torrent = await _torrents.GetByHash(hash);

            if (torrent == null)
            {
                return(null);
            }

            var result = new TorrentProperties
            {
                AdditionDate           = torrent.RdAdded.ToUnixTimeSeconds(),
                Comment                = "RealDebridClient <https://github.com/rogerfar/rdt-client>",
                CompletionDate         = torrent.RdEnded?.ToUnixTimeSeconds() ?? -1,
                CreatedBy              = "RealDebridClient <https://github.com/rogerfar/rdt-client>",
                CreationDate           = torrent.RdAdded.ToUnixTimeSeconds(),
                DlLimit                = -1,
                DlSpeed                = torrent.RdSpeed ?? 0,
                DlSpeedAvg             = torrent.RdSpeed ?? 0,
                Eta                    = 0,
                LastSeen               = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                NbConnections          = 0,
                NbConnectionsLimit     = 100,
                Peers                  = 0,
                PeersTotal             = 2,
                PieceSize              = torrent.Files.Count > 0 ? torrent.RdSize / torrent.Files.Count : 0,
                PiecesHave             = torrent.Downloads.Count(m => m.Status == DownloadStatus.Finished),
                PiecesNum              = torrent.Files.Count,
                Reannounce             = 0,
                SavePath               = savePath,
                SeedingTime            = 1,
                Seeds                  = 100,
                SeedsTotal             = 100,
                ShareRatio             = 9999,
                TimeElapsed            = (Int64)(torrent.RdAdded - DateTimeOffset.UtcNow).TotalMinutes,
                TotalDownloaded        = (Int64)(torrent.RdSize * (torrent.RdProgress / 100.0)),
                TotalDownloadedSession = (Int64)(torrent.RdSize * (torrent.RdProgress / 100.0)),
                TotalSize              = torrent.RdSize,
                TotalUploaded          = (Int64)(torrent.RdSize * (torrent.RdProgress / 100.0)),
                TotalUploadedSession   = (Int64)(torrent.RdSize * (torrent.RdProgress / 100.0)),
                TotalWasted            = 0,
                UpLimit                = -1,
                UpSpeed                = torrent.RdSpeed ?? 0,
                UpSpeedAvg             = torrent.RdSpeed ?? 0
            };

            return(result);
        }
示例#2
0
        public async Task <IList <TorrentFileItem> > TorrentFileContents(String hash)
        {
            var results = new List <TorrentFileItem>();

            var torrent = await _torrents.GetByHash(hash);

            if (torrent == null)
            {
                return(null);
            }

            foreach (var file in torrent.Files)
            {
                var result = new TorrentFileItem();
                result.Name = file.Path;
                results.Add(result);
            }

            return(results);
        }