internal void UpdateTorrent(UTorrentAPI.Torrent torrent) { if (torrent == null) { Status = TorrentStateStatus.NotFound; return; } _torrent = torrent; Status = TorrentStateStatus.Downloading; _file = FindFile(torrent); if (_file != null) { FilePath = _file.Path; if (_file.SizeInBytes == _file.DownloadedBytes) Status = TorrentStateStatus.Done; } }
private UTorrentAPI.File FindFile(UTorrentAPI.Torrent torrent) { var cn = Episode.EncodeName(_season, _number); return torrent.Files.Where(f => f.Path.IndexOf(cn, StringComparison.OrdinalIgnoreCase) >= 0).FirstOrDefault(); }