1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-10 11:25:04 -05:00

* avoid printStackTrace in favour of logging

This commit is contained in:
Reinhard Pointner 2015-05-25 08:37:57 +00:00
parent 579a6dc894
commit fbbb99a5b9
2 changed files with 11 additions and 9 deletions

View File

@ -11,6 +11,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.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.sun.jna.NativeLibrary; import com.sun.jna.NativeLibrary;
@ -55,6 +56,7 @@ public class MediaInfo implements Closeable {
try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
return openViaBuffer(raf); return openViaBuffer(raf);
} catch (IOException e) { } catch (IOException e) {
Logger.getLogger(MediaInfo.class.getName()).log(Level.WARNING, e.toString());
return false; return false;
} }
} }

View File

@ -8,6 +8,8 @@ import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -82,9 +84,8 @@ public enum SubtitleMetrics implements SimilarityMetric {
}; };
private Map<String, Object> getSubtitleProperties(OpenSubtitlesSubtitleDescriptor subtitle) { private Map<String, Object> getSubtitleProperties(OpenSubtitlesSubtitleDescriptor subtitle) {
Map<String, Object> props = new HashMap<String, Object>();
try { try {
Map<String, Object> props = new HashMap<String, Object>();
float fps = Math.round(subtitle.getMovieFPS()); // round because most FPS values in the database are bad anyway float fps = Math.round(subtitle.getMovieFPS()); // round because most FPS values in the database are bad anyway
if (fps > 0) { if (fps > 0) {
props.put(FPS, fps); props.put(FPS, fps);
@ -93,11 +94,11 @@ public enum SubtitleMetrics implements SimilarityMetric {
if (seconds > 0) { if (seconds > 0) {
props.put(SECONDS, seconds); props.put(SECONDS, seconds);
} }
} catch (Exception e) {
e.printStackTrace();
}
return props; return props;
} catch (Exception e) {
Logger.getLogger(SubtitleMetrics.class.getName()).log(Level.WARNING, e.toString());
}
return emptyMap();
} }
private final Map<File, Map<String, Object>> mediaInfoCache = new WeakHashMap<File, Map<String, Object>>(64); private final Map<File, Map<String, Object>> mediaInfoCache = new WeakHashMap<File, Map<String, Object>>(64);
@ -107,7 +108,6 @@ public enum SubtitleMetrics implements SimilarityMetric {
return mediaInfoCache.computeIfAbsent(file, (f) -> { return mediaInfoCache.computeIfAbsent(file, (f) -> {
try { try {
Map<String, Object> props = new HashMap<String, Object>(); Map<String, Object> props = new HashMap<String, Object>();
MediaInfo mediaInfo = new MediaInfo(); MediaInfo mediaInfo = new MediaInfo();
if (mediaInfo.open(file)) { if (mediaInfo.open(file)) {
float fps = Math.round(Float.parseFloat(mediaInfo.get(StreamKind.Video, 0, "FrameRate"))); float fps = Math.round(Float.parseFloat(mediaInfo.get(StreamKind.Video, 0, "FrameRate")));
@ -118,12 +118,12 @@ public enum SubtitleMetrics implements SimilarityMetric {
if (seconds > 0) { if (seconds > 0) {
props.put(SECONDS, seconds); props.put(SECONDS, seconds);
} }
}
return props; return props;
} catch (Exception e) {
return emptyMap();
} }
} catch (Exception e) {
Logger.getLogger(SubtitleMetrics.class.getName()).log(Level.WARNING, e.toString());
}
return emptyMap();
}); });
} }
} }