From 78268f3c5893a0fcfef20d0f57e62d7d9be15f79 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 19 Jan 2012 22:35:10 -0800 Subject: [PATCH] Better parser logging. --- NzbDrone.Core.Test/IndexerTests.cs | 4 ++-- NzbDrone.Core.Test/ParserTest.cs | 8 +++++++- NzbDrone.Core/Model/EpisodeParseResult.cs | 4 ++-- NzbDrone.Core/Parser.cs | 7 +++++-- NzbDrone.Core/Providers/DownloadProvider.cs | 2 +- NzbDrone.Core/Providers/EpisodeProvider.cs | 6 +++--- NzbDrone.Core/Providers/Indexer/IndexerBase.cs | 2 +- 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 6daec9ebd..de80a91a9 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test parseResults.Should().NotBeEmpty(); parseResults.Should().OnlyContain(s => s.Indexer == mockIndexer.Name); - parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.NzbTitle)); + parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString)); ExceptionVerification.ExpectedWarns(warns); } @@ -115,7 +115,7 @@ namespace NzbDrone.Core.Test parseResults.Should().NotBeEmpty(); parseResults.Should().OnlyContain(s => s.Indexer == newzbinProvider.Name); - parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.NzbTitle)); + parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString)); ExceptionVerification.MarkInconclusive(typeof(WebException)); ExceptionVerification.IgnoreWarns(); diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 61845fbc8..5e3d793bc 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -65,6 +65,7 @@ namespace NzbDrone.Core.Test result.SeasonNumber.Should().Be(seasonNumber); result.EpisodeNumbers.First().Should().Be(episodeNumber); result.CleanTitle.Should().Be(Parser.NormalizeTitle(title)); + result.OriginalString.Should().Be(postTitle); } [Test] @@ -84,6 +85,7 @@ namespace NzbDrone.Core.Test result.EpisodeNumbers.Should().HaveCount(1); result.SeasonNumber.Should().Be(season); result.EpisodeNumbers[0].Should().Be(episode); + result.OriginalString.Should().Be(path); ExceptionVerification.IgnoreWarns(); } @@ -162,6 +164,7 @@ namespace NzbDrone.Core.Test result.EpisodeNumbers.Should().BeEquivalentTo(result.EpisodeNumbers); result.CleanTitle.Should().Be(Parser.NormalizeTitle(title)); result.EpisodeNumbers.Count.Should().Be(count); + result.OriginalString.Should().Be(postTitle); } @@ -178,7 +181,8 @@ namespace NzbDrone.Core.Test var airDate = new DateTime(year, month, day); result.CleanTitle.Should().Be(Parser.NormalizeTitle(title)); result.AirDate.Should().Be(airDate); - Assert.IsNull(result.EpisodeNumbers); + result.EpisodeNumbers.Should().BeNull(); + result.OriginalString.Should().Be(postTitle); } [Test] @@ -203,6 +207,7 @@ namespace NzbDrone.Core.Test result.CleanTitle.Should().Be(Parser.NormalizeTitle(title)); result.EpisodeNumbers.Count.Should().Be(0); result.FullSeason.Should().BeTrue(); + result.OriginalString.Should().Be(postTitle); } [TestCase("Conan", "conan")] @@ -342,6 +347,7 @@ namespace NzbDrone.Core.Test result.CleanTitle.Should().Be(Parser.NormalizeTitle(seriesName)); result.SeasonNumber.Should().Be(seasonNumber); result.FullSeason.Should().BeTrue(); + result.OriginalString.Should().Be(postTitle); } [TestCase("5.64 GB", 6055903887)] diff --git a/NzbDrone.Core/Model/EpisodeParseResult.cs b/NzbDrone.Core/Model/EpisodeParseResult.cs index fcd514a24..4b9d73eb8 100644 --- a/NzbDrone.Core/Model/EpisodeParseResult.cs +++ b/NzbDrone.Core/Model/EpisodeParseResult.cs @@ -29,7 +29,7 @@ namespace NzbDrone.Core.Model public string NzbUrl { get; set; } - public string NzbTitle { get; set; } + public string OriginalString { get; set; } public Series Series { get; set; } @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Model return string.Format("{0} - S{1:00}E{2} {3}", SeriesTitle, SeasonNumber, String.Join("-", EpisodeNumbers), Quality); - return NzbTitle; + return OriginalString; } } diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index 153a1cf7b..2442d553f 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -77,6 +77,8 @@ namespace NzbDrone.Core result = ParseTitle(fileInfo.FullName); } + result.OriginalString = path; + return result; } @@ -102,6 +104,7 @@ namespace NzbDrone.Core result.Language = ParseLanguage(title); result.Quality = ParseQuality(title); + result.OriginalString = title; return result; } } @@ -313,8 +316,8 @@ namespace NzbDrone.Core return result; } - if ((normalizedName.Contains("sdtv") || - (result.QualityType == QualityTypes.Unknown && normalizedName.Contains("hdtv"))) && + if ((normalizedName.Contains("sdtv") || + (result.QualityType == QualityTypes.Unknown && normalizedName.Contains("hdtv"))) && !normalizedName.Contains("mpeg")) { result.QualityType = QualityTypes.SDTV; diff --git a/NzbDrone.Core/Providers/DownloadProvider.cs b/NzbDrone.Core/Providers/DownloadProvider.cs index fb877aa19..bbc85efc2 100644 --- a/NzbDrone.Core/Providers/DownloadProvider.cs +++ b/NzbDrone.Core/Providers/DownloadProvider.cs @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Providers history.Indexer = parseResult.Indexer; history.IsProper = parseResult.Quality.Proper; history.Quality = parseResult.Quality.QualityType; - history.NzbTitle = parseResult.NzbTitle; + history.NzbTitle = parseResult.OriginalString; history.EpisodeId = episode.EpisodeId; history.SeriesId = episode.SeriesId; diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index fcaca6cfe..e68679569 100644 --- a/NzbDrone.Core/Providers/EpisodeProvider.cs +++ b/NzbDrone.Core/Providers/EpisodeProvider.cs @@ -133,7 +133,7 @@ namespace NzbDrone.Core.Providers if (!parseResult.Series.IsDaily) { //Todo: Collect this as a Series we want to treat as a daily series, or possible parsing error - Logger.Warn("Found daily-style episode for non-daily series: {0}. {1}", parseResult.Series.Title, parseResult.NzbTitle); + Logger.Warn("Found daily-style episode for non-daily series: {0}. {1}", parseResult.Series.Title, parseResult.OriginalString); return new List(); } @@ -141,7 +141,7 @@ namespace NzbDrone.Core.Providers if (episodeInfo == null && autoAddNew) { - Logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.NzbTitle); + Logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.OriginalString); episodeInfo = new Episode { SeriesId = parseResult.Series.SeriesId, @@ -193,7 +193,7 @@ namespace NzbDrone.Core.Providers //if still null we should add the temp episode if (episodeInfo == null && autoAddNew) { - Logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.NzbTitle); + Logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.OriginalString); episodeInfo = new Episode { SeriesId = parseResult.Series.SeriesId, diff --git a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs index be285c1a2..e53ee9679 100644 --- a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs +++ b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs @@ -177,7 +177,7 @@ namespace NzbDrone.Core.Providers.Indexer { parsedEpisode.NzbUrl = NzbDownloadUrl(item); parsedEpisode.Indexer = Name; - parsedEpisode.NzbTitle = item.Title.Text; + parsedEpisode.OriginalString = item.Title.Text; result.Add(parsedEpisode); } }