* avoid Joe.720p style patterns being recognized as Joe.S7E20 like series patterns

This commit is contained in:
Reinhard Pointner 2014-08-27 06:33:27 +00:00
parent 2dee2c49a0
commit a634abdb85
3 changed files with 26 additions and 8 deletions

View File

@ -28,6 +28,15 @@ public class SmartSeasonEpisodeMatcher extends SeasonEpisodeMatcher {
return super.match(clean(name));
}
@Override
public List<SxE> match(File file) {
return super.match(new File(clean(file.getPath())));
}
public String head(String name) {
return super.head(clean(name));
}
@Override
protected List<String> tokenizeTail(File file) {
List<String> tail = super.tokenizeTail(file);

View File

@ -217,6 +217,14 @@ public class SeasonEpisodeMatcher {
return -1;
}
public String head(String name) {
int seasonEpisodePosition = find(name, 0);
if (seasonEpisodePosition > 0) {
return name.substring(0, seasonEpisodePosition).trim();
}
return null;
}
public static class SxE {
public static final int UNDEFINED = -1;

View File

@ -24,6 +24,7 @@ import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.filebot.media.SmartSeasonEpisodeMatcher;
import net.filebot.similarity.SeasonEpisodeMatcher.SxE;
import net.filebot.util.FileUtilities;
@ -41,7 +42,7 @@ public class SeriesNameMatcher {
}
public SeriesNameMatcher(Locale locale, boolean strict) {
seasonEpisodeMatcher = new SeasonEpisodeMatcher(SeasonEpisodeMatcher.DEFAULT_SANITY, strict);
seasonEpisodeMatcher = new SmartSeasonEpisodeMatcher(SeasonEpisodeMatcher.DEFAULT_SANITY, strict);
dateMatcher = new DateMatcher();
nameSimilarityMetric = new NameSimilarityMetric();
@ -86,9 +87,9 @@ public class SeriesNameMatcher {
// focus chars before the SxE / Date pattern when matching by common word sequence
String[] focus = Arrays.copyOf(names, names.length);
for (int i = 0; i < focus.length; i++) {
int sxePos = seasonEpisodeMatcher.find(focus[i], 0);
if (sxePos >= 0) {
focus[i] = focus[i].substring(0, sxePos);
String beforeSxE = seasonEpisodeMatcher.head(focus[i]);
if (beforeSxE != null && beforeSxE.length() > 0) {
focus[i] = beforeSxE;
} else {
int datePos = dateMatcher.find(focus[i], 0);
if (datePos >= 0) {
@ -189,10 +190,10 @@ public class SeriesNameMatcher {
* @return a substring of the given name that ends before the first occurrence of a season episode pattern, or null if there is no such pattern
*/
public String matchByEpisodeIdentifier(String name) {
int seasonEpisodePosition = seasonEpisodeMatcher.find(name, 0);
if (seasonEpisodePosition > 0) {
// series name ends at the first season episode pattern
return normalizePunctuation(name.substring(0, seasonEpisodePosition));
// series name ends at the first season episode pattern
String seriesName = seasonEpisodeMatcher.head(name);
if (seriesName != null && seriesName.length() > 0) {
return normalizePunctuation(seriesName);
}
int datePosition = dateMatcher.find(name, 0);