1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-21 15:28:52 -05:00

Reverse Map [%s] to [%s]

This commit is contained in:
Reinhard Pointner 2019-06-10 14:33:07 +07:00
parent f0b4d65d27
commit b0734f74c4

View File

@ -224,7 +224,7 @@ public class CmdlineOperations implements CmdlineInterface {
episodes = applyEpisodeExpressionMapper(episodes, mapper);
for (List<File> filesPerType : mapByMediaExtension(filter(batch, VIDEO_FILES, SUBTITLE_FILES)).values()) {
matches.addAll(matchEpisodes(filesPerType, episodes, strict));
matchEpisodes(filesPerType, episodes, strict).stream().map(this::unmap).forEach(matches::add);
}
}
}
@ -254,6 +254,16 @@ public class CmdlineOperations implements CmdlineInterface {
return renameAll(formatMatches(matches, format, outputDir), renameAction, conflictAction, matches, exec);
}
private Match<File, ?> unmap(Match<File, ?> match) {
// add matches and unmap mapped episodes
if (match.getCandidate() instanceof MappedEpisode) {
MappedEpisode mapping = (MappedEpisode) match.getCandidate();
log.fine(format("Reverse Map [%s] to [%s]", mapping.getMapping(), mapping.getOriginal()));
return new Match<File, Episode>(match.getValue(), mapping.getOriginal());
}
return match;
}
private List<Match<File, Object>> matchEpisodes(Collection<File> files, Collection<Episode> episodes, boolean strict) throws Exception {
// always use strict fail-fast matcher
EpisodeMatcher matcher = new EpisodeMatcher(files, episodes, strict);