Permalink
Browse files

Preferred words

New: Ability to prefer releases based on terms in release title
  • Loading branch information...
markus101 committed Oct 20, 2018
1 parent a3fa6e7 commit cd919b6741354032c3dd183a73951cd6a4884715
Showing with 848 additions and 343 deletions.
  1. +1 −0 src/NzbDrone.Api/Calendar/CalendarModule.cs
  2. +1 −0 src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs
  3. +1 −0 src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs
  4. +1 −0 src/NzbDrone.Api/Episodes/EpisodeModule.cs
  5. +1 −0 src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs
  6. +1 −0 src/NzbDrone.Api/History/HistoryModule.cs
  7. +9 −9 src/NzbDrone.Api/Restrictions/RestrictionModule.cs
  8. +6 −9 src/NzbDrone.Api/Restrictions/RestrictionResource.cs
  9. +1 −0 src/NzbDrone.Api/Wanted/CutoffModule.cs
  10. +1 −0 src/NzbDrone.Api/Wanted/MissingModule.cs
  11. +58 −17 src/NzbDrone.Core.Test/DecisionEngineTests/CutoffSpecificationFixture.cs
  12. +2 −1 src/NzbDrone.Core.Test/DecisionEngineTests/DownloadDecisionMakerFixture.cs
  13. +43 −6 src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs
  14. +10 −10 src/NzbDrone.Core.Test/DecisionEngineTests/ReleaseRestrictionsSpecificationFixture.cs
  15. +5 −4 src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/DelaySpecificationFixture.cs
  16. +1 −0 src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/HistorySpecificationFixture.cs
  17. +1 −1 src/NzbDrone.Core.Test/DecisionEngineTests/RssSync/ProperSpecificationFixture.cs
  18. +3 −3 src/NzbDrone.Core.Test/DecisionEngineTests/SameEpisodesSpecificationFixture.cs
  19. +32 −12 ...Test/DecisionEngineTests/{QualityUpgradeSpecificationFixture.cs → UpgradeSpecificationFixture.cs}
  20. +3 −3 src/NzbDrone.Core.Test/Housekeeping/Housekeepers/CleanupUnusedTagsFixture.cs
  21. +2 −2 src/NzbDrone.Core.Test/MediaFiles/EpisodeFileMovingServiceTests/MoveEpisodeFileFixture.cs
  22. +2 −1 src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
  23. +95 −0 src/NzbDrone.Core.Test/Profiles/Releases/PreferredWordService/CalculateFixture.cs
  24. +15 −0 src/NzbDrone.Core/Datastore/Migration/127_rename_release_profiles.cs
  25. +3 −2 src/NzbDrone.Core/Datastore/TableMapping.cs
  26. +7 −1 src/NzbDrone.Core/DecisionEngine/DownloadDecisionComparer.cs
  27. +9 −1 src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs
  28. +11 −5 src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs
  29. +1 −1 src/NzbDrone.Core/DecisionEngine/{ → Specifications}/IDecisionEngineSpecification.cs
  30. +16 −7 src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs
  31. +5 −5 src/NzbDrone.Core/DecisionEngine/Specifications/ReleaseRestrictionsSpecification.cs
  32. +20 −13 src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/DelaySpecification.cs
  33. +24 −2 src/NzbDrone.Core/DecisionEngine/Specifications/RssSync/HistorySpecification.cs
  34. +1 −1 src/NzbDrone.Core/DecisionEngine/{ → Specifications}/SameEpisodesSpecification.cs
  35. +38 −13 src/NzbDrone.Core/DecisionEngine/{ → Specifications}/UpgradableSpecification.cs
  36. +9 −4 src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs
  37. +22 −0 src/NzbDrone.Core/Download/Aggregation/Aggregators/AggregatePreferredWordScore.cs
  38. +9 −0 src/NzbDrone.Core/Download/Aggregation/Aggregators/IAggregateRemoteEpisode.cs
  39. +44 −0 src/NzbDrone.Core/Download/Aggregation/RemoteEpisodeAggregationService.cs
  40. +2 −2 src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupUnusedTags.cs
  41. +6 −1 src/NzbDrone.Core/MediaFiles/EpisodeFile.cs
  42. +1 −0 src/NzbDrone.Core/MediaFiles/EpisodeImport/Specifications/SameEpisodesImportSpecification.cs
  43. +13 −8 src/NzbDrone.Core/NzbDrone.Core.csproj
  44. +17 −2 src/NzbDrone.Core/Organizer/FileNameBuilder.cs
  45. +7 −1 src/NzbDrone.Core/Organizer/FileNameSampleService.cs
  46. +1 −0 src/NzbDrone.Core/Parser/Model/RemoteEpisode.cs
  47. +2 −6 src/NzbDrone.Core/{Restrictions → Profiles/Releases}/PerlRegexFactory.cs
  48. +76 −0 src/NzbDrone.Core/Profiles/Releases/PreferredWordService.cs
  49. +21 −0 src/NzbDrone.Core/Profiles/Releases/ReleaseProfile.cs
  50. +17 −0 src/NzbDrone.Core/Profiles/Releases/ReleaseProfileRepository.cs
  51. +65 −0 src/NzbDrone.Core/Profiles/Releases/ReleaseProfileService.cs
  52. +1 −4 src/NzbDrone.Core/{Restrictions → Profiles/Releases}/TermMatcher.cs
  53. +0 −18 src/NzbDrone.Core/Restrictions/Restriction.cs
  54. +0 −17 src/NzbDrone.Core/Restrictions/RestrictionRepository.cs
  55. +0 −65 src/NzbDrone.Core/Restrictions/RestrictionService.cs
  56. +6 −6 src/NzbDrone.Core/Tags/TagService.cs
  57. +1 −0 src/Sonarr.Api.V3/Calendar/CalendarModule.cs
  58. +1 −0 src/Sonarr.Api.V3/EpisodeFiles/EpisodeFileModule.cs
  59. +1 −0 src/Sonarr.Api.V3/EpisodeFiles/EpisodeFileResource.cs
  60. +1 −0 src/Sonarr.Api.V3/Episodes/EpisodeModule.cs
  61. +1 −0 src/Sonarr.Api.V3/Episodes/EpisodeModuleWithSignalR.cs
  62. +1 −0 src/Sonarr.Api.V3/History/HistoryModule.cs
  63. +10 −4 src/Sonarr.Api.V3/Indexers/ReleaseModuleBase.cs
  64. +3 −1 src/Sonarr.Api.V3/Indexers/ReleaseResource.cs
  65. +60 −0 src/Sonarr.Api.V3/Profiles/Release/ReleaseProfileModule.cs
  66. +16 −13 src/Sonarr.Api.V3/{Restrictions/RestrictionResource.cs → Profiles/Release/ReleaseProfileResource.cs}
  67. +0 −60 src/Sonarr.Api.V3/Restrictions/RestrictionModule.cs
  68. +2 −2 src/Sonarr.Api.V3/Sonarr.Api.V3.csproj
  69. +1 −0 src/Sonarr.Api.V3/Wanted/CutoffModule.cs
  70. +1 −0 src/Sonarr.Api.V3/Wanted/MissingModule.cs
@@ -3,6 +3,7 @@
using System.Linq;
using NzbDrone.Api.Episodes;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Tv;
using NzbDrone.SignalR;
@@ -5,6 +5,7 @@
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Exceptions;
using NzbDrone.SignalR;
using Sonarr.Http;
@@ -1,6 +1,7 @@
using System;
using System.IO;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.MediaFiles;
using Sonarr.Http.REST;
using NzbDrone.Core.Qualities;
@@ -2,6 +2,7 @@
using Sonarr.Http.REST;
using NzbDrone.Core.Tv;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.SignalR;
namespace NzbDrone.Api.Episodes
@@ -4,6 +4,7 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events;
@@ -7,6 +7,7 @@
using NzbDrone.Api.Series;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Download;
using NzbDrone.Core.History;
using Sonarr.Http;
@@ -1,20 +1,20 @@
using System.Collections.Generic;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Restrictions;
using NzbDrone.Core.Profiles.Releases;
using Sonarr.Http;
using Sonarr.Http.Mapping;
namespace NzbDrone.Api.Restrictions
{
public class RestrictionModule : SonarrRestModule<RestrictionResource>
{
private readonly IRestrictionService _restrictionService;
private readonly IReleaseProfileService _releaseProfileService;
public RestrictionModule(IRestrictionService restrictionService)
public RestrictionModule(IReleaseProfileService releaseProfileService)
{
_restrictionService = restrictionService;
_releaseProfileService = releaseProfileService;
GetResourceById = GetRestriction;
GetResourceAll = GetAllRestrictions;
@@ -35,27 +35,27 @@ public RestrictionModule(IRestrictionService restrictionService)
private RestrictionResource GetRestriction(int id)
{
return _restrictionService.Get(id).ToResource();
return _releaseProfileService.Get(id).ToResource();
}
private List<RestrictionResource> GetAllRestrictions()
{
return _restrictionService.All().ToResource();
return _releaseProfileService.All().ToResource();
}
private int CreateRestriction(RestrictionResource resource)
{
return _restrictionService.Add(resource.ToModel()).Id;
return _releaseProfileService.Add(resource.ToModel()).Id;
}
private void UpdateRestriction(RestrictionResource resource)
{
_restrictionService.Update(resource.ToModel());
_releaseProfileService.Update(resource.ToModel());
}
private void DeleteRestriction(int id)
{
_restrictionService.Delete(id);
_releaseProfileService.Delete(id);
}
}
}
@@ -1,14 +1,13 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Profiles.Releases;
using Sonarr.Http.REST;
using NzbDrone.Core.Restrictions;
namespace NzbDrone.Api.Restrictions
{
public class RestrictionResource : RestResource
{
public string Required { get; set; }
public string Preferred { get; set; }
public string Ignored { get; set; }
public HashSet<int> Tags { get; set; }
@@ -20,7 +19,7 @@ public RestrictionResource()
public static class RestrictionResourceMapper
{
public static RestrictionResource ToResource(this Restriction model)
public static RestrictionResource ToResource(this ReleaseProfile model)
{
if (model == null) return null;
@@ -29,28 +28,26 @@ public static RestrictionResource ToResource(this Restriction model)
Id = model.Id,
Required = model.Required,
Preferred = model.Preferred,
Ignored = model.Ignored,
Tags = new HashSet<int>(model.Tags)
};
}
public static Restriction ToModel(this RestrictionResource resource)
public static ReleaseProfile ToModel(this RestrictionResource resource)
{
if (resource == null) return null;
return new Restriction
return new ReleaseProfile
{
Id = resource.Id,
Required = resource.Required,
Preferred = resource.Preferred,
Ignored = resource.Ignored,
Tags = new HashSet<int>(resource.Tags)
};
}
public static List<RestrictionResource> ToResource(this IEnumerable<Restriction> models)
public static List<RestrictionResource> ToResource(this IEnumerable<ReleaseProfile> models)
{
return models.Select(ToResource).ToList();
}
@@ -2,6 +2,7 @@
using NzbDrone.Api.Episodes;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Tv;
using NzbDrone.SignalR;
using Sonarr.Http;
@@ -2,6 +2,7 @@
using NzbDrone.Api.Episodes;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Tv;
using NzbDrone.SignalR;
using Sonarr.Http;
@@ -1,8 +1,8 @@
using FluentAssertions;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Profiles.Qualities;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Profiles.Languages;
@@ -13,6 +13,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[TestFixture]
public class CutoffSpecificationFixture : CoreTest<UpgradableSpecification>
{
private static readonly int NoPreferredWordScore = 0;
[Test]
public void should_return_true_if_current_episode_is_less_than_cutoff()
{
@@ -27,7 +29,9 @@ public void should_return_true_if_current_episode_is_less_than_cutoff()
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
Cutoff = Language.English
},
new QualityModel(Quality.DVD, new Revision(version: 2)), Language.English).Should().BeTrue();
new QualityModel(Quality.DVD, new Revision(version: 2)),
Language.English,
NoPreferredWordScore).Should().BeTrue();
}
[Test]
@@ -44,7 +48,9 @@ public void should_return_false_if_current_episode_is_equal_to_cutoff()
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
Cutoff = Language.English
},
new QualityModel(Quality.HDTV720p, new Revision(version: 2)), Language.English).Should().BeFalse();
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
Language.English,
NoPreferredWordScore).Should().BeFalse();
}
[Test]
@@ -61,7 +67,9 @@ public void should_return_false_if_current_episode_is_greater_than_cutoff()
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
Cutoff = Language.English
},
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), Language.English).Should().BeFalse();
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
Language.English,
NoPreferredWordScore).Should().BeFalse();
}
[Test]
@@ -80,7 +88,9 @@ public void should_return_true_when_new_episode_is_proper_but_existing_is_not()
},
new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
Language.English,
new QualityModel(Quality.HDTV720p, new Revision(version: 2))).Should().BeTrue();
NoPreferredWordScore,
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
NoPreferredWordScore).Should().BeTrue();
}
[Test]
@@ -99,13 +109,14 @@ public void should_return_false_if_cutoff_is_met_and_quality_is_higher()
},
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
Language.English,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2))).Should().BeFalse();
NoPreferredWordScore,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
NoPreferredWordScore).Should().BeFalse();
}
[Test]
public void should_return_true_if_quality_cutoff_is_met_and_quality_is_higher_but_language_is_not_met()
{
Profile _profile = new Profile
{
Cutoff = Quality.HDTV720p.Id,
@@ -122,13 +133,14 @@ public void should_return_true_if_quality_cutoff_is_met_and_quality_is_higher_bu
_langProfile,
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
Language.English,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2))).Should().BeTrue();
NoPreferredWordScore,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
NoPreferredWordScore).Should().BeTrue();
}
[Test]
public void should_return_false_if_cutoff_is_met_and_quality_is_higher_and_language_is_met()
{
Profile _profile = new Profile
{
Cutoff = Quality.HDTV720p.Id,
@@ -146,13 +158,14 @@ public void should_return_false_if_cutoff_is_met_and_quality_is_higher_and_langu
_langProfile,
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
Language.Spanish,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2))).Should().BeFalse();
NoPreferredWordScore,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
NoPreferredWordScore).Should().BeFalse();
}
[Test]
public void should_return_false_if_cutoff_is_met_and_quality_is_higher_and_language_is_higher()
{
Profile _profile = new Profile
{
Cutoff = Quality.HDTV720p.Id,
@@ -170,13 +183,14 @@ public void should_return_false_if_cutoff_is_met_and_quality_is_higher_and_langu
_langProfile,
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
Language.French,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2))).Should().BeFalse();
NoPreferredWordScore,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
NoPreferredWordScore).Should().BeFalse();
}
[Test]
public void should_return_true_if_cutoff_is_not_met_and_new_quality_is_higher_and_language_is_higher()
{
Profile _profile = new Profile
{
Cutoff = Quality.HDTV720p.Id,
@@ -194,13 +208,14 @@ public void should_return_true_if_cutoff_is_not_met_and_new_quality_is_higher_an
_langProfile,
new QualityModel(Quality.SDTV, new Revision(version: 2)),
Language.French,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2))).Should().BeTrue();
NoPreferredWordScore,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
NoPreferredWordScore).Should().BeTrue();
}
[Test]
public void should_return_true_if_cutoff_is_not_met_and_language_is_higher()
{
Profile _profile = new Profile
{
Cutoff = Quality.HDTV720p.Id,
@@ -217,7 +232,33 @@ public void should_return_true_if_cutoff_is_not_met_and_language_is_higher()
_profile,
_langProfile,
new QualityModel(Quality.SDTV, new Revision(version: 2)),
Language.French).Should().BeTrue();
Language.French,
NoPreferredWordScore).Should().BeTrue();
}
[Test]
public void should_return_true_if_cutoffs_are_met_and_score_is_higher()
{
Profile _profile = new Profile
{
Cutoff = Quality.HDTV720p.Id,
Items = Qualities.QualityFixture.GetDefaultQualities(),
};
LanguageProfile _langProfile = new LanguageProfile
{
Cutoff = Language.Spanish,
Languages = LanguageFixture.GetDefaultLanguages()
};
Subject.CutoffNotMet(
_profile,
_langProfile,
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
Language.Spanish,
NoPreferredWordScore,
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
10).Should().BeTrue();
}
}
}
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Moq;
@@ -11,6 +11,7 @@
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
using FizzWare.NBuilder;
using NzbDrone.Core.DecisionEngine.Specifications;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
Oops, something went wrong.

0 comments on commit cd919b6

Please sign in to comment.