public void Handle(DownloadIgnoredEvent message) { var historyToAdd = new List <EpisodeHistory>(); foreach (var episodeId in message.EpisodeIds) { var history = new EpisodeHistory { EventType = EpisodeHistoryEventType.DownloadIgnored, Date = DateTime.UtcNow, Quality = message.Quality, SourceTitle = message.SourceTitle, SeriesId = message.SeriesId, EpisodeId = episodeId, DownloadId = message.DownloadId, Language = message.Language }; history.Data.Add("DownloadClient", message.DownloadClientInfo.Type); history.Data.Add("DownloadClientName", message.DownloadClientInfo.Name); history.Data.Add("Message", message.Message); historyToAdd.Add(history); } _historyRepository.InsertMany(historyToAdd); }
public void Handle(EpisodeFileRenamedEvent message) { var sourcePath = message.OriginalPath; var sourceRelativePath = message.Series.Path.GetRelativePath(message.OriginalPath); var path = Path.Combine(message.Series.Path, message.EpisodeFile.RelativePath); var relativePath = message.EpisodeFile.RelativePath; foreach (var episode in message.EpisodeFile.Episodes.Value) { var history = new EpisodeHistory { EventType = EpisodeHistoryEventType.EpisodeFileRenamed, Date = DateTime.UtcNow, Quality = message.EpisodeFile.Quality, SourceTitle = message.OriginalPath, SeriesId = message.EpisodeFile.SeriesId, EpisodeId = episode.Id, Language = message.EpisodeFile.Language }; history.Data.Add("SourcePath", sourcePath); history.Data.Add("SourceRelativePath", sourceRelativePath); history.Data.Add("Path", path); history.Data.Add("RelativePath", relativePath); _historyRepository.Insert(history); } }
public void Handle(EpisodeFileDeletedEvent message) { if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes) { _logger.Debug("Removing episode file from DB as part of cleanup routine, not creating history event."); return; } else if (message.Reason == DeleteMediaFileReason.ManualOverride) { _logger.Debug("Removing episode file from DB as part of manual override of existing file, not creating history event."); return; } foreach (var episode in message.EpisodeFile.Episodes.Value) { var history = new EpisodeHistory { EventType = EpisodeHistoryEventType.EpisodeFileDeleted, Date = DateTime.UtcNow, Quality = message.EpisodeFile.Quality, SourceTitle = message.EpisodeFile.Path, SeriesId = message.EpisodeFile.SeriesId, EpisodeId = episode.Id, Language = message.EpisodeFile.Language }; history.Data.Add("Reason", message.Reason.ToString()); _historyRepository.Insert(history); } }
public void Handle(EpisodeGrabbedEvent message) { foreach (var episode in message.Episode.Episodes) { var history = new EpisodeHistory { EventType = EpisodeHistoryEventType.Grabbed, Date = DateTime.UtcNow, Quality = message.Episode.ParsedEpisodeInfo.Quality, SourceTitle = message.Episode.Release.Title, SeriesId = episode.SeriesId, EpisodeId = episode.Id, DownloadId = message.DownloadId, Language = message.Episode.ParsedEpisodeInfo.Language, }; history.Data.Add("Indexer", message.Episode.Release.Indexer); history.Data.Add("NzbInfoUrl", message.Episode.Release.InfoUrl); history.Data.Add("ReleaseGroup", message.Episode.ParsedEpisodeInfo.ReleaseGroup); history.Data.Add("Age", message.Episode.Release.Age.ToString()); history.Data.Add("AgeHours", message.Episode.Release.AgeHours.ToString()); history.Data.Add("AgeMinutes", message.Episode.Release.AgeMinutes.ToString()); history.Data.Add("PublishedDate", message.Episode.Release.PublishDate.ToString("s") + "Z"); history.Data.Add("DownloadClient", message.DownloadClient); history.Data.Add("DownloadClientName", message.DownloadClientName); history.Data.Add("Size", message.Episode.Release.Size.ToString()); history.Data.Add("DownloadUrl", message.Episode.Release.DownloadUrl); history.Data.Add("Guid", message.Episode.Release.Guid); history.Data.Add("TvdbId", message.Episode.Release.TvdbId.ToString()); history.Data.Add("TvRageId", message.Episode.Release.TvRageId.ToString()); history.Data.Add("Protocol", ((int)message.Episode.Release.DownloadProtocol).ToString()); history.Data.Add("PreferredWordScore", message.Episode.PreferredWordScore.ToString()); history.Data.Add("SeriesMatchType", message.Episode.SeriesMatchType.ToString()); if (!message.Episode.ParsedEpisodeInfo.ReleaseHash.IsNullOrWhiteSpace()) { history.Data.Add("ReleaseHash", message.Episode.ParsedEpisodeInfo.ReleaseHash); } var torrentRelease = message.Episode.Release as TorrentInfo; if (torrentRelease != null) { history.Data.Add("TorrentInfoHash", torrentRelease.InfoHash); } _historyRepository.Insert(history); } }
public void Handle(EpisodeImportedEvent message) { if (!message.NewDownload) { return; } var downloadId = message.DownloadId; if (downloadId.IsNullOrWhiteSpace()) { downloadId = FindDownloadId(message); } foreach (var episode in message.EpisodeInfo.Episodes) { var history = new EpisodeHistory { EventType = EpisodeHistoryEventType.DownloadFolderImported, Date = DateTime.UtcNow, Quality = message.EpisodeInfo.Quality, SourceTitle = message.ImportedEpisode.SceneName ?? Path.GetFileNameWithoutExtension(message.EpisodeInfo.Path), SeriesId = message.ImportedEpisode.SeriesId, EpisodeId = episode.Id, DownloadId = downloadId, Language = message.EpisodeInfo.Language }; history.Data.Add("FileId", message.ImportedEpisode.Id.ToString()); history.Data.Add("DroppedPath", message.EpisodeInfo.Path); history.Data.Add("ImportedPath", Path.Combine(message.EpisodeInfo.Series.Path, message.ImportedEpisode.RelativePath)); history.Data.Add("DownloadClient", message.DownloadClientInfo?.Type); history.Data.Add("DownloadClientName", message.DownloadClientInfo?.Name); history.Data.Add("PreferredWordScore", message.EpisodeInfo.PreferredWordScore.ToString()); history.Data.Add("ReleaseGroup", message.EpisodeInfo.ReleaseGroup); _historyRepository.Insert(history); } }
public void Handle(DownloadFailedEvent message) { foreach (var episodeId in message.EpisodeIds) { var history = new EpisodeHistory { EventType = EpisodeHistoryEventType.DownloadFailed, Date = DateTime.UtcNow, Quality = message.Quality, SourceTitle = message.SourceTitle, SeriesId = message.SeriesId, EpisodeId = episodeId, DownloadId = message.DownloadId, Language = message.Language }; history.Data.Add("DownloadClient", message.DownloadClient); history.Data.Add("DownloadClientName", message.TrackedDownload?.DownloadItem.DownloadClientInfo.Name); history.Data.Add("Message", message.Message); _historyRepository.Insert(history); } }