Fixed: (Cardigann) Implement validate as field filter

pull/1471/head
Bogdan 2 years ago
parent 888b514dd8
commit d397cdf5fb

@ -747,18 +747,20 @@ namespace NzbDrone.Core.Indexers.Cardigann
// for debugging
var debugData = data.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\xA0", "\\xA0");
var strTag = (string)filter.Args;
if (strTag != null)
{
strTag = string.Format("({0}):", strTag);
}
else
{
strTag = ":";
}
strTag = strTag != null ? $"({strTag}):" : ":";
_logger.Debug(string.Format("CardigannIndexer ({0}): strdump{1} {2}", _definition.Id, strTag, debugData));
_logger.Debug($"CardigannIndexer ({_definition.Id}): strdump{strTag} {debugData}");
break;
case "validate":
char[] delimiters = { ',', ' ', '/', ')', '(', '.', ';', '[', ']', '"', '|', ':' };
var args = (string)filter.Args;
var argsList = args.ToLower().Split(delimiters, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
var validList = argsList.ToList();
var validIntersect = validList.Intersect(data.ToLower().Split(delimiters, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)).ToList();
data = string.Join(", ", validIntersect);
break;
default:
_logger.Error($"CardigannIndexer ({_definition.Id}): Unsupported field filter: {filter.Name}");
break;
}
}

@ -585,8 +585,12 @@ namespace NzbDrone.Core.Indexers.Cardigann
value = release.PosterUrl;
break;
case "genre":
release.Genres ??= new List<string>();
char[] delimiters = { ',', ' ', '/', ')', '(', '.', ';', '[', ']', '"', '|', ':' };
release.Genres = release.Genres.Union(value.Split(delimiters, System.StringSplitOptions.RemoveEmptyEntries)).ToList();
release.Genres = release.Genres
.Union(value.Split(delimiters, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries))
.Select(x => x.Replace("_", " "))
.ToList();
value = string.Join(", ", release.Genres);
break;
case "year":
@ -632,29 +636,14 @@ namespace NzbDrone.Core.Indexers.Cardigann
switch (filter.Name)
{
case "andmatch":
var characterLimit = -1;
if (filter.Args != null)
{
characterLimit = int.Parse(filter.Args);
}
var queryKeywords = variables[".Keywords"] as string;
// See IndexerBase.FilterReleasesByQuery
break;
case "strdump":
// for debugging
_logger.Debug(string.Format("CardigannIndexer ({0}): row strdump: {1}", _definition.Id, row.ToString()));
break;
case "validate":
char[] delimiters = { ',', ' ', '/', ')', '(', '.', ';', '[', ']', '"', '|', ':' };
var args = (string)filter.Args;
var argsList = args.ToLower().Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
var validList = argsList.ToList();
var validIntersect = validList.Intersect(row.ToString().ToLower().Split(delimiters, StringSplitOptions.RemoveEmptyEntries)).ToList();
row = string.Join(", ", validIntersect);
_logger.Debug($"CardigannIndexer ({_definition.Id}): row strdump: {row}");
break;
default:
_logger.Error(string.Format("CardigannIndexer ({0}): Unsupported rows filter: {1}", _definition.Id, filter.Name));
_logger.Error($"CardigannIndexer ({_definition.Id}): Unsupported rows filter: {filter.Name}");
break;
}
}

Loading…
Cancel
Save