1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-10-31 15:35:06 -04:00
This commit is contained in:
Reinhard Pointner 2016-02-09 13:34:55 +00:00
parent c55882e7d1
commit 49710f27f9

View File

@ -21,6 +21,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Stream;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JDialog; import javax.swing.JDialog;
@ -125,10 +126,12 @@ public class SubtitleUploadDialog extends JDialog {
return i; return i;
} }
private List<SubtitleGroup> groupRunsByCD(SubtitleMapping[] table) { private List<SubtitleGroup> getUploadGroups(SubtitleMapping[] table) {
return StreamEx.ofValues(StreamEx.of(table).sortedBy(SubtitleMapping::getVideo).groupingBy(SubtitleMapping::getGroup)).flatMap((group) -> { return StreamEx.ofValues(StreamEx.of(table).groupingBy(SubtitleMapping::getGroup)).flatMap(this::groupRunsByCD).toList();
return StreamEx.of(group).groupRuns((m1, m2) -> getCD(m1) + 1 == getCD(m2)).map(SubtitleGroup::new); }
}).toList();
private Stream<SubtitleGroup> groupRunsByCD(Collection<SubtitleMapping> group) {
return StreamEx.of(group).sortedBy(SubtitleMapping::getVideo).groupRuns((m1, m2) -> getCD(m1) + 1 == getCD(m2)).map(SubtitleGroup::new);
} }
private void runCheck(SubtitleMapping mapping) { private void runCheck(SubtitleMapping mapping) {
@ -226,7 +229,7 @@ public class SubtitleUploadDialog extends JDialog {
uploadExecutorService = Executors.newSingleThreadExecutor(); uploadExecutorService = Executors.newSingleThreadExecutor();
SubtitleMapping[] table = ((SubtitleMappingTableModel) subtitleMappingTable.getModel()).getData(); SubtitleMapping[] table = ((SubtitleMappingTableModel) subtitleMappingTable.getModel()).getData();
for (SubtitleGroup group : groupRunsByCD(table)) { for (SubtitleGroup group : getUploadGroups(table)) {
if (group.isUploadReady()) { if (group.isUploadReady()) {
uploadExecutorService.submit(() -> runUpload(group)); uploadExecutorService.submit(() -> runUpload(group));
} }