* fix support for multi-episode 3-digit absolute numbering

@see http://www.filebot.net/forums/viewtopic.php?f=5&t=1877
This commit is contained in:
Reinhard Pointner 2014-08-06 09:52:21 +00:00
parent 83e32123de
commit 58a9e5c747
2 changed files with 25 additions and 4 deletions

View File

@ -9,7 +9,7 @@ import net.filebot.similarity.SeasonEpisodeMatcher;
public class SmartSeasonEpisodeMatcher extends SeasonEpisodeMatcher {
// make sure certain patterns like x264 or 720p will never be interpreted as SxE numbers
private Pattern ignorePattern = new ReleaseInfo().getVideoFormatPattern(false);
private final Pattern ignorePattern = new ReleaseInfo().getVideoFormatPattern(false);
public SmartSeasonEpisodeMatcher(SeasonEpisodeFilter sanity, boolean strict) {
super(sanity, strict);

View File

@ -13,6 +13,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import net.filebot.media.SmartSeasonEpisodeMatcher;
import net.filebot.similarity.SeasonEpisodeMatcher.SxE;
import net.filebot.web.Episode;
import net.filebot.web.MultiEpisode;
@ -48,8 +49,14 @@ public class EpisodeMatcher extends Matcher<File, Object> {
boolean modified = false;
for (Match<File, Object> it : possibleMatches) {
File file = it.getValue();
Set<SxE> uniqueFiles = parseEpisodeIdentifer(file);
Set<SxE> uniqueEpisodes = episodeIdentifierSets.get(file);
Set<Integer> uniqueFiles = normalizeIdentifierSet(parseEpisodeIdentifer(file));
if (uniqueFiles.size() < 2)
continue;
Set<Integer> uniqueEpisodes = normalizeIdentifierSet(episodeIdentifierSets.get(file));
if (uniqueEpisodes.size() < 2)
continue;
if (uniqueFiles.equals(uniqueEpisodes)) {
Episode[] episodes = episodeSets.get(file).toArray(new Episode[0]);
@ -70,7 +77,7 @@ public class EpisodeMatcher extends Matcher<File, Object> {
}
private final SeasonEpisodeMatcher seasonEpisodeMatcher = new SeasonEpisodeMatcher(SeasonEpisodeMatcher.DEFAULT_SANITY, false);
private final SeasonEpisodeMatcher seasonEpisodeMatcher = new SmartSeasonEpisodeMatcher(SeasonEpisodeMatcher.DEFAULT_SANITY, false);
private final Map<File, Set<SxE>> transformCache = synchronizedMap(new HashMap<File, Set<SxE>>(64, 4));
private Set<SxE> parseEpisodeIdentifer(File file) {
@ -90,6 +97,20 @@ public class EpisodeMatcher extends Matcher<File, Object> {
return result;
}
private Set<Integer> normalizeIdentifierSet(Set<SxE> numbers) {
// SxE 1x01 => 101
// Absolute 101 => 101
Set<Integer> identifier = new HashSet<Integer>(numbers.size());
for (SxE it : numbers) {
if (it.season > 0 && it.episode > 0 && it.episode < 100) {
identifier.add(it.season * 100 + it.episode);
} else if (it.season < 0 && it.episode > 0) {
identifier.add(it.episode);
}
}
return identifier;
}
private boolean isMultiEpisode(Episode[] episodes) {
// sanity check that there is valid episode data for at least two episodes
if (episodes.length < 2)