* slightly tweak movie name detection

This commit is contained in:
Reinhard Pointner 2012-06-18 17:06:37 +00:00
parent ce339c273d
commit d4b38f918f
1 changed files with 8 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package net.sourceforge.filebot.media;
import static java.util.Collections.*; import static java.util.Collections.*;
import static java.util.regex.Pattern.*;
import static net.sourceforge.filebot.similarity.CommonSequenceMatcher.*; import static net.sourceforge.filebot.similarity.CommonSequenceMatcher.*;
import static net.sourceforge.filebot.similarity.Normalization.*; import static net.sourceforge.filebot.similarity.Normalization.*;
import static net.sourceforge.tuned.FileUtilities.*; import static net.sourceforge.tuned.FileUtilities.*;
@ -301,8 +302,13 @@ public class MediaDetection {
// search by file name or folder name // search by file name or folder name
List<String> terms = new ArrayList<String>(); List<String> terms = new ArrayList<String>();
// 1. term: file // 1. term: try to match movie pattern 'name (year)' or use filename as is
terms.add(getName(movieFile)); 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 // 2. term: first meaningful parent folder
File movieFolder = guessMovieFolder(movieFile); File movieFolder = guessMovieFolder(movieFile);