MediaInfoScanner { public void updateMovieInfo(Movie movie, Map<String, String> infosGeneral, List<Map<String, String>> infosVideo, List<Map<String, String>> infosAudio, List<Map<String, String>> infosText, Map<String, String> infosMultiPart) { String infoValue; if (ENABLE_METADATA) { processMetaData(movie, infosGeneral); } if (OverrideTools.checkOverwriteContainer(movie, MEDIAINFO_PLUGIN_ID)) { infoValue = infosGeneral.get("Format"); movie.setContainer(infoValue, MEDIAINFO_PLUGIN_ID); } if (OverrideTools.checkOverwriteRuntime(movie, MEDIAINFO_PLUGIN_ID)) { int duration = getDuration(infosGeneral, infosVideo); duration = duration + getMultiPartDuration(infosMultiPart); if (duration > 0) { duration = duration / 1000; movie.setRuntime(DateTimeTools.formatDuration(duration), MEDIAINFO_PLUGIN_ID); } } if (!infosVideo.isEmpty()) { movie.getCodecs().clear(); Map<String, String> infosMainVideo = infosVideo.get(0); Codec codecToAdd = getCodecInfo(CodecType.VIDEO, infosMainVideo); if (MI_OVERALL_BITRATE && StringTools.isNotValidString(codecToAdd.getCodecBitRate())) { infoValue = infosGeneral.get(Codec.MI_CODEC_OVERALL_BITRATE); if (StringUtils.isNotBlank(infoValue) && infoValue.length() > 3) { infoValue = infoValue.substring(0, infoValue.length() - 3); codecToAdd.setCodecBitRate(infoValue); } } movie.addCodec(codecToAdd); if (OverrideTools.checkOverwriteResolution(movie, MEDIAINFO_PLUGIN_ID)) { String width = infosMainVideo.get("Width"); String height = infosMainVideo.get("Height"); movie.setResolution(width, height, MEDIAINFO_PLUGIN_ID); } if (OverrideTools.checkOverwriteFPS(movie, MEDIAINFO_PLUGIN_ID)) { infoValue = infosMainVideo.get("Frame rate"); if (infoValue == null) { infoValue = infosMainVideo.get("Original frame rate"); } if (infoValue != null) { int inxDiv = infoValue.indexOf(Movie.SPACE_SLASH_SPACE); if (inxDiv > -1) { infoValue = infoValue.substring(0, inxDiv); } movie.setFps(NumberUtils.toFloat(infoValue, 0.0F), MEDIAINFO_PLUGIN_ID); } } if (OverrideTools.checkOverwriteAspectRatio(movie, MEDIAINFO_PLUGIN_ID)) { infoValue = infosMainVideo.get("Display aspect ratio"); if (infoValue != null) { movie.setAspectRatio(ASPECT_TOOLS.cleanAspectRatio(infoValue), MEDIAINFO_PLUGIN_ID); } } if (OverrideTools.checkOverwriteVideoOutput(movie, MEDIAINFO_PLUGIN_ID)) { if (movie.isHD()) { StringBuilder normeHD = new StringBuilder(); if (movie.isHD1080()) { normeHD.append("1080"); } else { normeHD.append("720"); } infoValue = infosMainVideo.get("Scan type"); if (infoValue != null) { if ("Progressive".equals(infoValue)) { normeHD.append("p"); } else { normeHD.append("i"); } } normeHD.append(" ").append(Math.round(movie.getFps())).append("Hz"); movie.setVideoOutput(normeHD.toString(), MEDIAINFO_PLUGIN_ID); } else { StringBuilder videoOutput = new StringBuilder(); switch (Math.round(movie.getFps())) { case 24: videoOutput.append("24"); break; case 25: videoOutput.append("PAL 25"); break; case 30: videoOutput.append("NTSC 30"); break; case 50: videoOutput.append("PAL 50"); break; case 60: videoOutput.append("NTSC 60"); break; default: videoOutput.append("NTSC"); break; } infoValue = infosMainVideo.get("Scan type"); if (infoValue != null) { if ("Progressive".equals(infoValue)) { videoOutput.append("p"); } else { videoOutput.append("i"); } } movie.setVideoOutput(videoOutput.toString(), MEDIAINFO_PLUGIN_ID); } } if (OverrideTools.checkOverwriteVideoSource(movie, MEDIAINFO_PLUGIN_ID)) { infoValue = infosMainVideo.get("MultiView_Count"); if ("2".equals(infoValue)) { movie.setVideoSource("3D", MEDIAINFO_PLUGIN_ID); } } } Set<String> foundLanguages = new HashSet<>(); for (Map<String, String> infosCurAudio : infosAudio) { infoValue = infosCurAudio.get("Language"); if (infoValue != null) { if (infoValue.contains("/")) { infoValue = infoValue.substring(0, infoValue.indexOf('/')).trim(); } String determineLanguage = MovieFilenameScanner.determineLanguage(infoValue); foundLanguages.add(determineLanguage); } Codec codecToAdd = getCodecInfo(CodecType.AUDIO, infosCurAudio); movie.addCodec(codecToAdd); } if (OverrideTools.checkOverwriteLanguage(movie, MEDIAINFO_PLUGIN_ID)) { StringBuilder movieLanguage = new StringBuilder(); for (String language : foundLanguages) { if (movieLanguage.length() > 0) { movieLanguage.append(LANG_DELIM); } movieLanguage.append(language); } if (StringTools.isValidString(movieLanguage.toString())) { movie.setLanguage(movieLanguage.toString(), MEDIAINFO_PLUGIN_ID); } else if (StringTools.isValidString(AUDIO_LANG_UNKNOWN)) { String determineLanguage = MovieFilenameScanner.determineLanguage(AUDIO_LANG_UNKNOWN); movie.setLanguage(determineLanguage, MEDIAINFO_PLUGIN_ID); } } for (Map<String, String> infosCurText : infosText) { String infoLanguage = ""; infoValue = infosCurText.get("Language"); if (StringTools.isNotValidString(infoValue)) { infoValue = "UNDEFINED"; } if (StringTools.isValidString(infoValue)) { if (infoValue.contains("/")) { infoValue = infoValue.substring(0, infoValue.indexOf('/')).trim(); } infoLanguage = MovieFilenameScanner.determineLanguage(infoValue); } String infoFormat = ""; infoValue = infosCurText.get("Format"); if (StringTools.isValidString(infoValue)) { infoFormat = infoValue; } else { infoValue = infosCurText.get("Codec"); if (StringTools.isValidString(infoValue)) { infoFormat = infoValue; } } if (StringTools.isValidString(infoFormat) && StringTools.isValidString(infoLanguage)) { if ("SRT".equalsIgnoreCase(infoFormat) || "UTF-8".equalsIgnoreCase(infoFormat) || "RLE".equalsIgnoreCase(infoFormat) || "PGS".equalsIgnoreCase(infoFormat) || "ASS".equalsIgnoreCase(infoFormat) || "VobSub".equalsIgnoreCase(infoFormat)) { SubtitleTools.addMovieSubtitle(movie, infoLanguage); } else { LOG.debug("Subtitle format skipped: {}", infoFormat); } } } } MediaInfoScanner(); boolean extendedExtension(String filename); void update(Movie currentMovie); void scan(Movie currentMovie); void updateMovieInfo(Movie movie, Map<String, String> infosGeneral, List<Map<String, String>> infosVideo,
            List<Map<String, String>> infosAudio, List<Map<String, String>> infosText,
            Map<String, String> infosMultiPart); String archiveScan(String movieFilePath); static final String OS_NAME; static final String OS_VERSION; static final String OS_ARCH; }
@Test public void testStaticFile() { LOG.info("StaticFile"); getMediaInfoTestFile("mediainfo-ts-2d.txt", true); Movie movie = new Movie(); MI_TEST.updateMovieInfo(movie, infosGeneral, infosVideo, infosAudio, infosText, infosGeneral); LOG.info("Runtime: {}", movie.getRuntime()); assertEquals("Wrong runtime", "1h 54m", movie.getRuntime()); }