fixed episode parse, profile storage

This commit is contained in:
Keivan 2011-02-03 12:09:19 -08:00
parent ca27c75df5
commit 16fcda18c3
4 changed files with 48 additions and 11 deletions

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using MbUnit.Framework;
@ -23,6 +24,7 @@ namespace NzbDrone.Core.Test
var repo = MockLib.GetEmptyRepository();
var testProfile = new QualityProfile
{
Name = Guid.NewGuid().ToString(),
Cutoff = QualityTypes.TV,
Allowed = new List<QualityTypes>() { QualityTypes.HDTV, QualityTypes.DVD },
};
@ -33,6 +35,7 @@ namespace NzbDrone.Core.Test
//Assert
Assert.AreEqual(id, fetch.ProfileId);
Assert.AreEqual(testProfile.Name, fetch.Name);
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
Assert.AreEqual(testProfile.Allowed, fetch.Allowed);
}

View File

@ -8,6 +8,7 @@ namespace NzbDrone.Core.Model
internal string SeriesTitle { get; set; }
internal int SeasonNumber { get; set; }
internal int EpisodeNumber { get; set; }
internal int Year { get; set; }
public override string ToString()
{

View File

@ -18,7 +18,7 @@ namespace NzbDrone.Core
private static readonly Regex[] ReportTitleRegex = new[]
{
new Regex(@"(?<title>.+?)?\W(S)?(?<season>\d+)\w(?<episode>\d+)\W(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled)
new Regex(@"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)\w(?<episode>\d+)\W(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled)
};
private static readonly Regex NormalizeRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
@ -41,16 +41,26 @@ namespace NzbDrone.Core
if (match.Count != 0)
{
var seriesName = NormalizeTitle(match[0].Groups["title"].Value);
var year = 0;
Int32.TryParse(match[0].Groups["year"].Value, out year);
if (year < 1900 || year > DateTime.Now.Year + 1)
{
year = 0;
}
foreach (Match matchGroup in match)
{
var parsedEpisode = new EpisodeParseResult
{
SeriesTitle = seriesName,
SeasonNumber = Convert.ToInt32(matchGroup.Groups["season"].Value),
EpisodeNumber = Convert.ToInt32(matchGroup.Groups["episode"].Value)
EpisodeNumber = Convert.ToInt32(matchGroup.Groups["episode"].Value),
Year = year
};
result.Add(parsedEpisode);
Logger.Trace("Episode Parsed. {0}", parsedEpisode);

View File

@ -12,9 +12,32 @@ namespace NzbDrone.Core.Repository.Quality
public string Name { get; set; }
public bool UserProfile { get; set; } //Allows us to tell the difference between default and user profiles
[SubSonicIgnore]
public List<QualityTypes> Allowed { get; set; }
public QualityTypes Cutoff { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
public string SonicAllowed
{
get
{
string result = String.Empty;
foreach (var q in Allowed)
{
result += (int)q + "|";
}
return result.Trim('|');
}
private set
{
var qualities = value.Split('|');
Allowed = new List<QualityTypes>(qualities.Length);
foreach (var quality in qualities)
{
Allowed.Add((QualityTypes)Convert.ToInt32(quality));
}
}
}
}
}