* fix bugs in the multi-episode logic

This commit is contained in:
Reinhard Pointner 2012-03-20 18:18:34 +00:00
parent 3326a30735
commit 8ea81bfa68
3 changed files with 26 additions and 9 deletions

View File

@ -52,7 +52,10 @@ names += anime.findResults{ it.getPrimaryTitle() }
names += anime.findResults{ it.getOfficialTitle('en') }
names = names.findAll{ it =~ /^[A-Z0-9]/ && it =~ /[\p{Alpha}]{3}/}.findResults{ net.sourceforge.filebot.similarity.Normalization.normalizePunctuation(it) }
names = names.sort().unique()
def unique = new TreeSet(String.CASE_INSENSITIVE_ORDER)
unique.addAll(names)
names = unique as List
gz(s_out, names)

View File

@ -9,7 +9,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -49,19 +48,33 @@ public class EpisodeMatcher extends Matcher<File, Object> {
episodeIdentifierSets.put(it.getKey(), sxe);
}
for (Iterator<Match<File, Object>> itr = possibleMatches.iterator(); itr.hasNext();) {
File file = itr.next().getValue();
boolean modified = false;
for (Match<File, Object> it : possibleMatches) {
File file = it.getValue();
Set<SxE> uniqueFiles = parseEpisodeIdentifer(file);
Set<SxE> uniqueEpisodes = episodeIdentifierSets.get(file);
if (uniqueFiles.equals(uniqueEpisodes)) {
MultiEpisode episode = new MultiEpisode(episodeSets.get(file).toArray(new Episode[0]));
disjointMatchCollection.add(new Match<File, Object>(file, episode));
itr.remove();
Episode[] episodes = episodeSets.get(file).toArray(new Episode[0]);
Set<String> seriesNames = new HashSet<String>();
for (Episode ep : episodes) {
seriesNames.add(ep.getSeriesName());
}
if (seriesNames.size() == 1) {
MultiEpisode episode = new MultiEpisode(episodes);
disjointMatchCollection.add(new Match<File, Object>(file, episode));
modified = true;
}
}
}
if (modified) {
removeCollected(possibleMatches);
}
super.deepMatch(possibleMatches, level);
}

View File

@ -96,8 +96,9 @@ public enum EpisodeMetrics implements SimilarityMetric {
Episode e = (Episode) object;
// don't use title for matching if title equals series name
if (!e.getSeriesName().toLowerCase().contains(e.getTitle().toLowerCase())) {
object = e.getTitle();
String normalizedToken = normalizeObject(e.getTitle());
if (normalizedToken.length() >= 3 && !normalizeObject(e.getSeriesName()).contains(normalizedToken)) {
return normalizedToken;
}
}