mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 16:58:51 -05:00
* fix corner-case
@see http://www.filebot.net/forums/viewtopic.php?f=8&t=1425
This commit is contained in:
parent
751cf116e9
commit
24cd64ec03
@ -196,8 +196,9 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||
// filter episodes
|
||||
episodes = applyExpressionFilter(episodes, filter);
|
||||
|
||||
matches.addAll(matchEpisodes(filter(batch, VIDEO_FILES), episodes, strict));
|
||||
matches.addAll(matchEpisodes(filter(batch, SUBTITLE_FILES), episodes, strict));
|
||||
for (List<File> filesPerType : mapByMediaExtension(filter(batch, VIDEO_FILES, SUBTITLE_FILES)).values()) {
|
||||
matches.addAll(matchEpisodes(filesPerType, episodes, strict));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -972,6 +972,37 @@ public class MediaDetection {
|
||||
return mediaFolders;
|
||||
}
|
||||
|
||||
public static Map<String, List<File>> mapByMediaExtension(Iterable<File> files) {
|
||||
Map<String, List<File>> map = new LinkedHashMap<String, List<File>>();
|
||||
|
||||
for (File file : files) {
|
||||
String key = getExtension(file);
|
||||
|
||||
// allow extended extensions for subtitles files, for example name.eng.srt => map by en.srt
|
||||
if (key != null && SUBTITLE_FILES.accept(file)) {
|
||||
Locale locale = releaseInfo.getLanguageSuffix(getName(file));
|
||||
if (locale != null) {
|
||||
key = locale.getLanguage() + '.' + key;
|
||||
}
|
||||
}
|
||||
|
||||
// normalize to lower-case
|
||||
if (key != null) {
|
||||
key = key.toLowerCase();
|
||||
}
|
||||
|
||||
List<File> valueList = map.get(key);
|
||||
if (valueList == null) {
|
||||
valueList = new ArrayList<File>();
|
||||
map.put(key, valueList);
|
||||
}
|
||||
|
||||
valueList.add(file);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public static Map<String, List<File>> mapBySeriesName(Collection<File> files, boolean useSeriesIndex, boolean useAnimeIndex, Locale locale) throws Exception {
|
||||
Map<String, List<File>> result = new TreeMap<String, List<File>>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
|
@ -299,7 +299,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
||||
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
|
||||
|
||||
// group by subtitles first and then by files in general
|
||||
for (List<File> filesPerType : mapByExtension(files).values()) {
|
||||
for (List<File> filesPerType : mapByMediaExtension(files).values()) {
|
||||
EpisodeMatcher matcher = new EpisodeMatcher(filesPerType, episodes, false);
|
||||
for (Match<File, Object> it : matcher.match()) {
|
||||
matches.add(new Match<File, Episode>(it.getValue(), ((Episode) it.getCandidate()).clone()));
|
||||
|
Loading…
Reference in New Issue
Block a user