Ejemplo n.º 1
0
        public void AddTorrents(IEnumerable <TorrentLink> torrents)
        {
            IEnumerable <TorrentLink> existings = this.Session.Load <TorrentLink>(torrents.Select(t => t.Id)).Where(t => t != null);

            if (existings == null || existings.Count() == 0)
            {
                existings = new List <TorrentLink>();
            }
            TorrentAnalyzer analyzer = new TorrentAnalyzer();

            foreach (var torrent in torrents)
            {
                analyzer.Analyze(torrent);
                var existing = existings.FirstOrDefault(t => t.Id == torrent.Id);
                if (existing != null)
                {
                    existing.Url         = torrent.Url;
                    existing.Files       = torrent.Files;
                    existing.SerieLinkId = torrent.SerieLinkId;
                    this.Session.Store(existing);
                }
                else
                {
                    this.Session.Store(torrent);
                }
            }
        }
Ejemplo n.º 2
0
        public void ShouldRetrieveFileInfos()
        {
            TorrentLink link = new TorrentLink
            {
                Url = "http://www.omgtorrent.com/torrents/Series/californication/californication_saison_1.torrent"
            };
            TorrentAnalyzer analyzer = new TorrentAnalyzer();

            analyzer.Analyze(link);

            Assert.NotNull(link.Files);
            Assert.NotEmpty(link.Files);
            Assert.True(link.Files.All(f => f.Episode != null));
        }