diff --git a/source/net/filebot/media/ReleaseInfo.java b/source/net/filebot/media/ReleaseInfo.java index 1b9d5879..8362ee84 100644 --- a/source/net/filebot/media/ReleaseInfo.java +++ b/source/net/filebot/media/ReleaseInfo.java @@ -100,15 +100,19 @@ public class ReleaseInfo { // check file and folder for release group names String[] groups = releaseGroup.get(); - // try case-sensitive match - String match = matchLast(getReleaseGroupPattern(true), groups, name); + for (boolean strict : new boolean[] { true, false }) { + String match = matchLast(getReleaseGroupPattern(strict), groups, name); - if (match != null) { - return match; + if (match != null) { + // group pattern does not match closing brackets in GROUP[INDEX] patterns + if (match.lastIndexOf(']') < match.lastIndexOf('[')) { + return match + ']'; + } + return match; + } } - // try case-insensitive match - return matchLast(getReleaseGroupPattern(false), groups, name); + return null; } private Pattern languageTag; diff --git a/test/net/filebot/media/ReleaseInfoTest.java b/test/net/filebot/media/ReleaseInfoTest.java index f276dbba..f4939fa4 100644 --- a/test/net/filebot/media/ReleaseInfoTest.java +++ b/test/net/filebot/media/ReleaseInfoTest.java @@ -20,6 +20,8 @@ public class ReleaseInfoTest { @Test public void getReleaseGroup() throws Exception { assertEquals("aXXo", info.getReleaseGroup("Jurassic.Park[1993]DvDrip-aXXo")); + assertEquals("aXXo", info.getReleaseGroup("Jurassic.Park[1993]DvDrip-[aXXo]")); + assertEquals("aXXo[RARBG]", info.getReleaseGroup("Jurassic.Park[1993]DvDrip-aXXo[RARBG]")); } @Test