simplified quality fixed some broken tests

pull/4/head
Keivan 14 years ago
parent 764f67f8e8
commit ca27c75df5

@ -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)]

@ -29,10 +29,10 @@ namespace NzbDrone.Core.Test
//Act
var id = (int)repo.Add(testProfile);
var fetch = repo.Single<QualityProfile>(c => c.Id == id);
var fetch = repo.Single<QualityProfile>(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);
}

@ -212,7 +212,6 @@
<Compile Include="Instrumentation\Log.cs" />
<Compile Include="Repository\History.cs" />
<Compile Include="Repository\Indexer.cs" />
<Compile Include="Repository\Quality\AllowedQuality.cs" />
<Compile Include="Repository\Config.cs" />
<Compile Include="Repository\Quality\QualityProfile.cs" />
<Compile Include="Repository\Season.cs" />

@ -18,7 +18,7 @@ namespace NzbDrone.Core
private static readonly Regex[] ReportTitleRegex = new[]
{
new Regex(@"(?<title>.+?)?\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)

@ -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();
}
}

@ -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;
}

@ -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; }
}
}

@ -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; }
}
}

@ -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,
}
}

@ -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};

Loading…
Cancel
Save