From 9aeb85402426421541bec5b8103c2e0dedac16a1 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 19 Feb 2017 22:27:25 +0800 Subject: [PATCH] Use "inferred media file" logic when retrieving MediaInfo for image files linked to video files (i.e. the same as with subtitle files) --- source/net/filebot/MediaTypes.java | 1 + source/net/filebot/MediaTypes.properties | 3 +++ source/net/filebot/format/MediaBindingBean.java | 16 +++++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source/net/filebot/MediaTypes.java b/source/net/filebot/MediaTypes.java index 14aa38e4..034ad239 100644 --- a/source/net/filebot/MediaTypes.java +++ b/source/net/filebot/MediaTypes.java @@ -63,6 +63,7 @@ public class MediaTypes { public static final ExtensionFileFilter AUDIO_FILES = getCategoryFilter("audio"); public static final ExtensionFileFilter VIDEO_FILES = getCategoryFilter("video"); public static final ExtensionFileFilter SUBTITLE_FILES = getCategoryFilter("subtitle"); + public static final ExtensionFileFilter IMAGE_FILES = getCategoryFilter("image"); public static final ExtensionFileFilter ARCHIVE_FILES = getCategoryFilter("archive"); public static final ExtensionFileFilter VERIFICATION_FILES = getCategoryFilter("verification"); diff --git a/source/net/filebot/MediaTypes.properties b/source/net/filebot/MediaTypes.properties index d0455b11..7531ea52 100644 --- a/source/net/filebot/MediaTypes.properties +++ b/source/net/filebot/MediaTypes.properties @@ -47,3 +47,6 @@ subtitle/SubStationAlpha: ssa ass subtitle/SAMI: smi sami subtitle/WebVTT: vtt subtitle/VobSub: vobsub sub idx + +image/jpg: jpg jpeg +image/png: png diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index dfcf5df2..b02ff6f1 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -1008,13 +1008,15 @@ public class MediaBindingBean { } public File getInferredMediaFile() { - if (getMediaFile().isDirectory()) { + File file = getMediaFile(); + + if (file.isDirectory()) { // just select the first video file in the folder as media sample - List videos = listFiles(getMediaFile(), VIDEO_FILES, CASE_INSENSITIVE_PATH_ORDER); + List videos = listFiles(file, VIDEO_FILES, CASE_INSENSITIVE_PATH_ORDER); if (videos.size() > 0) { return videos.get(0); } - } else if (SUBTITLE_FILES.accept(getMediaFile()) || ((infoObject instanceof Episode || infoObject instanceof Movie) && !VIDEO_FILES.accept(getMediaFile()))) { + } else if ((SUBTITLE_FILES.accept(file) || IMAGE_FILES.accept(file)) || ((infoObject instanceof Episode || infoObject instanceof Movie) && !VIDEO_FILES.accept(file))) { // prefer equal match from current context if possible if (context != null) { for (Entry it : context.entrySet()) { @@ -1025,8 +1027,8 @@ public class MediaBindingBean { } // file is a subtitle, or nfo, etc - String baseName = stripReleaseInfo(FileUtilities.getName(getMediaFile())).toLowerCase(); - List videos = getChildren(getMediaFile().getParentFile(), VIDEO_FILES); + String baseName = stripReleaseInfo(FileUtilities.getName(file)).toLowerCase(); + List videos = getChildren(file.getParentFile(), VIDEO_FILES); // find corresponding movie file for (File movieFile : videos) { @@ -1037,12 +1039,12 @@ public class MediaBindingBean { // still no good match found -> just take the most probable video from the same folder if (videos.size() > 0) { - sort(videos, SimilarityComparator.compareTo(FileUtilities.getName(getMediaFile()), FileUtilities::getName)); + sort(videos, SimilarityComparator.compareTo(FileUtilities.getName(file), FileUtilities::getName)); return videos.get(0); } } - return getMediaFile(); + return file; } public Episode getSeasonEpisode() {