From b99500b4050f16bca923aecb6b35a3350ab93fe4 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 21 Oct 2017 23:57:33 +0100 Subject: [PATCH] Improved matching behavior for movie years off by one --- source/net/filebot/media/MediaDetection.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/media/MediaDetection.java b/source/net/filebot/media/MediaDetection.java index 907ba65b..e6c67156 100644 --- a/source/net/filebot/media/MediaDetection.java +++ b/source/net/filebot/media/MediaDetection.java @@ -42,6 +42,7 @@ import java.util.function.Supplier; import java.util.logging.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.IntStream; import net.filebot.ApplicationFolder; import net.filebot.Language; @@ -710,12 +711,7 @@ public class MediaDetection { @Override protected String normalize(Object object) { - Matcher ym = year.matcher(object.toString()); - StringBuilder sb = new StringBuilder(); - while (ym.find()) { - sb.append(ym.group()).append(' '); - } - return sb.toString().trim(); + return streamMatches(object.toString(), year).mapToInt(Integer::parseInt).flatMap(i -> IntStream.of(i, i + 1)).mapToObj(Objects::toString).collect(joining(" ")); } @Override