From 6a2e1a61d9bbf8ed692d54a1fdb91745bb7ec895 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 20 Mar 2016 21:21:08 +0000 Subject: [PATCH] Support multi-release-group patterns (e.g. FUM[ettv] or lol[ettv]) --- source/net/filebot/media/ReleaseInfo.java | 23 +++++++++---------- .../net/filebot/similarity/Normalization.java | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/source/net/filebot/media/ReleaseInfo.java b/source/net/filebot/media/ReleaseInfo.java index 06624af5..d69dd9d8 100644 --- a/source/net/filebot/media/ReleaseInfo.java +++ b/source/net/filebot/media/ReleaseInfo.java @@ -102,12 +102,12 @@ public class ReleaseInfo { // try case-sensitive match String match = matchLast(getReleaseGroupPattern(true), groups, strings); - // try case-insensitive match as fallback - if (match == null) { - match = matchLast(getReleaseGroupPattern(false), groups, strings); + if (match != null) { + return match; } - return match; + // try case-insensitive match + return matchLast(getReleaseGroupPattern(false), groups, strings); } private Map languages; @@ -121,13 +121,14 @@ public class ReleaseInfo { } String lang = matchLast(languageSuffix, null, name); - if (lang == null) + if (lang == null) { return null; + } return languages.get(lang); } - protected String matchLast(Pattern pattern, String[] standardValues, CharSequence... sequence) { + protected String matchLast(Pattern pattern, String[] paragon, CharSequence... sequence) { String lastMatch = null; // match last occurrence @@ -142,11 +143,9 @@ public class ReleaseInfo { } // prefer standard value over matched value - if (lastMatch != null && standardValues != null) { - for (String standard : standardValues) { - if (standard.equalsIgnoreCase(lastMatch)) { - return standard; - } + if (lastMatch != null && paragon != null) { + for (String it : paragon) { + lastMatch = compile("(?