From d4b38f918f6448835a59382e1450058ee5f0ae11 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 18 Jun 2012 17:06:37 +0000 Subject: [PATCH] * slightly tweak movie name detection --- .../net/sourceforge/filebot/media/MediaDetection.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 139c40bb..ad0f1680 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -3,6 +3,7 @@ package net.sourceforge.filebot.media; import static java.util.Collections.*; +import static java.util.regex.Pattern.*; import static net.sourceforge.filebot.similarity.CommonSequenceMatcher.*; import static net.sourceforge.filebot.similarity.Normalization.*; import static net.sourceforge.tuned.FileUtilities.*; @@ -301,8 +302,13 @@ public class MediaDetection { // search by file name or folder name List terms = new ArrayList(); - // 1. term: file - terms.add(getName(movieFile)); + // 1. term: try to match movie pattern 'name (year)' or use filename as is + Matcher nameMatcher = compile("^(.+?)[(]((?:19|20)\\d{2})[)]").matcher(movieFile.getName()); + if (nameMatcher.find()) { + terms.add(String.format("%s (%s)", nameMatcher.group(1).trim(), nameMatcher.group(2))); + } else { + terms.add(getName(movieFile)); + } // 2. term: first meaningful parent folder File movieFolder = guessMovieFolder(movieFile);