public void CheckNewTorrents() { LoadProviders(); LoadNotifiers(); HashSet <string> lastTorrents = ReadLastTorrents(); HashSet <string> providedTorrents = ReadTorrentsFromProviders(); HashSet <string> newTorrents = new HashSet <string>(); foreach (string torrent in providedTorrents) { if (!lastTorrents.Contains(torrent)) { newTorrents.Add(torrent); } } // Notify NotificationResult result = new NotificationResult(); result.providedTorrents = providedTorrents; result.newTorrents = newTorrents; foreach (INotifier notifier in notifiers) { try { notifier.NotifyCheckOk(result); }catch (Exception ex) { Console.WriteLine("Error notifying: " + ex.Message); } } }
public void NotifyCheckOk(NotificationResult result) { MailMessage mail = new MailMessage(from, to); mail.Subject = "Web Tracker"; mail.Body = "[" + result.newTorrents.Count + "] new torrents found"; client.EnableSsl = true; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = credentials; client.Send(mail); }
public void NotifyCheckOk(NotificationResult result) { WriteTorrentsToFile(providedFile, result.providedTorrents); WriteTorrentsToFile(newsFile, result.newTorrents); }