mirror of https://github.com/Radarr/Radarr
fixed episode parse, profile storage
This commit is contained in:
parent
ca27c75df5
commit
16fcda18c3
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MbUnit.Framework;
|
using MbUnit.Framework;
|
||||||
|
@ -22,10 +23,11 @@ namespace NzbDrone.Core.Test
|
||||||
//Arrange
|
//Arrange
|
||||||
var repo = MockLib.GetEmptyRepository();
|
var repo = MockLib.GetEmptyRepository();
|
||||||
var testProfile = new QualityProfile
|
var testProfile = new QualityProfile
|
||||||
{
|
{
|
||||||
Cutoff = QualityTypes.TV,
|
Name = Guid.NewGuid().ToString(),
|
||||||
Allowed = new List<QualityTypes>() { QualityTypes.HDTV, QualityTypes.DVD },
|
Cutoff = QualityTypes.TV,
|
||||||
};
|
Allowed = new List<QualityTypes>() { QualityTypes.HDTV, QualityTypes.DVD },
|
||||||
|
};
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var id = (int)repo.Add(testProfile);
|
var id = (int)repo.Add(testProfile);
|
||||||
|
@ -33,6 +35,7 @@ namespace NzbDrone.Core.Test
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual(id, fetch.ProfileId);
|
Assert.AreEqual(id, fetch.ProfileId);
|
||||||
|
Assert.AreEqual(testProfile.Name, fetch.Name);
|
||||||
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
|
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
|
||||||
Assert.AreEqual(testProfile.Allowed, fetch.Allowed);
|
Assert.AreEqual(testProfile.Allowed, fetch.Allowed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace NzbDrone.Core.Model
|
||||||
internal string SeriesTitle { get; set; }
|
internal string SeriesTitle { get; set; }
|
||||||
internal int SeasonNumber { get; set; }
|
internal int SeasonNumber { get; set; }
|
||||||
internal int EpisodeNumber { get; set; }
|
internal int EpisodeNumber { get; set; }
|
||||||
|
internal int Year { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core
|
||||||
|
|
||||||
private static readonly Regex[] ReportTitleRegex = new[]
|
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);
|
private static readonly Regex NormalizeRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
@ -41,15 +41,25 @@ namespace NzbDrone.Core
|
||||||
if (match.Count != 0)
|
if (match.Count != 0)
|
||||||
{
|
{
|
||||||
var seriesName = NormalizeTitle(match[0].Groups["title"].Value);
|
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)
|
foreach (Match matchGroup in match)
|
||||||
{
|
{
|
||||||
|
|
||||||
var parsedEpisode = new EpisodeParseResult
|
var parsedEpisode = new EpisodeParseResult
|
||||||
{
|
{
|
||||||
SeriesTitle = seriesName,
|
SeriesTitle = seriesName,
|
||||||
SeasonNumber = Convert.ToInt32(matchGroup.Groups["season"].Value),
|
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);
|
result.Add(parsedEpisode);
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,32 @@ namespace NzbDrone.Core.Repository.Quality
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public bool UserProfile { get; set; } //Allows us to tell the difference between default and user profiles
|
public bool UserProfile { get; set; } //Allows us to tell the difference between default and user profiles
|
||||||
|
|
||||||
|
[SubSonicIgnore]
|
||||||
public List<QualityTypes> Allowed { get; set; }
|
public List<QualityTypes> Allowed { get; set; }
|
||||||
|
|
||||||
public QualityTypes Cutoff { 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue