Skip to content

Commit

Permalink
Fixed: (MetadataProfile) Allow usage of Must Not Contain
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Jul 8, 2023
1 parent 484c255 commit 38e3944
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/NzbDrone.Core/Profiles/Metadata/MetadataProfile.cs
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using NzbDrone.Core.Datastore;

namespace NzbDrone.Core.Profiles.Metadata
Expand All @@ -12,6 +13,11 @@ public class MetadataProfile : ModelBase
public bool SkipSeriesSecondary { get; set; }
public string AllowedLanguages { get; set; }
public int MinPages { get; set; }
public string Ignored { get; set; }
public List<string> Ignored { get; set; }

public MetadataProfile()
{
Ignored = new List<string>();
}
}
}
4 changes: 2 additions & 2 deletions src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs
Expand Up @@ -158,7 +158,7 @@ private List<Book> FilterBooks(IEnumerable<Book> remoteBooks, List<Book> localBo
FilterByPredicate(hash, x => x.ForeignBookId, localHash, profile, (x, p) => !p.SkipMissingDate || x.ReleaseDate.HasValue, "release date is missing");
FilterByPredicate(hash, x => x.ForeignBookId, localHash, profile, (x, p) => !p.SkipPartsAndSets || !IsPartOrSet(x, seriesLinks.GetValueOrDefault(x), titles), "book is part of set");
FilterByPredicate(hash, x => x.ForeignBookId, localHash, profile, (x, p) => !p.SkipSeriesSecondary || !seriesLinks.ContainsKey(x) || seriesLinks[x].Any(y => y.IsPrimary), "book is a secondary series item");
FilterByPredicate(hash, x => x.ForeignBookId, localHash, profile, (x, p) => !MatchesTerms(x.Title, p.Ignored), "contains ignored terms");
FilterByPredicate(hash, x => x.ForeignBookId, localHash, profile, (x, p) => !p.Ignored.Any(i => MatchesTerms(x.Title, i)), "contains ignored terms");

foreach (var book in hash)
{
Expand All @@ -184,7 +184,7 @@ private List<Edition> FilterEditions(IEnumerable<Edition> editions, List<Edition

FilterByPredicate(hash, x => x.ForeignEditionId, localHash, profile, (x, p) => !allowedLanguages.Any() || allowedLanguages.Contains(x.Language?.CanonicalizeLanguage()), "edition language not allowed");
FilterByPredicate(hash, x => x.ForeignEditionId, localHash, profile, (x, p) => !p.SkipMissingIsbn || x.Isbn13.IsNotNullOrWhiteSpace() || x.Asin.IsNotNullOrWhiteSpace(), "isbn and asin is missing");
FilterByPredicate(hash, x => x.ForeignEditionId, localHash, profile, (x, p) => !MatchesTerms(x.Title, p.Ignored), "contains ignored terms");
FilterByPredicate(hash, x => x.ForeignEditionId, localHash, profile, (x, p) => !p.Ignored.Any(i => MatchesTerms(x.Title, i)), "contains ignored terms");

return hash.ToList();
}
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class MetadataProfileResource : RestResource
public bool SkipSeriesSecondary { get; set; }
public string AllowedLanguages { get; set; }
public int MinPages { get; set; }
public string Ignored { get; set; }
public List<string> Ignored { get; set; }
}

public static class MetadataProfileResourceMapper
Expand Down

0 comments on commit 38e3944

Please sign in to comment.