Esempio n. 1
0
        public virtual bool DownloadReport(EpisodeParseResult parseResult)
        {
            var downloadTitle = GetDownloadTitle(parseResult);

            var provider = GetActiveDownloadClient();

            bool success = provider.DownloadNzb(parseResult.NzbUrl, GetDownloadTitle(parseResult));

            if (success)
            {
                logger.Trace("Download added to Queue: {0}", downloadTitle);


                foreach (var episode in _episodeProvider.GetEpisodesByParseResult(parseResult))
                {
                    var history = new History();
                    history.Date = DateTime.Now;
                    history.Indexer = parseResult.Indexer;
                    history.IsProper = parseResult.Quality.Proper;
                    history.Quality = parseResult.Quality.QualityType;
                    history.NzbTitle = parseResult.OriginalString;
                    history.EpisodeId = episode.EpisodeId;
                    history.SeriesId = episode.SeriesId;

                    _historyProvider.Add(history);
                    _episodeProvider.MarkEpisodeAsFetched(episode.EpisodeId);

                    _signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Downloading);
                }

                _externalNotificationProvider.OnGrab(downloadTitle);
            }

            return success;
        }
Esempio n. 2
0
        public virtual bool DownloadReport(EpisodeParseResult parseResult)
        {
            var downloadTitle = GetDownloadTitle(parseResult);
            var provider = GetActiveDownloadClient();
            var recentEpisode = CheckIfRecentEpisode(parseResult);

            bool success = provider.DownloadNzb(parseResult.NzbUrl, downloadTitle, recentEpisode);

            if (success)
            {
                logger.Trace("Download added to Queue: {0}", downloadTitle);

                foreach (var episode in parseResult.Episodes)
                {
                    var history = new History
                                      {
                                            Date = DateTime.Now,
                                            Indexer = parseResult.Indexer,
                                            IsProper = parseResult.Quality.Proper,
                                            Quality = parseResult.Quality.Quality,
                                            NzbTitle = parseResult.OriginalString,
                                            EpisodeId = episode.EpisodeId,
                                            SeriesId = episode.SeriesId,
                                            NzbInfoUrl = parseResult.NzbInfoUrl,
                                            ReleaseGroup = parseResult.ReleaseGroup,
                                      };

                    _historyProvider.Add(history);
                    _episodeProvider.MarkEpisodeAsFetched(episode.EpisodeId);

                    _signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Downloading, null);
                }

                _externalNotificationProvider.OnGrab(downloadTitle);
            }

            return success;
        }
Esempio n. 3
0
 public virtual void Add(History item)
 {
     _database.Insert(item);
     logger.Debug("Item added to history: {0}", item.NzbTitle);
 }
        public void add_item()
        {
            WithRealDb();

            var episode = Builder<Episode>.CreateNew().Build();

            QualityTypes quality = QualityTypes.HDTV720p;
            const bool proper = true;

            var history = new History
                              {
                                  Date = DateTime.Now,
                                  EpisodeId = episode.EpisodeId,
                                  SeriesId = episode.SeriesId,
                                  NzbTitle = "my title",
                                  Indexer = "Fake Indexer",
                                  Quality = quality,
                                  IsProper = proper
                              };

            //Act
            Mocker.Resolve<HistoryProvider>().Add(history);

            //Assert
            var storedHistory = Db.Fetch<History>();

            storedHistory.Should().HaveCount(1);
            history.Date.Should().BeWithin(TimeSpan.FromMinutes(1)).Before(storedHistory.First().Date);

            history.EpisodeId.Should().Be(storedHistory.First().EpisodeId);
            history.SeriesId.Should().Be(storedHistory.First().SeriesId);
            history.NzbTitle.Should().Be(storedHistory.First().NzbTitle);
            history.Indexer.Should().Be(storedHistory.First().Indexer);
            history.Quality.Should().Be(storedHistory.First().Quality);
            history.IsProper.Should().Be(storedHistory.First().IsProper);
        }