From 49b6a822babe5d589cf615aae22eee9e835e72b5 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 13 Jun 2019 20:08:26 +0700 Subject: [PATCH] Improved matching between AniDB and TheTVDB mappings on XEM: https://www.filebot.net/forums/viewtopic.php?f=6&t=6037&p=44576#p44576 --- source/net/filebot/web/XEM.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/net/filebot/web/XEM.java b/source/net/filebot/web/XEM.java index 2435a6d7..03cc213e 100644 --- a/source/net/filebot/web/XEM.java +++ b/source/net/filebot/web/XEM.java @@ -4,6 +4,7 @@ import static java.util.Arrays.*; import static java.util.Collections.*; import static java.util.stream.Collectors.*; import static net.filebot.Logging.*; +import static net.filebot.similarity.Normalization.*; import static net.filebot.util.JsonUtilities.*; import static net.filebot.util.StringUtilities.*; import static net.filebot.web.WebRequest.*; @@ -58,6 +59,10 @@ public enum XEM { return values == null || values.isEmpty() ? null : values.get(0); } + private String normalizeSeriesName(String n) { + return normalizePunctuation(n).toLowerCase(); + } + protected final Resource> haveMap = Resource.lazy(this::getHaveMap); public Optional map(Episode episode, XEM destination) throws Exception { @@ -67,14 +72,14 @@ public enum XEM { return Optional.empty(); } - String seriesName = episode.getSeriesName(); + String seriesName = normalizeSeriesName(episode.getSeriesName()); Integer season = getSeason(episode.getSeason()); Map> names = getNames(seriesId); debug.finest(format("[XEM] %s", names)); Integer mappedSeason = names.entrySet().stream().filter(it -> { - return it.getValue().stream().anyMatch(seriesName::equals); + return it.getValue().stream().map(this::normalizeSeriesName).anyMatch(seriesName::equals); }).map(it -> { return matchInteger(it.getKey()); }).filter(Objects::nonNull).findFirst().orElse(season);