Make sure that CD1/2 detection always works regardless of media folder structure by relying exclusively on MediaInfo characteristics instead of (guessed) media folder

@see https://www.filebot.net/forums/viewtopic.php?f=4&t=4845
This commit is contained in:
Reinhard Pointner 2017-04-09 12:28:00 +08:00
parent 771c2e8c4a
commit b17e71dc38
1 changed files with 24 additions and 28 deletions

View File

@ -30,6 +30,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
@ -1094,13 +1095,7 @@ public class MediaDetection {
return;
}
mapByMediaFolder(filesByExtension).forEach((mediaFolder, filesByMediaFolder) -> {
if (filesByMediaFolder.size() < 2) {
groups.add(filesByMediaFolder);
return;
}
filesByMediaFolder.stream().collect(groupingBy(f -> {
filesByExtension.stream().collect(groupingBy(f -> {
if (VIDEO_FILES.accept(f) && f.length() > ONE_MEGABYTE) {
try (MediaInfo mi = new MediaInfo().open(f)) {
String v = mi.get(StreamKind.Video, 0, "Codec");
@ -1121,10 +1116,11 @@ public class MediaDetection {
debug.warning(format("Failed to detect subtitle language: %s", e.getMessage()));
}
}
return emptyList();
// default to grouping by most likely media folder
return Optional.ofNullable(guessMediaFolder(f)).map(File::getName);
}, LinkedHashMap::new, toList())).forEach((group, videos) -> groups.add(videos));
});
});
return groups;
}