mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 00:38:52 -05:00
Implement advanced multi-part movie detection (via group by mediainfo)
This commit is contained in:
parent
47d9513a70
commit
73e7443593
@ -463,6 +463,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
// collect all File/MoviePart matches
|
// collect all File/MoviePart matches
|
||||||
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
|
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
|
||||||
|
|
||||||
|
// TODO: MediaDetection.groupByMediaCharacteristics()
|
||||||
for (Entry<Movie, SortedSet<File>> byMovie : filesByMovie.entrySet()) {
|
for (Entry<Movie, SortedSet<File>> byMovie : filesByMovie.entrySet()) {
|
||||||
for (List<File> movieFileListByMediaFolder : mapByMediaFolder(byMovie.getValue()).values()) {
|
for (List<File> movieFileListByMediaFolder : mapByMediaFolder(byMovie.getValue()).values()) {
|
||||||
for (List<File> fileSet : mapByExtension(movieFileListByMediaFolder).values()) {
|
for (List<File> fileSet : mapByExtension(movieFileListByMediaFolder).values()) {
|
||||||
|
@ -751,13 +751,23 @@ public class MediaBindingBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Define("bitrate")
|
@Define("bitrate")
|
||||||
public Long getBitRate() {
|
public Long getOverallBitRate() {
|
||||||
return new Double(getMediaInfo(StreamKind.General, 0, "OverallBitRate")).longValue();
|
return new Double(getMediaInfo(StreamKind.General, 0, "OverallBitRate")).longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Define("vbr")
|
||||||
|
public Long getVideoBitRate() {
|
||||||
|
return new Double(getMediaInfo(StreamKind.Video, 0, "BitRate")).longValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Define("abr")
|
||||||
|
public Long getAudioBitRate() {
|
||||||
|
return new Double(getMediaInfo(StreamKind.Audio, 0, "BitRate")).longValue();
|
||||||
|
}
|
||||||
|
|
||||||
@Define("duration")
|
@Define("duration")
|
||||||
public Long getDuration() {
|
public Long getDuration() {
|
||||||
return (long) Double.parseDouble(getMediaInfo(StreamKind.General, 0, "Duration"));
|
return new Double(getMediaInfo(StreamKind.General, 0, "Duration")).longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Define("seconds")
|
@Define("seconds")
|
||||||
|
@ -1067,6 +1067,37 @@ public class MediaDetection {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<List<File>> groupByMediaCharacteristics(Collection<File> files) {
|
||||||
|
List<List<File>> groups = new ArrayList<List<File>>();
|
||||||
|
|
||||||
|
mapByExtension(files).forEach((extension, filesByExtension) -> {
|
||||||
|
if (filesByExtension.size() < 2) {
|
||||||
|
groups.add(filesByExtension);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mapByMediaFolder(filesByExtension).forEach((mediaFolder, filesByMediaFolder) -> {
|
||||||
|
if (filesByMediaFolder.size() < 2) {
|
||||||
|
groups.add(filesByMediaFolder);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
filesByMediaFolder.stream().collect(groupingBy(new VideoQuality()::getVideoBitrate)).forEach((vbr, 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
public static Map<String, List<File>> mapBySeriesName(Collection<File> files, boolean anime, Locale locale) throws Exception {
|
public static Map<String, List<File>> mapBySeriesName(Collection<File> files, boolean anime, Locale locale) throws Exception {
|
||||||
Map<String, List<File>> result = new TreeMap<String, List<File>>(String.CASE_INSENSITIVE_ORDER);
|
Map<String, List<File>> result = new TreeMap<String, List<File>>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package net.filebot.media;
|
package net.filebot.media;
|
||||||
|
|
||||||
import static net.filebot.util.StringUtilities.*;
|
|
||||||
import static java.util.Comparator.*;
|
import static java.util.Comparator.*;
|
||||||
import static net.filebot.Logging.*;
|
import static net.filebot.Logging.*;
|
||||||
import static net.filebot.MediaTypes.*;
|
import static net.filebot.MediaTypes.*;
|
||||||
|
import static net.filebot.util.StringUtilities.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -64,4 +64,16 @@ public class VideoQuality implements Comparator<File> {
|
|||||||
}).orElseGet(f::length);
|
}).orElseGet(f::length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getVideoBitrate(File f) {
|
||||||
|
return media(f).map(it -> {
|
||||||
|
return it.getVideoBitRate();
|
||||||
|
}).orElse(0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAudioBitrate(File f) {
|
||||||
|
return media(f).map(it -> {
|
||||||
|
return it.getAudioBitRate();
|
||||||
|
}).orElse(0L);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,7 @@ class MovieMatcher implements AutoCompleteMatcher {
|
|||||||
// collect all File/MoviePart matches
|
// collect all File/MoviePart matches
|
||||||
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
|
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
|
||||||
|
|
||||||
|
// TODO: MediaDetection.groupByMediaCharacteristics()
|
||||||
filesByMovie.forEach((movie, byMovie) -> {
|
filesByMovie.forEach((movie, byMovie) -> {
|
||||||
mapByMediaFolder(byMovie).forEach((mediaFolder, byFolder) -> {
|
mapByMediaFolder(byMovie).forEach((mediaFolder, byFolder) -> {
|
||||||
mapByExtension(byFolder).forEach((ext, moviePartFiles) -> {
|
mapByExtension(byFolder).forEach((ext, moviePartFiles) -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user