From 7e38afc83857e4843cb9740747db9f9239146445 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 21 Feb 2012 20:43:19 -0800 Subject: [PATCH] Logging/Download notification tweaks. --- NzbDrone.Common/ReportingService.cs | 6 +- NzbDrone.Core.Test/EpisodeParseResultTest.cs | 134 ++++++++++++++++++ NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 1 + NzbDrone.Core/Jobs/RssSyncJob.cs | 2 + NzbDrone.Core/Model/EpisodeParseResult.cs | 24 ++-- NzbDrone.Core/Providers/EpisodeProvider.cs | 2 +- .../Providers/Indexer/IndexerBase.cs | 2 +- NzbDrone.Core/Providers/SearchProvider.cs | 5 +- NzbDrone.Web/Content/NzbDrone.css | 1 + 9 files changed, 159 insertions(+), 18 deletions(-) create mode 100644 NzbDrone.Core.Test/EpisodeParseResultTest.cs diff --git a/NzbDrone.Common/ReportingService.cs b/NzbDrone.Common/ReportingService.cs index dd0d8d2cb..0ab413e17 100644 --- a/NzbDrone.Common/ReportingService.cs +++ b/NzbDrone.Common/ReportingService.cs @@ -51,7 +51,7 @@ namespace NzbDrone.Common } e.Data.Add("title", title); - logger.ErrorException("Unable to report parse error", e); + logger.InfoException("Unable to report parse error", e); } } @@ -77,8 +77,8 @@ namespace NzbDrone.Common throw; } - //this shouldn't log an exception since it might cause a recursive loop. - logger.Error("Unable to report exception. " + e); + //this shouldn't log an exception since it will cause a recursive loop. + logger.Info("Unable to report exception. " + e); } } } diff --git a/NzbDrone.Core.Test/EpisodeParseResultTest.cs b/NzbDrone.Core.Test/EpisodeParseResultTest.cs new file mode 100644 index 000000000..a98b7526a --- /dev/null +++ b/NzbDrone.Core.Test/EpisodeParseResultTest.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Model; +using NzbDrone.Core.Repository.Quality; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test +{ + [TestFixture] + // ReSharper disable InconsistentNaming + public class EpisodeParseResultTest : CoreTest + { + [Test] + public void tostring_single_season_episode() + { + var parseResult = new EpisodeParseResult(); + parseResult.SeriesTitle = "My Series"; + parseResult.SeasonNumber = 12; + parseResult.EpisodeNumbers = new List { 3 }; + parseResult.FullSeason = false; + parseResult.AirDate = null; + parseResult.Quality = new Quality(QualityTypes.HDTV, false); + + + parseResult.ToString().Should().Be("My Series - S12E03 HDTV"); + } + + [Test] + public void tostring_single_season_episode_proper() + { + var parseResult = new EpisodeParseResult(); + parseResult.SeriesTitle = "My Series"; + parseResult.SeasonNumber = 12; + parseResult.EpisodeNumbers = new List { 3 }; + parseResult.FullSeason = false; + parseResult.AirDate = null; + parseResult.Quality = new Quality(QualityTypes.HDTV, true); + + + parseResult.ToString().Should().Be("My Series - S12E03 HDTV [proper]"); + } + + [Test] + public void tostring_multi_season_episode() + { + var parseResult = new EpisodeParseResult(); + parseResult.SeriesTitle = "My Series"; + parseResult.SeasonNumber = 12; + parseResult.EpisodeNumbers = new List { 3, 4, 5 }; + parseResult.FullSeason = false; + parseResult.AirDate = null; + parseResult.Quality = new Quality(QualityTypes.HDTV, false); + + + parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV"); + } + + [Test] + public void tostring_multi_season_episode_proper() + { + var parseResult = new EpisodeParseResult(); + parseResult.SeriesTitle = "My Series"; + parseResult.SeasonNumber = 12; + parseResult.EpisodeNumbers = new List { 3, 4, 5 }; + parseResult.FullSeason = false; + parseResult.AirDate = null; + parseResult.Quality = new Quality(QualityTypes.HDTV, true); + + + parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV [proper]"); + } + + + [Test] + public void tostring_full_season() + { + var parseResult = new EpisodeParseResult(); + parseResult.SeriesTitle = "My Series"; + parseResult.SeasonNumber = 12; + parseResult.FullSeason = true; + parseResult.AirDate = null; + parseResult.Quality = new Quality(QualityTypes.HDTV, false); + + + parseResult.ToString().Should().Be("My Series - Season 12 HDTV"); + } + + + [Test] + public void tostring_full_season_proper() + { + var parseResult = new EpisodeParseResult(); + parseResult.SeriesTitle = "My Series"; + parseResult.SeasonNumber = 12; + parseResult.FullSeason = true; + parseResult.AirDate = null; + parseResult.Quality = new Quality(QualityTypes.HDTV, true); + + + parseResult.ToString().Should().Be("My Series - Season 12 HDTV [proper]"); + } + + [Test] + public void tostring_daily_show() + { + var parseResult = new EpisodeParseResult(); + parseResult.SeriesTitle = "My Series"; + parseResult.SeasonNumber = 12; + parseResult.FullSeason = true; + parseResult.AirDate = new DateTime(2010, 12, 30); + parseResult.Quality = new Quality(QualityTypes.HDTV, false); + + + parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV"); + } + + [Test] + public void tostring_daily_show_proper() + { + var parseResult = new EpisodeParseResult(); + parseResult.SeriesTitle = "My Series"; + parseResult.SeasonNumber = 12; + parseResult.FullSeason = true; + parseResult.AirDate = new DateTime(2010, 12, 30); + parseResult.Quality = new Quality(QualityTypes.HDTV, true); + + + parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV [proper]"); + } + + } +} diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 9caa28c52..b1c461299 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -109,6 +109,7 @@ + diff --git a/NzbDrone.Core/Jobs/RssSyncJob.cs b/NzbDrone.Core/Jobs/RssSyncJob.cs index 630cda65e..fc10aafd5 100644 --- a/NzbDrone.Core/Jobs/RssSyncJob.cs +++ b/NzbDrone.Core/Jobs/RssSyncJob.cs @@ -84,6 +84,8 @@ namespace NzbDrone.Core.Jobs notification.CurrentMessage = "RSS Sync Completed"; + Logger.Info("RSS Sync completed"); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Model/EpisodeParseResult.cs b/NzbDrone.Core/Model/EpisodeParseResult.cs index 4ef644d38..b8375bef4 100644 --- a/NzbDrone.Core/Model/EpisodeParseResult.cs +++ b/NzbDrone.Core/Model/EpisodeParseResult.cs @@ -44,17 +44,23 @@ namespace NzbDrone.Core.Model public override string ToString() { + + string episodeString = "[Unknown Episode]"; + if (AirDate != null && EpisodeNumbers == null) - return string.Format("{0} - {1} {2}", SeriesTitle, AirDate.Value.ToShortDateString(), Quality); + { + episodeString = string.Format("{0}", AirDate.Value.ToString("yyyy-MM-dd")); + } + else if (FullSeason) + { + episodeString = string.Format("Season {0:00}", SeasonNumber); + } + else if (EpisodeNumbers != null && EpisodeNumbers.Any()) + { + episodeString = string.Format("S{0:00}E{1}",SeasonNumber, String.Join("-", EpisodeNumbers.Select(c => c.ToString("00")))); + } - if (FullSeason) - return string.Format("{0} - Season {1:00}", SeriesTitle, SeasonNumber); - - if (EpisodeNumbers != null && EpisodeNumbers.Any()) - return string.Format("{0} - S{1:00}E{2} {3}", SeriesTitle, SeasonNumber, - String.Join("-", EpisodeNumbers.Select(c => c.ToString("00"))), Quality); - - return "[Invalid format]"; + return string.Format("{0} - {1} {2}", SeriesTitle, episodeString, Quality); } } diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index 0aceb7799..971b52e99 100644 --- a/NzbDrone.Core/Providers/EpisodeProvider.cs +++ b/NzbDrone.Core/Providers/EpisodeProvider.cs @@ -231,7 +231,7 @@ namespace NzbDrone.Core.Providers } else { - logger.Debug("Unable to find {0}-S{1:00}E{2:00}", parseResult.Series.Title, parseResult.SeasonNumber, episodeNumber); + logger.Debug("Unable to find {0}", parseResult); } } diff --git a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs index 7b2f2679b..f020f85cb 100644 --- a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs +++ b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs @@ -93,7 +93,7 @@ namespace NzbDrone.Core.Providers.Indexer result = Fetch(Urls); - _logger.Info("Finished processing feeds from " + Name); + _logger.Debug("Finished processing feeds from " + Name); return result; } diff --git a/NzbDrone.Core/Providers/SearchProvider.cs b/NzbDrone.Core/Providers/SearchProvider.cs index 982a982b5..c978aa3f1 100644 --- a/NzbDrone.Core/Providers/SearchProvider.cs +++ b/NzbDrone.Core/Providers/SearchProvider.cs @@ -275,10 +275,7 @@ namespace NzbDrone.Core.Providers { if (_downloadProvider.DownloadReport(episodeParseResult)) { - notification.CurrentMessage = - String.Format("{0} - S{1:00}E{2:00} {3} Added to download queue", - episodeParseResult.Series.Title, episodeParseResult.SeasonNumber, - episodeParseResult.EpisodeNumbers[0], episodeParseResult.Quality); + notification.CurrentMessage = String.Format("{0} Added to download queue", episodeParseResult); //Add the list of episode numbers from this release successes.AddRange(episodeParseResult.EpisodeNumbers); diff --git a/NzbDrone.Web/Content/NzbDrone.css b/NzbDrone.Web/Content/NzbDrone.css index 4fccfc9a1..4d7a3174d 100644 --- a/NzbDrone.Web/Content/NzbDrone.css +++ b/NzbDrone.Web/Content/NzbDrone.css @@ -117,6 +117,7 @@ hr font-weight: 100; height: 135px; background: url(images/header.jpg) no-repeat left top; + background-color: #065EFE; font-size: 90px; color: #FFFFFF; text-transform: lowercase;