From cb10a44ce4558ce1ac8eed10ce8d9719104021dc Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 19 Feb 2014 20:28:00 +0000 Subject: [PATCH] * improve {group} name extraction --- .../filebot/format/MediaBindingBean.java | 20 ++++++++++++++++++- .../filebot/media/ReleaseInfo.java | 4 ++++ .../filebot/similarity/Normalization.java | 4 ++++ website/data/release-groups.txt | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/source/net/sourceforge/filebot/format/MediaBindingBean.java b/source/net/sourceforge/filebot/format/MediaBindingBean.java index 0752b5f4..69375c32 100644 --- a/source/net/sourceforge/filebot/format/MediaBindingBean.java +++ b/source/net/sourceforge/filebot/format/MediaBindingBean.java @@ -419,8 +419,26 @@ public class MediaBindingBean { // use inferred media file File inferredMediaFile = getInferredMediaFile(); + // consider foldername, filename and original filename + String[] filenames = new String[] { inferredMediaFile.getParentFile().getName(), inferredMediaFile.getName(), getOriginalFileName(inferredMediaFile) }; + + // reduce false positives by removing the know titles from the name + List titles = new ArrayList(); + titles.add(getName()); + titles.add(getYear().toString()); + titles.addAll(getAliasNames()); + Pattern nonGroupPattern = releaseInfo.getCustomRemovePattern(titles); + + for (int i = 0; i < filenames.length; i++) { + if (filenames[i] == null) + continue; + + // normalize space characters + filenames[i] = nonGroupPattern.matcher(normalizeSpace(filenames[i], " ")).replaceAll(""); + } + // look for release group names in media file and it's parent folder - return releaseInfo.getReleaseGroup(inferredMediaFile.getParent(), inferredMediaFile.getName(), getOriginalFileName(inferredMediaFile)); + return releaseInfo.getReleaseGroup(filenames); } @Define("lang") diff --git a/source/net/sourceforge/filebot/media/ReleaseInfo.java b/source/net/sourceforge/filebot/media/ReleaseInfo.java index 7a31ff68..f343c8e8 100644 --- a/source/net/sourceforge/filebot/media/ReleaseInfo.java +++ b/source/net/sourceforge/filebot/media/ReleaseInfo.java @@ -266,6 +266,10 @@ public class ReleaseInfo { return compile(join(excludeBlacklistResource.get(), "|"), CASE_INSENSITIVE | UNICODE_CASE); } + public Pattern getCustomRemovePattern(Collection terms) throws IOException { + return compile("(?