1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

Fine-tune release group matching and cleanup

This commit is contained in:
Reinhard Pointner 2016-03-29 13:02:49 +00:00
parent 91ed090da1
commit d88fd57e9f
2 changed files with 23 additions and 7 deletions

View File

@ -95,19 +95,19 @@ public class ReleaseInfo {
return null;
}
public String getReleaseGroup(String... strings) throws Exception {
public String getReleaseGroup(String... name) throws Exception {
// check file and folder for release group names
String[] groups = releaseGroup.get();
// try case-sensitive match
String match = matchLast(getReleaseGroupPattern(true), groups, strings);
String match = matchLast(getReleaseGroupPattern(true), groups, name);
if (match != null) {
return match;
}
// try case-insensitive match
return matchLast(getReleaseGroupPattern(false), groups, strings);
return matchLast(getReleaseGroupPattern(false), groups, name);
}
private Pattern languageTag;
@ -177,8 +177,8 @@ public class ReleaseInfo {
Pattern resolution = getResolutionPattern();
Pattern queryBlacklist = getBlacklistPattern();
stopwords[b] = new Pattern[] { languageTag, videoSource, videoTags, videoFormat, resolution, stereoscopic3d, languageSuffix };
blacklist[b] = new Pattern[] { releaseGroupTrim, queryBlacklist, languageTag, clutterBracket, releaseGroup, videoSource, videoTags, videoFormat, resolution, stereoscopic3d, languageSuffix };
stopwords[b] = new Pattern[] { languageSuffix, languageTag, videoSource, videoTags, videoFormat, resolution, stereoscopic3d };
blacklist[b] = new Pattern[] { languageSuffix, releaseGroupTrim, queryBlacklist, languageTag, clutterBracket, releaseGroup, videoSource, videoTags, videoFormat, resolution, stereoscopic3d };
}
return items.stream().map(it -> {
@ -324,8 +324,13 @@ public class ReleaseInfo {
}
public Pattern getReleaseGroupPattern(boolean strict) throws Exception {
// pattern matching any release group name enclosed in separators
return compile("((?<!\\p{Alnum})" + or(releaseGroup.get()) + "(?!\\p{Alnum}|[^\\p{Alnum}](19|20)\\d{2})($|[\\p{Punct}]))+", strict ? 0 : CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS);
// match 1..N group patterns
String group = "((?<!\\p{Alnum})" + or(releaseGroup.get()) + "(?!\\p{Alnum})[\\p{Punct}]??)+";
// group pattern at beginning or ending of the string
String[] groupHeadTail = { "(?<=^[^\\p{Alnum}]*)" + group, group + "(?=[\\p{Alpha}\\p{Punct}]*$)" };
return compile(or(groupHeadTail), strict ? 0 : CASE_INSENSITIVE | UNICODE_CHARACTER_CLASS);
}
public Pattern getReleaseGroupTrimPattern() throws Exception {

View File

@ -21,6 +21,17 @@ public class ReleaseInfoTest {
assertEquals("aXXo", info.getReleaseGroup("Jurassic.Park[1993]DvDrip-aXXo"));
}
@Test
public void getReleaseGroupWithSubs() throws Exception {
assertEquals("aXXo", info.getReleaseGroup("Jurassic.Park[1993]DvDrip-aXXo.eng-forced"));
}
@Test
public void getReleaseGroupFalseNegative() throws Exception {
assertEquals(null, info.getReleaseGroup("The.aXXo.Movie.2005"));
assertEquals(null, info.getReleaseGroup("The aXXo Movie"));
}
@Test
public void getClutterBracketPattern() throws Exception {
assertEquals("John [2016] (ENG)", clean(info.getClutterBracketPattern(true), "John [2016] [Action, Drama] (ENG)"));