Implement advanced multi-part movie detection (via group by mediainfo)

This commit is contained in:
Reinhard Pointner 2016-08-08 07:46:04 +08:00
parent 8457561dd5
commit 76bb88042a
3 changed files with 12 additions and 21 deletions

View File

@ -770,11 +770,6 @@ public class MediaBindingBean {
return (int) (getDuration() / 60000);
}
@Define("encodedDate")
public String getEncodedDate() {
return getMediaInfo(StreamKind.General, 0, "Encoded_Date"); // e.g. UTC 2014-07-18 13:57:37
}
@Define("media")
public AssociativeScriptObject getGeneralMediaInfo() {
return createMediaInfoBindings(StreamKind.General).get(0);

View File

@ -46,6 +46,8 @@ import net.filebot.ApplicationFolder;
import net.filebot.Resource;
import net.filebot.WebServices;
import net.filebot.archive.Archive;
import net.filebot.mediainfo.MediaInfo;
import net.filebot.mediainfo.MediaInfo.StreamKind;
import net.filebot.similarity.CommonSequenceMatcher;
import net.filebot.similarity.DateMatcher;
import net.filebot.similarity.EpisodeMetrics;
@ -1082,16 +1084,16 @@ public class MediaDetection {
return;
}
try {
filesByMediaFolder.stream().collect(groupingBy(new VideoQuality()::getEncodedDate)).forEach((group, videos) -> {
groups.add(videos);
});
} catch (Exception e) {
debug.warning(format("Failed to group by media characteristics: %s", e.getMessage()));
// if mediainfo fails and we can't further group by video bitrate then just keep the grouping we have
groups.add(filesByMediaFolder);
}
filesByMediaFolder.stream().collect(groupingBy(f -> {
if (VIDEO_FILES.accept(f)) {
try (MediaInfo mi = new MediaInfo().open(f)) {
return mi.get(StreamKind.General, 0, "Encoded_Date");
} catch (Exception e) {
debug.warning(format("Failed to read media characteristics: %s", e.getMessage()));
}
}
return "";
})).forEach((group, videos) -> groups.add(videos));
});
});

View File

@ -64,10 +64,4 @@ public class VideoQuality implements Comparator<File> {
}).orElseGet(f::length);
}
public String getEncodedDate(File f) {
return media(f).map(it -> {
return it.getEncodedDate();
}).orElse(null);
}
}