diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 3d1c3f19a..e8c3dcad1 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -21,6 +21,7 @@ namespace NzbDrone.Core.Test [Row(@"z:\tv shows\battlestar galactica (2003)\Season 3\S03E05 - Collaborators.mkv", 3, 5)] [Row(@"z:\tv shows\modern marvels\Season 16\S16E03 - The Potato.mkv", 16, 3)] [Row(@"z:\tv shows\robot chicken\Specials\S00E16 - Dear Consumer - SD TV.avi", 0, 16)] + [Row(@"Parenthood.2010.S02E14.HDTV.XviD-LOL", 2, 14)] public void episode_parse(string path, int season, int episode) { var result = Parser.ParseEpisodeInfo(path); @@ -30,8 +31,8 @@ namespace NzbDrone.Core.Test } [Test] - [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD)] - [Row("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.Bluray)] + [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.BDRip)] + [Row("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.BDRip)] [Row("Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV)] [Row("Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.TV)] [Row("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD)] diff --git a/NzbDrone.Core.Test/QualityProfileTest.cs b/NzbDrone.Core.Test/QualityProfileTest.cs index 8796bbc02..36ecc3343 100644 --- a/NzbDrone.Core.Test/QualityProfileTest.cs +++ b/NzbDrone.Core.Test/QualityProfileTest.cs @@ -29,10 +29,10 @@ namespace NzbDrone.Core.Test //Act var id = (int)repo.Add(testProfile); - var fetch = repo.Single(c => c.Id == id); + var fetch = repo.Single(c => c.ProfileId == id); //Assert - Assert.AreEqual(id, fetch.Id); + Assert.AreEqual(id, fetch.ProfileId); Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff); Assert.AreEqual(testProfile.Allowed, fetch.Allowed); } diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 7c8a82ef0..eb6424ab9 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -212,7 +212,6 @@ - diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index 35c0f2096..73e85a54d 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Core private static readonly Regex[] ReportTitleRegex = new[] { - new Regex(@"(?.+?)?\W(S)?(?<season>\d+)[EeXx](?<episode>\d+)\W(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled) + new Regex(@"(?<title>.+?)?\W(S)?(?<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); @@ -80,21 +80,25 @@ namespace NzbDrone.Core if (name.Contains("dvd")) return QualityTypes.DVD; + + if (name.Contains("bdrip") || name.Contains("brrip")) + { + return QualityTypes.BDRip; + } + if (name.Contains("xvid") || name.Contains("divx")) { - if (name.Contains("bluray") || name.Contains("bdrip")) + if (name.Contains("bluray")) { - return QualityTypes.DVD; + return QualityTypes.BDRip; } + return QualityTypes.TV; } - if (name.Contains("bluray") || name.Contains("bdrip")) + if (name.Contains("bluray")) { - if (name.Contains("1080p")) - return QualityTypes.Bluray1080p; - - return QualityTypes.Bluray720p; + return QualityTypes.Bluray; } if (name.Contains("web-dl")) return QualityTypes.WEBDL; @@ -142,14 +146,14 @@ namespace NzbDrone.Core if (String.IsNullOrEmpty(path)) throw new ArgumentException("Path can not be null or empty"); - var info = new FileInfo(path); + var info = new FileInfo(path); + + if (info.FullName.StartsWith(@"\\")) //UNC + { + return info.FullName.ToLower().TrimEnd('/', '\\', ' '); + } - if( info.FullName.StartsWith(@"\\")) //UNC - { - return info.FullName.ToLower().TrimEnd('/', '\\', ' '); - } - - return info.FullName.ToLower().Trim('/', '\\', ' '); + return info.FullName.ToLower().Trim('/', '\\', ' '); } public static NzbInfoModel ParseNzbInfo(FeedInfoModel feed, RssItem item) diff --git a/NzbDrone.Core/Providers/IQualityProvider.cs b/NzbDrone.Core/Providers/IQualityProvider.cs index 22ad05465..49e6b949f 100644 --- a/NzbDrone.Core/Providers/IQualityProvider.cs +++ b/NzbDrone.Core/Providers/IQualityProvider.cs @@ -8,9 +8,9 @@ namespace NzbDrone.Core.Providers { public interface IQualityProvider { - void AddProfile(QualityProfile profile, List<AllowedQuality> allowedQualities); - void UpdateProfile(QualityProfile profile, List<AllowedQuality> allowedQualities); - void RemoveProfile(int profileId); - List<QualityProfile> GetProfiles(); + void Add(QualityProfile profile); + void Update(QualityProfile profile); + void Delete(int profileId); + List<QualityProfile> GetAllProfiles(); } } diff --git a/NzbDrone.Core/Providers/QualityProvider.cs b/NzbDrone.Core/Providers/QualityProvider.cs index e21b7d50c..0141e1da7 100644 --- a/NzbDrone.Core/Providers/QualityProvider.cs +++ b/NzbDrone.Core/Providers/QualityProvider.cs @@ -18,61 +18,31 @@ namespace NzbDrone.Core.Providers #region IQualityProvider Members - public void AddProfile(QualityProfile profile, List<AllowedQuality> allowedQualities) + public void Add(QualityProfile profile) { - var profileId = _sonicRepo.Add(profile); - - foreach (var allowed in allowedQualities) - { - allowed.ProfileId = (int)profileId; - _sonicRepo.Add<AllowedQuality>(allowed); - } + _sonicRepo.Add(profile); } - public void UpdateProfile(QualityProfile profile, List<AllowedQuality> allowedQualities) + public void Update(QualityProfile profile) { if (!_sonicRepo.Exists<QualityProfile>(q => q.ProfileId == profile.ProfileId)) { //Log Error - throw new NotImplementedException(); + throw new InvalidOperationException("Unable to update none existing profile"); } - _sonicRepo.Update<QualityProfile>(profile); - - //Check to see if any items in the DB do not exist in this list - //Check to see if any of the allowedQualities already exist, if so update, else add - - foreach (var inDb in _sonicRepo.All<AllowedQuality>().Where(q => q.ProfileId == profile.ProfileId)) - { - if (!allowedQualities.Exists(l => l.ProfileId == inDb.ProfileId && l.Quality == inDb.Quality)) - _sonicRepo.Delete<AllowedQuality>(inDb.Id); - } - - foreach (var allowed in allowedQualities) - { - allowed.ProfileId = profile.ProfileId; - if (!_sonicRepo.Exists<AllowedQuality>(q => q.ProfileId == profile.ProfileId && q.Quality == allowed.Quality)) - _sonicRepo.Add(allowed); - - else - _sonicRepo.Update(allowed); - } + _sonicRepo.Update(profile); } - public void RemoveProfile(int profileId) + public void Delete(int profileId) { - _sonicRepo.DeleteMany<AllowedQuality>(q => q.ProfileId == profileId); _sonicRepo.Delete<QualityProfile>(profileId); } - public List<QualityProfile> GetProfiles() + public List<QualityProfile> GetAllProfiles() { var profiles = _sonicRepo.All<QualityProfile>().ToList(); - foreach (var profile in profiles) - { - profile.AllowedQualities = _sonicRepo.Find<AllowedQuality>(q => q.ProfileId == profile.ProfileId).ToList(); - } return profiles; } diff --git a/NzbDrone.Core/Repository/Quality/AllowedQuality.cs b/NzbDrone.Core/Repository/Quality/AllowedQuality.cs deleted file mode 100644 index 87fcbf4a8..000000000 --- a/NzbDrone.Core/Repository/Quality/AllowedQuality.cs +++ /dev/null @@ -1,16 +0,0 @@ -using SubSonic.SqlGeneration.Schema; - -namespace NzbDrone.Core.Repository.Quality -{ - public class AllowedQuality - { - public int Id { get; set; } - public int ProfileId { get; set; } - public int Order { get; set; } - public bool MarkComplete { get; set; } - public QualityTypes Quality { get; set; } - - [SubSonicToOneRelation(ThisClassContainsJoinKey = true)] - public virtual QualityProfile QualityProfile { get; private set; } - } -} diff --git a/NzbDrone.Core/Repository/Quality/QualityProfile.cs b/NzbDrone.Core/Repository/Quality/QualityProfile.cs index b68cb299d..65292d2c8 100644 --- a/NzbDrone.Core/Repository/Quality/QualityProfile.cs +++ b/NzbDrone.Core/Repository/Quality/QualityProfile.cs @@ -12,10 +12,9 @@ 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 - [SubSonicToManyRelation] - public virtual List<AllowedQuality> Allowed { get; private set; } + public List<QualityTypes> Allowed { get; set; } + public QualityTypes Cutoff { get; set; } + - [SubSonicIgnore] - public List<AllowedQuality> AllowedQualities { get; set; } } } diff --git a/NzbDrone.Core/Repository/Quality/QualityTypes.cs b/NzbDrone.Core/Repository/Quality/QualityTypes.cs index f8142420c..e9ed82bc3 100644 --- a/NzbDrone.Core/Repository/Quality/QualityTypes.cs +++ b/NzbDrone.Core/Repository/Quality/QualityTypes.cs @@ -19,6 +19,10 @@ namespace NzbDrone.Core.Repository.Quality /// </summary> DVD = 2, /// <summary> + /// SD File (HD Source) + /// </summary> + BDRip = 2, + /// <summary> /// HD File (HDTV Source) /// </summary> HDTV = 3, @@ -27,12 +31,9 @@ namespace NzbDrone.Core.Repository.Quality /// </summary> WEBDL = 4, /// <summary> - /// 720P HD File (Blu-ray Source) - /// </summary> - Bluray720p = 5, - /// <summary> - /// 1080P HD File (Blu-ray Source) + /// HD File (Blu-ray Source could be 1080p or 720p) /// </summary> - Bluray1080p = 6 + Bluray = 5, + } } \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 74c51e943..c2ab4bf92 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -97,8 +97,8 @@ namespace NzbDrone.Web.Controllers { ViewData["viewName"] = "Quality"; - var userProfiles = _qualityProvider.GetProfiles().Where(q => q.UserProfile).ToList(); - var profiles = _qualityProvider.GetProfiles().Where(q => q.UserProfile == false).ToList(); + var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList(); + var profiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile == false).ToList(); QualityModel model = new QualityModel {Profiles = profiles, UserProfiles = userProfiles};