Merge branch 'mark-fork'

pull/6/head
kay.one 14 years ago
commit b86dac57e1

@ -84,6 +84,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