Added parsing for daily shows and tests for that format.

pull/6/head
Mark McDowall 14 years ago
parent c149060a24
commit 5e37bfa0c6

@ -1,4 +1,5 @@
using MbUnit.Framework;
using System;
using MbUnit.Framework;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Test
@ -13,7 +14,6 @@ namespace NzbDrone.Core.Test
*
*/
[Test]
[Row("Sonny.With.a.Chance.S02E15", 2, 15)]
[Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, 1)]
@ -81,6 +81,16 @@ namespace NzbDrone.Core.Test
Assert.AreElementsEqualIgnoringOrder(episodes, result.Episodes);
}
[Test]
[Row("Conan 2011 04 18 Emma Roberts HDTV XviD BFF", 2011, 04, 18)]
[Row("The Tonight Show With Jay Leno 2011 04 15 1080i HDTV DD5 1 MPEG2 TrollHD", 2011, 04, 15)]
public void episode_daily_parse(string path, int year, int month, int day)
{
var result = Parser.ParseEpisodeInfo(path);
var airDate = new DateTime(year, month, day);
Assert.AreEqual(airDate, result.AirDate);
}
[Test]
[Row(@"c:\test\", @"c:\test")]

@ -13,14 +13,20 @@ namespace NzbDrone.Core.Model
internal List<int> Episodes { get; set; }
internal int Year { get; set; }
internal DateTime AirDate { get; set; }
public bool Proper { get; set; }
public QualityTypes Quality { get; set; }
public override string ToString()
{
if (Episodes == null)
return string.Format("Series:{0} Air Date:{1}", SeriesTitle, AirDate.Date);
return string.Format("Series:{0} Season:{1} Episode:{2}", SeriesTitle, SeasonNumber,
String.Join(",", Episodes));
}
}
}

@ -14,6 +14,9 @@ namespace NzbDrone.Core
private static readonly Regex[] ReportTitleRegex = new[]
{
new Regex(
@"(?<title>.+?)?\W?(?<year>\d{4}?)?\W+(?<airyear>\d{4})\W+(?<airmonth>\d{2})\W+(?<airday>\d{2})\W?(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(
@"(?<title>.+?)?\W?(?<year>\d{4}?)?(?:\WS?(?<season>\d{1,2})(?:(?:\-|\.|[ex]|\s|to)+(?<episode>\d+))+)+\W?(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
@ -60,11 +63,21 @@ namespace NzbDrone.Core
year = 0;
}
var parsedEpisode = new EpisodeParseResult
var airyear = 0;
Int32.TryParse(match[0].Groups["airyear"].Value, out airyear);
EpisodeParseResult parsedEpisode;
if (airyear < 1 )
{
var season = 0;
Int32.TryParse(match[0].Groups["season"].Value, out season);
parsedEpisode = new EpisodeParseResult
{
Proper = title.ToLower().Contains("proper"),
SeriesTitle = seriesName,
SeasonNumber = Convert.ToInt32(match[0].Groups["season"].Value),
SeasonNumber = season,
Year = year,
Episodes = new List<int>()
};
@ -79,14 +92,29 @@ namespace NzbDrone.Core
{
parsedEpisode.Episodes.Add(i);
}
}
}
//else
//{
// foreach (Capture ep in matchGroup.Groups["episode"].Captures)
// {
// parsedEpisode.Episodes.Add(Convert.ToInt32(ep.Value));
// }
//}
else
{
//Try to Parse as a daily show
if (airyear > 0)
{
var airmonth = Convert.ToInt32(match[0].Groups["airmonth"].Value);
var airday = Convert.ToInt32(match[0].Groups["airday"].Value);
parsedEpisode = new EpisodeParseResult
{
Proper = title.ToLower().Contains("proper"),
SeriesTitle = seriesName,
Year = year,
AirDate = new DateTime(airyear, airmonth, airday)
};
}
//Something went wrong with this one... return null
else
return null;
}
parsedEpisode.Quality = ParseQuality(title);

Loading…
Cancel
Save