1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-21 23:38:50 -05:00

More lenient XEM series name matching

This commit is contained in:
Reinhard Pointner 2019-06-07 22:08:06 +07:00
parent 53323a8dfa
commit ffa0690bfc
3 changed files with 10 additions and 14 deletions

View File

@ -285,16 +285,12 @@ public class EpisodeMetrics {
}
protected String[] getNormalizedEffectiveIdentifiers(Object object) {
List<?> identifiers = getEffectiveIdentifiers(object);
String[] names = new String[identifiers.size()];
for (int i = 0; i < names.length; i++) {
names[i] = normalizeObject(identifiers.get(i));
}
return names;
return getEffectiveIdentifiers(object).stream().map(it -> {
return normalizeObject(it);
}).toArray(String[]::new);
}
protected List<?> getEffectiveIdentifiers(Object object) {
protected Collection<?> getEffectiveIdentifiers(Object object) {
if (object instanceof Episode) {
return ((Episode) object).getSeriesNames();
} else if (object instanceof Movie) {
@ -302,7 +298,7 @@ public class EpisodeMetrics {
} else if (object instanceof File) {
return listPathTail((File) object, 3, true);
}
return singletonList(object);
return singleton(object);
}
@Override

View File

@ -1,7 +1,6 @@
package net.filebot.web;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
@ -95,7 +94,7 @@ public class Episode implements Serializable {
return Arrays.asList(season, episode, special, absolute);
}
public List<String> getSeriesNames() {
public Set<String> getSeriesNames() {
Set<String> names = new LinkedHashSet<String>();
if (seriesName != null) {
names.add(seriesName);
@ -110,7 +109,7 @@ public class Episode implements Serializable {
}
}
}
return new ArrayList<String>(names);
return names;
}
@Override

View File

@ -49,13 +49,14 @@ public enum XEM {
return Optional.empty();
}
String seriesName = episode.getSeriesName();
Set<String> seriesNames = episode.getSeriesNames();
Integer season = getSeason(episode.getSeason());
Map<String, List<String>> names = getNames(seriesId);
debug.finest(format("[XEM] %s", names));
Integer mappedSeason = names.entrySet().stream().filter(it -> {
return it.getValue().contains(seriesName);
return it.getValue().stream().anyMatch(seriesNames::contains);
}).map(it -> {
return matchInteger(it.getKey());
}).filter(Objects::nonNull).findFirst().orElse(season);