예제 #1
0
        private static string GetRealLocation(RpcEntity.TorrentInfo torrentInfo)
        {
            var pathSeperator = torrentInfo.DownloadDir.Contains('/')
                ? "/"
                : "\\";

            return(torrentInfo.Files.Length > 1
                ? torrentInfo.DownloadDir + pathSeperator + torrentInfo.Name
                : torrentInfo.DownloadDir);
        }
예제 #2
0
 internal static Shared.TorrentClient.Torrent ToSharedModel(this RpcEntity.TorrentInfo torrentInfo)
 {
     return(new Shared.TorrentClient.Torrent
     {
         ID = torrentInfo.ID,
         Name = torrentInfo.Name,
         SizeInBytes = torrentInfo.TotalSize,
         BytesOnDisk = torrentInfo.TotalSize - torrentInfo.LeftUntilDone,
         InfoHash = torrentInfo.HashString,
         Location = GetRealLocation(torrentInfo),
         TotalUploadInBytes = torrentInfo.UploadedEver,
         TrackerUrls = torrentInfo.Trackers
                       .Select(t => new Uri(t.announce).Authority)
                       .ToList(),
         AddedDateTime = DateTimeOffset.FromUnixTimeSeconds(torrentInfo.AddedDate).UtcDateTime,
         Files = torrentInfo.Files.ToSharedModel()
     });
 }