* fix 001 => 0xSpecial 1 false match issues

@see http://www.filebot.net/forums/viewtopic.php?f=5&t=1399
This commit is contained in:
Reinhard Pointner 2014-03-18 06:08:46 +00:00
parent e6ce233d10
commit deb37c8ffd
2 changed files with 20 additions and 12 deletions

View File

@ -1,7 +1,6 @@
package net.sourceforge.filebot.similarity;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.util.regex.Pattern.*;
import static net.sourceforge.filebot.Settings.*;
@ -62,15 +61,22 @@ public enum EpisodeMetrics implements SimilarityMetric {
if (object instanceof Episode) {
Episode episode = (Episode) object;
if (episode.getSpecial() != null) {
return singleton(new SxE(0, episode.getSpecial()));
}
// get SxE from episode, both SxE for season/episode numbering and SxE for absolute episode numbering
SxE sxe = new SxE(episode.getSeason(), episode.getEpisode());
SxE abs = new SxE(null, episode.getAbsolute());
Set<SxE> sxe = new HashSet<SxE>(2);
result = (abs.episode < 0 || sxe.equals(abs)) ? singleton(sxe) : asList(sxe, abs);
// default SxE numbering
if (episode.getEpisode() != null) {
sxe.add(new SxE(episode.getSeason(), episode.getEpisode()));
}
// absolute numbering
if (episode.getAbsolute() != null) {
sxe.add(new SxE(null, episode.getAbsolute()));
}
// 0xSpecial numbering
if (episode.getSpecial() != null) {
sxe.add(new SxE(0, episode.getSpecial()));
}
result = sxe;
} else {
result = super.parse(object);
}

View File

@ -90,10 +90,12 @@ public class SeasonEpisodeMatcher {
protected Collection<SxE> process(MatchResult match) {
Set<SxE> sxe = new LinkedHashSet<SxE>(2);
// interpret match as season and episode
for (int i = 2; i <= match.groupCount(); i++) {
if (match.group(i) != null) {
sxe.add(new SxE(match.group(1), match.group(i)));
// interpret match as season and episode, but ignore 001 => 0x01 Season 0 matches
if (match.group(1).length() > 0 && Integer.parseInt(match.group(1)) > 0) {
for (int i = 2; i <= match.groupCount(); i++) {
if (match.group(i) != null) {
sxe.add(new SxE(match.group(1), match.group(i)));
}
}
}