Refactor ImageMetadata API

This commit is contained in:
Reinhard Pointner 2017-02-26 04:26:15 +08:00
parent 24d04178a3
commit 2c7c32472e
1 changed files with 7 additions and 1 deletions

View File

@ -1,7 +1,10 @@
package net.filebot.mediainfo; package net.filebot.mediainfo;
import static java.nio.charset.StandardCharsets.*; import static java.nio.charset.StandardCharsets.*;
import static java.util.regex.Pattern.*;
import static java.util.stream.Collectors.*;
import static net.filebot.Logging.*; import static net.filebot.Logging.*;
import static net.filebot.util.StringUtilities.*;
import java.io.Closeable; import java.io.Closeable;
import java.io.File; import java.io.File;
@ -12,6 +15,7 @@ import java.util.EnumMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream;
import com.sun.jna.Platform; import com.sun.jna.Platform;
import com.sun.jna.Pointer; import com.sun.jna.Pointer;
@ -154,7 +158,9 @@ public class MediaInfo implements Closeable {
if (streamKind == StreamKind.Image && streamNumber == 0) { if (streamKind == StreamKind.Image && streamNumber == 0) {
String path = get(StreamKind.General, 0, "CompleteName"); String path = get(StreamKind.General, 0, "CompleteName");
try { try {
streamInfo.putAll(new ImageMetadata(new File(path))); streamInfo.putAll(new ImageMetadata(new File(path)).snapshot(t -> {
return Stream.of(t.getDirectoryName(), t.getTagName()).flatMap(s -> tokenize(s, compile("\\W+"))).distinct().collect(joining("_"));
}));
} catch (Throwable e) { } catch (Throwable e) {
debug.warning(format("%s: %s", e, path)); debug.warning(format("%s: %s", e, path));
} }