public void Setup() { _series = Builder<Series> .CreateNew() .With(s => s.Title = "Hawaii Five-0") .Build(); }
public void Setup() { _series = Builder<Series> .CreateNew() .Build(); _episode = Builder<Episode> .CreateNew() .With(e => e.SeriesId = _series.SeriesId) .With(e => e.Series = _series) .Build(); _episodes = Builder<Episode> .CreateListOfSize(10) .All() .With(e => e.SeriesId = _series.SeriesId) .With(e => e.Series = _series) .Build() .ToList(); _parseResults = Builder<EpisodeParseResult> .CreateListOfSize(10) .Build(); _indexer1 = new Mock<IndexerBase>(); _indexer2 = new Mock<IndexerBase>(); _indexers = new List<IndexerBase> { _indexer1.Object, _indexer2.Object }; Mocker.GetMock<IndexerProvider>() .Setup(c => c.GetEnabledIndexers()) .Returns(_indexers); }
public EpisodeFile MapIt(EpisodeFile episodeFile, Series series, Episode episode) { // Terminating call. Since we can return null from this function // we need to be ready for PetaPoco to callback later with null // parameters if (episodeFile == null) return _current; // Is this the same EpisodeFile as the current one we're processing if (_current != null && _current.EpisodeFileId == episodeFile.EpisodeFileId) { // Yes, just add this post to the current EpisodeFiles's collection of Episodes _current.Episodes.Add(episode); // Return null to indicate we're not done with this EpisodeFiles yet return null; } // This is a different EpisodeFile to the current one, or this is the // first time through and we don't have an EpisodeFile yet // Save the current EpisodeFile var prev = _current; // Setup the new current EpisodeFile _current = episodeFile; _current.Episodes = new List<Episode>(); _current.Episodes.Add(episode); _current.Series = series; // Return the now populated previous EpisodeFile (or null if first time through) return prev; }
protected override void FinalizeSearch(Series series, dynamic options, Boolean reportsFound, ProgressNotification notification) { logger.Warn("Unable to find {0} in any of indexers.", options.Episode); notification.CurrentMessage = reportsFound ? String.Format("Sorry, couldn't find {0}, that matches your preferences.", options.Episode.AirDate) : String.Format("Sorry, couldn't find {0} in any of indexers.", options.Episode); }
public void Setup() { WithRealDb(); episodes = Builder<Episode>.CreateListOfSize(6) .All() .With(e => e.SeriesId = 1) .With(e => e.Ignored = false) .TheFirst(1) .With(e => e.AirDate = DateTime.Today.AddDays(-1)) .TheNext(1) .With(e => e.AirDate = DateTime.Today) .TheNext(1) .With(e => e.AirDate = DateTime.Today.AddDays(1)) .TheNext(1) .With(e => e.AirDate = DateTime.Today.AddDays(2)) .TheNext(1) .With(e => e.AirDate = DateTime.Today.AddDays(7)) .TheNext(1) .With(e => e.AirDate = DateTime.Today.AddDays(9)) .Build(); series = Builder<Series>.CreateNew() .With(s => s.SeriesId = 1) .And(c => c.Monitored = true) .Build(); Db.InsertMany(episodes); Db.Insert(series); }
public override List<EpisodeParseResult> PerformSearch(Series series, dynamic options, ProgressNotification notification) { if (options.Episode == null) throw new ArgumentException("Episode is invalid"); notification.CurrentMessage = "Looking for " + options.Episode; var reports = new List<EpisodeParseResult>(); var title = GetSearchTitle(series); Parallel.ForEach(_indexerProvider.GetEnabledIndexers(), indexer => { try { reports.AddRange(indexer.FetchDailyEpisode(title, options.Episode.AirDate)); } catch (Exception e) { logger.ErrorException(String.Format("An error has occurred while searching for {0} - {1:yyyy-MM-dd} from: {2}", series.Title, options.Episode.AirDate, indexer.Name), e); } }); return reports; }
public virtual List<Int32> Search(Series series, dynamic options, ProgressNotification notification) { if (options == null) throw new ArgumentNullException(options); var searchResult = new SearchHistory { SearchTime = DateTime.Now, SeriesId = series.SeriesId, EpisodeId = options.GetType().GetProperty("Episode") != null ? options.Episode.EpisodeId : null, SeasonNumber = options.GetType().GetProperty("SeasonNumber") != null ? options.SeasonNumber : null }; List<EpisodeParseResult> reports = PerformSearch(series, options, notification); logger.Debug("Finished searching all indexers. Total {0}", reports.Count); notification.CurrentMessage = "Processing search results"; ProcessReports(series, options, reports, searchResult, notification); _searchHistoryProvider.Add(searchResult); if(searchResult.Successes.Any()) return searchResult.Successes; FinalizeSearch(series, options, reports.Any(), notification); return new List<Int32>(); }
public void Setup() { _series = Builder<Series> .CreateNew() .With(s => s.Title = "South Park") .Build(); }
private void RefreshMetadata(ProgressNotification notification, Series series) { notification.CurrentMessage = String.Format("Refreshing episode metadata for '{0}'", series.Title); Logger.Debug("Getting episodes from database for series: {0}", series.SeriesId); var episodeFiles = _mediaFileProvider.GetSeriesFiles(series.SeriesId); if (episodeFiles == null || episodeFiles.Count == 0) { Logger.Warn("No episodes in database found for series: {0}", series.SeriesId); return; } try { _metadataProvider.CreateForEpisodeFiles(episodeFiles.ToList()); } catch (Exception e) { Logger.WarnException("An error has occurred while refreshing episode metadata", e); } notification.CurrentMessage = String.Format("Epsiode metadata refresh completed for {0}", series.Title); }
public void Setup() { _series = Builder<Series> .CreateNew() .With(s => s.IsDaily = false) .Build(); }
public void Setup() { _customStartDateSpecification = Mocker.Resolve<CustomStartDateSpecification>(); firstEpisode = new Episode { AirDate = DateTime.Today }; secondEpisode = new Episode { AirDate = DateTime.Today }; fakeSeries = Builder<Series>.CreateNew() .With(c => c.Monitored = true) .With(c => c.CustomStartDate = null) .Build(); parseResultMulti = new EpisodeParseResult { SeriesTitle = "Title", Series = fakeSeries, EpisodeNumbers = new List<int> { 3, 4 }, SeasonNumber = 12, Episodes = new List<Episode> { firstEpisode, secondEpisode } }; parseResultSingle = new EpisodeParseResult { SeriesTitle = "Title", Series = fakeSeries, EpisodeNumbers = new List<int> { 3 }, SeasonNumber = 12, Episodes = new List<Episode> { firstEpisode } }; }
public void Setup() { fakeSeries = Builder<Series>.CreateNew().Build(); fakeDailySeries = Builder<Series>.CreateNew() .With(c => c.IsDaily = true) .Build(); fakeEpisode = Builder<Episode>.CreateNew() .With(e => e.SeriesId = fakeSeries.SeriesId) .With(e => e.Title = "Episode (1)") .Build(); fakeEpisode2 = Builder<Episode>.CreateNew() .With(e => e.SeriesId = fakeSeries.SeriesId) .With(e => e.SeasonNumber = fakeEpisode.SeasonNumber) .With(e => e.EpisodeNumber = fakeEpisode.EpisodeNumber + 1) .With(e => e.Title = "Episode (2)") .Build(); fakeDailyEpisode = Builder<Episode>.CreateNew() .With(e => e.SeriesId = fakeSeries.SeriesId) .With(e => e.AirDate = DateTime.Now.Date) .With(e => e.Title = "Daily Episode 1") .Build(); WithRealDb(); episodeProvider = Mocker.Resolve<EpisodeProvider>(); }
public void Setup() { _series = Builder<Series> .CreateNew() .With(s => s.Title = "Scandal (2012)") .Build(); }
public override void OnDownload(string message, Series series) { if (_configProvider.TwitterNotifyOnDownload) { _logger.Trace("Sending Notification to Twitter (On Grab)"); _twitterProvider.SendTweet("Download Completed: " + message); } }
public virtual void Update(Series series) { //Use Json for Eden/Nightly or depricated HTTP for 10.x (Dharma) to get the proper path //Perform update with EventServer (Json currently doesn't support updating a specific path only - July 2011) var username = _configProvider.XbmcUsername; var password = _configProvider.XbmcPassword; foreach (var host in _configProvider.XbmcHosts.Split(',')) { Logger.Trace("Determining version of XBMC Host: {0}", host); var version = GetJsonVersion(host, username, password); //If Dharma if (version == 2) { //Check for active player only when we should skip updates when playing if (!_configProvider.XbmcUpdateWhenPlaying) { Logger.Trace("Determining if there are any active players on XBMC host: {0}", host); var activePlayers = GetActivePlayersDharma(host, username, password); //If video is currently playing, then skip update if(activePlayers["video"]) { Logger.Debug("Video is currently playing, skipping library update"); continue; } } UpdateWithHttp(series, host, username, password); } //If Eden or newer (attempting to make it future compatible) else if (version >= 3) { //Check for active player only when we should skip updates when playing if (!_configProvider.XbmcUpdateWhenPlaying) { Logger.Trace("Determining if there are any active players on XBMC host: {0}", host); var activePlayers = GetActivePlayersEden(host, username, password); //If video is currently playing, then skip update if(activePlayers.Any(a => a.Type.Equals("video"))) { Logger.Debug("Video is currently playing, skipping library update"); continue; } } UpdateWithJson(series, host, username, password); } //Log Version zero if check failed else Logger.Trace("Unknown version: [{0}], skipping.", version); } }
public void Setup() { WithTempAsAppPath(); series = Builder<Series> .CreateNew() .With(s => s.SeriesId == 79488) .With(s => s.Title == "30 Rock") .Build(); episodeFile = Builder<EpisodeFile>.CreateNew() .With(f => f.SeriesId = 79488) .With(f => f.SeasonNumber = 1) .With(f => f.Path = @"C:\Test\30 Rock\Season 01\30 Rock - S01E01 - Pilot.avi") .Build(); var tvdbEpisodes = Builder<TvdbEpisode>.CreateListOfSize(2) .All() .With(e => e.SeriesId = 79488) .With(e => e.SeasonNumber = 1) .With(e => e.Directors = new List<string>{ "Fake Director" }) .With(e => e.Writer = new List<string>{ "Fake Writer" }) .With(e => e.GuestStars = new List<string> { "Guest Star 1", "Guest Star 2", "Guest Star 3", "" }) .Build(); var seasonBanners = Builder<TvdbSeasonBanner> .CreateListOfSize(4) .TheFirst(2) .With(b => b.Season = 1) .TheLast(2) .With(b => b.Season = 2) .TheFirst(1) .With(b => b.BannerType = TvdbSeasonBanner.Type.season) .With(b => b.BannerPath = "seasons/79488-1-1.jpg") .TheNext(2) .With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide) .With(b => b.BannerPath = "banners/seasons/79488-test.jpg") .TheLast(1) .With(b => b.BannerType = TvdbSeasonBanner.Type.season) .With(b => b.BannerPath = "seasons/79488-2-1.jpg") .Build(); var seriesActors = Builder<TvdbActor> .CreateListOfSize(5) .All() .With(a => a.ActorImage = Builder<TvdbActorBanner>.CreateNew().Build()) .Build(); tvdbSeries = Builder<TvdbSeries> .CreateNew() .With(s => s.Id = 79488) .With(s => s.SeriesName = "30 Rock") .With(s => s.TvdbActors = seriesActors.ToList()) .With(s => s.Episodes = tvdbEpisodes.ToList()) .Build(); tvdbSeries.Banners.AddRange(seasonBanners); }
public void Setup() { WithRealDb(); _series = Builder<Series> .CreateNew() .Build(); Db.Insert(_series); }
public virtual void DownloadBanner(ProgressNotification notification, Series series) { notification.CurrentMessage = string.Format("Downloading banner for '{0}'", series.Title); if (_bannerProvider.Download(series)) notification.CurrentMessage = string.Format("Successfully download banner for '{0}'", series.Title); else notification.CurrentMessage = string.Format("Failed to download banner for '{0}'", series.Title); }
public override void OnDownload(string message, Series series) { const string subject = "NzbDrone [TV] - Downloaded"; var body = String.Format("{0} Downloaded and sorted.", message); if (_configProvider.SmtpNotifyOnDownload) { _logger.Trace("Sending SMTP Notification"); _smtpProvider.SendEmail(subject, body); } }
public override void OnDownload(string message, Series series) { const string header = "NzbDrone [TV] - Downloaded"; if (_configProvider.XbmcNotifyOnDownload) { _logger.Trace("Sending Notification to XBMC"); _xbmcProvider.Notify(header, message); } UpdateAndClean(series); }
public void Setup() { WithTempAsAppPath(); _series = Builder<Series>.CreateNew() .With(s => s.SeriesId = 12345) .Build(); var path = @"C:\Windows\Temp"; Mocker.GetMock<DiskProvider>().Setup(s => s.CreateDirectory(path)); }
public void setup() { _matchingSeries = Builder<Series>.CreateNew() .With(s => s.SeriesId = 79488) .With(s => s.Title = "30 Rock") .Build(); _mismatchedSeries = Builder<Series>.CreateNew() .With(s => s.SeriesId = 12345) .With(s => s.Title = "Not 30 Rock") .Build(); }
public override void OnDownload(string message, Series series) { const string header = "NzbDrone [TV] - Downloaded"; if (_configProvider.PlexNotifyOnDownload) { _logger.Trace("Sending Notification to Plex Clients"); _plexProvider.Notify(header, message); } UpdateIfEnabled(); }
public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult, SearchHistoryItem item) { if(options.SeasonNumber != episodeParseResult.SeasonNumber) { logger.Trace("Season number does not match searched season number, skipping."); item.SearchError = ReportRejectionType.WrongSeason; return item; } return item; }
private void UpdateAndClean(Series series) { if (_configProvider.XbmcUpdateLibrary) { _logger.Trace("Sending Update Request to XBMC"); _xbmcProvider.Update(series); } if (_configProvider.XbmcCleanLibrary) { _logger.Trace("Sending Clean DB Request to XBMC"); _xbmcProvider.Clean(); } }
public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult, SearchHistoryItem item) { Episode episode = options.Episode; if (!episodeParseResult.AirDate.HasValue || episodeParseResult.AirDate.Value != episode.AirDate.Value) { logger.Trace("Episode AirDate does not match searched episode number, skipping."); item.SearchError = ReportRejectionType.WrongEpisode; return item; } return item; }
public override List<EpisodeParseResult> PerformSearch(Series series, dynamic options, ProgressNotification notification) { if (options.SeasonNumber == null || options.SeasonNumber < 0) throw new ArgumentException("SeasonNumber is invalid"); if (options.Episodes == null) throw new ArgumentException("Episodes were not provided"); List<Episode> episodes = options.Episodes; if (!episodes.Any()) throw new ArgumentException("Episodes were not provided"); notification.CurrentMessage = String.Format("Looking for {0} - Season {1}", series.Title, options.SeasonNumber); var reports = new List<EpisodeParseResult>(); object reportsLock = new object(); var title = GetSearchTitle(series); var prefixes = GetEpisodeNumberPrefixes(episodes.Select(e => e.EpisodeNumber)); foreach(var p in prefixes) { var prefix = p; Parallel.ForEach(_indexerProvider.GetEnabledIndexers(), indexer => { try { lock(reportsLock) { reports.AddRange(indexer.FetchPartialSeason(title, options.SeasonNumber, prefix)); } } catch(Exception e) { logger.ErrorException( String.Format( "An error has occurred while searching for {0} Season {1:00} Prefix: {2} from: {3}", series.Title, options.SeasonNumber, prefix, indexer.Name), e); } }); } return reports; }
public virtual FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extention) { string path = series.Path; if (series.SeasonFolder) { var seasonFolder = _configProvider.SortingSeasonFolderFormat .Replace("%0s", seasonNumber.ToString("00")) .Replace("%s", seasonNumber.ToString()); path = Path.Combine(path, seasonFolder); } path = Path.Combine(path, fileName + extention); return new FileInfo(path); }
public TvRageSearchResult ProcessResults(IList<TvRageSearchResult> searchResults, Series series, string sceneCleanName, Episode firstEpisode) { foreach (var result in searchResults) { if (Parser.NormalizeTitle(result.Name).Equals(series.CleanTitle)) return result; if (!String.IsNullOrWhiteSpace(sceneCleanName) && Parser.NormalizeTitle(result.Name).Equals(sceneCleanName)) return result; if (firstEpisode.AirDate.HasValue && result.Started == firstEpisode.AirDate.Value) return result; } return null; }
public void Setup() { _searchResults = Builder<TvRageSearchResult> .CreateListOfSize(5) .Build(); _series = Builder<Series> .CreateNew() .With(s => s.FirstAired = DateTime.Today.AddDays(-180)) .Build(); _episode = Builder<Episode> .CreateNew() .With(e => e.AirDate = DateTime.Today.AddDays(-365)) .Build(); }