From d7732cab3bd327b85d50abafd987b8c1ce82f343 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 3 Apr 2011 21:20:01 -0700 Subject: [PATCH] fixed episode parse issue --- NzbDrone.Core.Test/ParserTest.cs | 18 +++++++++--------- NzbDrone.Core/Model/EpisodeParseResult.cs | 3 +++ NzbDrone.Core/Model/SeasonParseResult.cs | 2 ++ NzbDrone.Core/Parser.cs | 13 +++++++------ NzbDrone.Core/Providers/BacklogProvider.cs | 2 -- NzbDrone.Core/Providers/MediaFileProvider.cs | 2 +- .../Providers/RssItemProcessingProvider.cs | 4 ++-- NzbDrone.sln | 6 ++++-- 8 files changed, 28 insertions(+), 22 deletions(-) diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 30beb9618..9532db969 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -13,6 +13,7 @@ namespace NzbDrone.Core.Test public class ParserTest { [Test] + [Row("Sonny.With.a.Chance.S02E15", 2,15)] [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, 1)] [Row("Two.and.a.Half.Me.103.720p.HDTV.X264-DIMENSION", 1, 3)] [Row("Two.and.a.Half.Me.113.720p.HDTV.X264-DIMENSION", 1, 13)] @@ -30,9 +31,8 @@ public class ParserTest public void episode_parse(string path, int season, int episode) { var result = Parser.ParseEpisodeInfo(path); - Assert.Count(1, result); - Assert.AreEqual(season, result[0].SeasonNumber); - Assert.AreEqual(episode, result[0].EpisodeNumber); + Assert.AreEqual(season, result.SeasonNumber); + Assert.AreEqual(episode, result.Episodes[0]); } [Test] @@ -49,15 +49,15 @@ public void episode_parse(string path, int season, int episode) [Row("Sonny.With.a.Chance.S02E15.xvid", QualityTypes.TV)] [Row("Sonny.With.a.Chance.S02E15.divx", QualityTypes.TV)] [Row("Sonny.With.a.Chance.S02E15", QualityTypes.Unknown)] - [Row("S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV)] - [Row("S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV)] - [Row("S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720)] - [Row("S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080)] - [Row("S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL)] + [Row("Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV)] + [Row("Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV)] + [Row("Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720)] + [Row("Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080)] + [Row("Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL)] [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.BDRip)] public void quality_parse(string path, object quality) { - var result = Parser.ParseQuality(path); + var result = Parser.ParseEpisodeInfo(path).Quality; Assert.AreEqual(quality, result); } diff --git a/NzbDrone.Core/Model/EpisodeParseResult.cs b/NzbDrone.Core/Model/EpisodeParseResult.cs index 6c24b5551..0888b07d0 100644 --- a/NzbDrone.Core/Model/EpisodeParseResult.cs +++ b/NzbDrone.Core/Model/EpisodeParseResult.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using NzbDrone.Core.Repository.Quality; namespace NzbDrone.Core.Model { @@ -10,6 +11,8 @@ public class EpisodeParseResult internal List Episodes { get; set; } internal int Year { get; set; } + public QualityTypes Quality { get; set; } + public override string ToString() { return string.Format("Series:{0} Season:{1} Episode:{2}", SeriesTitle, SeasonNumber, String.Join(",", Episodes)); diff --git a/NzbDrone.Core/Model/SeasonParseResult.cs b/NzbDrone.Core/Model/SeasonParseResult.cs index 4f45ce305..1a246173a 100644 --- a/NzbDrone.Core/Model/SeasonParseResult.cs +++ b/NzbDrone.Core/Model/SeasonParseResult.cs @@ -9,6 +9,8 @@ public class SeasonParseResult internal int SeasonNumber { get; set; } internal int Year { get; set; } + public QualityTypes Quality { get; set; } + public override string ToString() { return string.Format("Series:{0} Season:{1}", SeriesTitle, SeasonNumber); diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index befcdfc74..37c57621c 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -38,9 +38,7 @@ internal static EpisodeParseResult ParseEpisodeInfo(string title) { Logger.Trace("Parsing string '{0}'", title); - var result = new EpisodeParseResult(); - - foreach (var regex in ReportTitleRegex) + foreach (var regex in ReportTitleRegex) { var match = regex.Matches(title); @@ -69,13 +67,15 @@ internal static EpisodeParseResult ParseEpisodeInfo(string title) } + parsedEpisode.Quality = ParseQuality(title); + Logger.Trace("Episode Parsed. {0}", parsedEpisode); - break; //Break out of the for loop, we don't want to process every REGEX for each item otherwise we'll get duplicates + return parsedEpisode; } } - return result; + return null; } /// @@ -112,6 +112,7 @@ internal static SeasonParseResult ParseSeasonInfo(string title) }; + result.Quality = ParseQuality(title); Logger.Trace("Season Parsed. {0}", result); return result; @@ -163,7 +164,7 @@ internal static bool ParseProper(string title) return title.ToLower().Contains("proper"); } - internal static QualityTypes ParseQuality(string name) + private static QualityTypes ParseQuality(string name) { Logger.Trace("Trying to parse quality for {0}", name); diff --git a/NzbDrone.Core/Providers/BacklogProvider.cs b/NzbDrone.Core/Providers/BacklogProvider.cs index 920626e80..60e2f3078 100644 --- a/NzbDrone.Core/Providers/BacklogProvider.cs +++ b/NzbDrone.Core/Providers/BacklogProvider.cs @@ -269,8 +269,6 @@ private void QueueSeasonIfWanted(NzbInfoModel nzb, Indexer indexer) nzb.TitleFix = String.Empty; nzb.TitleFix = String.Format("{0} [{1}]", nzb.TitleFix, nzb.Quality); //Add Quality to the titleFix - //Check that we want this quality - var quality = Parser.ParseQuality(nzb.Title); } catch (Exception ex) diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs index 2f6abf600..ffdf2a0f8 100644 --- a/NzbDrone.Core/Providers/MediaFileProvider.cs +++ b/NzbDrone.Core/Providers/MediaFileProvider.cs @@ -108,7 +108,7 @@ public EpisodeFile ImportFile(Series series, string filePath) episodeFile.SeriesId = series.SeriesId; episodeFile.Path = Parser.NormalizePath(filePath); episodeFile.Size = size; - episodeFile.Quality = Parser.ParseQuality(filePath); + episodeFile.Quality = episodesInFile.Quality; episodeFile.Proper = Parser.ParseProper(filePath); var fileId = (int)_repository.Add(episodeFile); diff --git a/NzbDrone.Core/Providers/RssItemProcessingProvider.cs b/NzbDrone.Core/Providers/RssItemProcessingProvider.cs index 10d794602..4b07bcdce 100644 --- a/NzbDrone.Core/Providers/RssItemProcessingProvider.cs +++ b/NzbDrone.Core/Providers/RssItemProcessingProvider.cs @@ -135,7 +135,7 @@ private void ProcessStandardItem(NzbInfoModel nzb, Indexer indexer, EpisodeParse Logger.Debug("Show is being watched: {0}", series.Title); nzb.Proper = Parser.ParseProper(nzb.Title); - nzb.Quality = Parser.ParseQuality(nzb.Title); + nzb.Quality = episodeParseResults.Quality; //Loop through the list of the episodeParseResults to ensure that all the episodes are needed foreach (var episode in episodeParseResults.Episodes) @@ -221,7 +221,7 @@ private void ProcessFullSeasonItem(NzbInfoModel nzb, Indexer indexer, SeasonPars Logger.Debug("Show is being watched: {0}", series.Title); nzb.Proper = Parser.ParseProper(nzb.Title); - nzb.Quality = Parser.ParseQuality(nzb.Title); + nzb.Quality = seasonParseResult.Quality; if (!_seriesProvider.QualityWanted(series.SeriesId, nzb.Quality)) { diff --git a/NzbDrone.sln b/NzbDrone.sln index c15d4b924..0cfcfbde7 100644 --- a/NzbDrone.sln +++ b/NzbDrone.sln @@ -38,8 +38,8 @@ Global {D12F7F2F-8A3C-415F-88FA-6DD061A84869}.Release|x86.Build.0 = Release|x86 {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}.Debug|x64.ActiveCfg = Debug|x64 {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}.Debug|x64.Build.0 = Debug|x64 {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}.Debug|x86.ActiveCfg = Debug|x86 @@ -55,6 +55,7 @@ Global {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x64.ActiveCfg = Debug|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x86.ActiveCfg = Debug|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x86.Build.0 = Debug|Any CPU @@ -67,6 +68,7 @@ Global {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|Any CPU.Build.0 = Debug|Any CPU {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|x64.ActiveCfg = Debug|Any CPU {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|x86.ActiveCfg = Debug|Any CPU {193ADD3B-792B-4173-8E4C-5A3F8F0237F0}.Debug|x86.Build.0 = Debug|Any CPU