diff --git a/.idea/csv-editor.xml b/.idea/csv-editor.xml
deleted file mode 100644
index 8470082..0000000
--- a/.idea/csv-editor.xml
+++ /dev/null
@@ -1,282 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 84995dc..b35db42 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -580,98 +580,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
deleted file mode 100644
index 6d50cd4..0000000
--- a/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e7de95b..86b5654 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,37 +1,134 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
@@ -51,9 +148,7 @@
-
-
@@ -67,69 +162,44 @@
-
-
-
{
"customColor": "",
"associatedIndex": 4
}
-
+
- {
- "keyToString": {
- "Application.Main.executor": "Run",
- "JUnit.TestASSSubtitleConverter.executor": "Run",
- "JUnit.TestAbstractSetupManager.executor": "Run",
- "JUnit.TestFFmpegVideoConverter.executor": "Run",
- "JUnit.TestFXSubtitlesBinder.executor": "Run",
- "Maven.autosubtitle [clean,package,-DskipTests].executor": "Run",
- "Maven.autosubtitle [clean,package].executor": "Run",
- "Maven.autosubtitle [clean].executor": "Run",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "SHARE_PROJECT_CONFIGURATION_FILES": "true",
- "com.codeium.enabled": "true",
- "git-widget-placeholder": "master",
- "ignore.virus.scanning.warn.message": "true",
- "kotlin-language-version-configured": "true",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "project.structure.last.edited": "Modules",
- "project.structure.proportion": "0.0",
- "project.structure.side.proportion": "0.0",
- "run.code.analysis.last.selected.profile": "aDefault",
- "settings.editor.selected.configurable": "actions.on.save",
- "vue.rearranger.settings.migration": "true"
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+}]]>
-
-
+
-
+
@@ -165,70 +235,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -311,34 +317,27 @@
-
-
-
-
-
-
+
+
-
- 1726946764733
+
+ 1727983986841
- 1726946764733
-
-
-
-
-
+ 1727983986841
+
+
diff --git a/api/src/main/java/com/github/gtache/autosubtitle/ToolType.java b/api/src/main/java/com/github/gtache/autosubtitle/ToolType.java
new file mode 100644
index 0000000..c2ec2b9
--- /dev/null
+++ b/api/src/main/java/com/github/gtache/autosubtitle/ToolType.java
@@ -0,0 +1,19 @@
+package com.github.gtache.autosubtitle;
+
+/**
+ * Type of a tool
+ */
+public enum ToolType {
+ /**
+ * The video converter (used to add subtitles)
+ */
+ VIDEO_CONVERTER,
+ /**
+ * The subtitle extractor (used to extract subtitles from a video)
+ */
+ SUBTITLE_EXTRACTOR,
+ /**
+ * The subtitle translator (used to translate subtitles from one language to another)
+ */
+ TRANSLATOR
+}
diff --git a/api/src/main/java/com/github/gtache/autosubtitle/setup/SetupManager.java b/api/src/main/java/com/github/gtache/autosubtitle/setup/SetupManager.java
index ab7d390..3fffb35 100644
--- a/api/src/main/java/com/github/gtache/autosubtitle/setup/SetupManager.java
+++ b/api/src/main/java/com/github/gtache/autosubtitle/setup/SetupManager.java
@@ -1,5 +1,7 @@
package com.github.gtache.autosubtitle.setup;
+import com.github.gtache.autosubtitle.ToolType;
+
/**
* Manages the setup of a component
*/
@@ -10,6 +12,11 @@ public interface SetupManager {
*/
String name();
+ /**
+ * @return the type of the component
+ */
+ ToolType type();
+
/**
* @return the status of the component setup
*/
diff --git a/cli/src/main/java/com/github/gtache/autosubtitle/cli/Cli.java b/cli/src/main/java/com/github/gtache/autosubtitle/cli/Cli.java
index 7ed6530..bdaa3fc 100644
--- a/cli/src/main/java/com/github/gtache/autosubtitle/cli/Cli.java
+++ b/cli/src/main/java/com/github/gtache/autosubtitle/cli/Cli.java
@@ -6,12 +6,15 @@ import picocli.CommandLine;
import java.util.Set;
+/**
+ * Main class for CLI
+ */
@CommandLine.Command(name = "autosubtitle", mixinStandardHelpOptions = true, version = "autosubtitle 1.0-SNAPSHOT", description = "CLI for auto-subtitle")
public final class Cli implements Runnable {
- @CommandLine.Option(names = {"-b", "--burn"}, description = "Burn the subtitles. Otherwise, adds them to the video", defaultValue = "false")
+ @CommandLine.Option(names = {"-b", "--burn"}, description = "Burns the subtitles. Otherwise, adds them to the video", defaultValue = "false")
private boolean burn;
- @CommandLine.Option(names = {"-e", "--extractor"}, description = "The subtitle extractor to use [whisper]", defaultValue = "whisper")
+ @CommandLine.Option(names = {"-e", "--extractor"}, description = "The subtitle extractor to use [whisperx]", defaultValue = "whisperx")
private String extractor;
@CommandLine.Option(names = {"-i", "--input"}, description = "The input file", required = true)
private String input;
diff --git a/conda/src/main/java/com/github/gtache/autosubtitle/setup/conda/CondaSetupManager.java b/conda/src/main/java/com/github/gtache/autosubtitle/setup/conda/CondaSetupManager.java
index e6e9bd3..9946c39 100644
--- a/conda/src/main/java/com/github/gtache/autosubtitle/setup/conda/CondaSetupManager.java
+++ b/conda/src/main/java/com/github/gtache/autosubtitle/setup/conda/CondaSetupManager.java
@@ -1,5 +1,6 @@
package com.github.gtache.autosubtitle.setup.conda;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.impl.OS;
import com.github.gtache.autosubtitle.process.ProcessRunner;
import com.github.gtache.autosubtitle.setup.SetupException;
@@ -42,6 +43,11 @@ public class CondaSetupManager extends AbstractSetupManager {
return "conda";
}
+ @Override
+ public ToolType type() {
+ return null; //Just an intermediary tool
+ }
+
@Override
protected SetupStatus getStatus() throws SetupException {
if (isSystemCondaInstalled()) {
diff --git a/conda/src/test/java/com/github/gtache/autosubtitle/setup/conda/TestCondaSetupManager.java b/conda/src/test/java/com/github/gtache/autosubtitle/setup/conda/TestCondaSetupManager.java
index 1cfbe97..95c17ce 100644
--- a/conda/src/test/java/com/github/gtache/autosubtitle/setup/conda/TestCondaSetupManager.java
+++ b/conda/src/test/java/com/github/gtache/autosubtitle/setup/conda/TestCondaSetupManager.java
@@ -68,6 +68,11 @@ class TestCondaSetupManager {
assertEquals("conda", condaSetupManager.name());
}
+ @Test
+ void testType() {
+ assertNull(condaSetupManager.type());
+ }
+
@Test
void testGetStatusIsSystemInstalled() throws SetupException {
assertEquals(SetupStatus.SYSTEM_INSTALLED, condaSetupManager.getStatus());
diff --git a/core/pom.xml b/core/pom.xml
index 03c549d..50cbf21 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -24,6 +24,10 @@
org.apache.logging.log4j
log4j-api
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
org.apache.logging.log4j
log4j-core
diff --git a/core/src/main/java/com/github/gtache/autosubtitle/modules/setup/impl/SetupModule.java b/core/src/main/java/com/github/gtache/autosubtitle/modules/setup/impl/SetupModule.java
index 767d454..5fbee4a 100644
--- a/core/src/main/java/com/github/gtache/autosubtitle/modules/setup/impl/SetupModule.java
+++ b/core/src/main/java/com/github/gtache/autosubtitle/modules/setup/impl/SetupModule.java
@@ -1,11 +1,14 @@
package com.github.gtache.autosubtitle.modules.setup.impl;
+import com.github.gtache.autosubtitle.ToolType;
+import com.github.gtache.autosubtitle.setup.SetupManager;
import dagger.Module;
import dagger.Provides;
import java.net.http.HttpClient;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Map;
/**
* Dagger core module for setup
@@ -32,4 +35,22 @@ public final class SetupModule {
static HttpClient providesHttpClient() {
return HttpClient.newHttpClient();
}
+
+ @Provides
+ static Map> providesSetupManagers(@VideoConverterSetup final Map convertersManagers,
+ @SubtitleExtractorSetup final Map extractorsManagers,
+ @TranslatorSetup final Map translatorsManagers) {
+ return Map.of(ToolType.VIDEO_CONVERTER, convertersManagers,
+ ToolType.SUBTITLE_EXTRACTOR, extractorsManagers,
+ ToolType.TRANSLATOR, translatorsManagers);
+ }
+
+ @Provides
+ static Map providesDefaultManagers(@VideoConverterSetup final SetupManager videoConverterManager,
+ @SubtitleExtractorSetup final SetupManager subtitleExtractorManager,
+ @TranslatorSetup final SetupManager translatorManager) {
+ return Map.of(ToolType.VIDEO_CONVERTER, videoConverterManager,
+ ToolType.SUBTITLE_EXTRACTOR, subtitleExtractorManager,
+ ToolType.TRANSLATOR, translatorManager);
+ }
}
diff --git a/core/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/converter/impl/SubtitleConverterModule.java b/core/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/converter/impl/SubtitleConverterModule.java
index 58a9c3a..90640e6 100644
--- a/core/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/converter/impl/SubtitleConverterModule.java
+++ b/core/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/converter/impl/SubtitleConverterModule.java
@@ -1,5 +1,6 @@
package com.github.gtache.autosubtitle.modules.subtitle.converter.impl;
+import com.github.gtache.autosubtitle.modules.subtitle.converter.json.impl.JSONConverterModule;
import com.github.gtache.autosubtitle.subtitle.converter.SubtitleConverter;
import com.github.gtache.autosubtitle.subtitle.converter.SubtitleConverterProvider;
import com.github.gtache.autosubtitle.subtitle.converter.impl.ASSSubtitleConverter;
@@ -13,7 +14,7 @@ import dagger.multibindings.StringKey;
/**
* Dagger module for the subtitle converters
*/
-@Module
+@Module(includes = JSONConverterModule.class)
public abstract class SubtitleConverterModule {
private SubtitleConverterModule() {
diff --git a/whisper/whisperx/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/parser/json/whisperx/WhisperXJsonModule.java b/core/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/converter/json/impl/JSONConverterModule.java
similarity index 54%
rename from whisper/whisperx/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/parser/json/whisperx/WhisperXJsonModule.java
rename to core/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/converter/json/impl/JSONConverterModule.java
index 48f8899..a0e7f0b 100644
--- a/whisper/whisperx/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/parser/json/whisperx/WhisperXJsonModule.java
+++ b/core/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/converter/json/impl/JSONConverterModule.java
@@ -1,8 +1,8 @@
-package com.github.gtache.autosubtitle.modules.subtitle.parser.json.whisperx;
+package com.github.gtache.autosubtitle.modules.subtitle.converter.json.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.gtache.autosubtitle.subtitle.converter.SubtitleConverter;
-import com.github.gtache.autosubtitle.subtitle.parser.json.whisperx.JSONSubtitleConverter;
+import com.github.gtache.autosubtitle.subtitle.converter.json.impl.JSONSubtitleConverter;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
@@ -11,17 +11,19 @@ import dagger.multibindings.StringKey;
import javax.inject.Singleton;
+/**
+ * Dagger module for the json subtitle converter
+ */
@Module
-public abstract class WhisperXJsonModule {
-
- private WhisperXJsonModule() {
+public abstract class JSONConverterModule {
+ private JSONConverterModule() {
}
@Binds
@IntoMap
@StringKey("json")
- abstract SubtitleConverter bindsJSONSubtitleConverter(final JSONSubtitleConverter subtitleConverter);
+ abstract SubtitleConverter bindsJsonSubtitleConverter(final JSONSubtitleConverter converter);
@Provides
@Singleton
diff --git a/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/impl/ASSSubtitleConverter.java b/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/impl/ASSSubtitleConverter.java
index 9088045..601ce29 100644
--- a/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/impl/ASSSubtitleConverter.java
+++ b/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/impl/ASSSubtitleConverter.java
@@ -23,8 +23,6 @@ import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import static java.util.Objects.requireNonNull;
-
/**
* Converts subtitles to SRT format
*/
@@ -36,11 +34,11 @@ public class ASSSubtitleConverter implements SubtitleConverter {
private static final String EVENTS_SECTION = "[Events]";
private static final String STYLES_SECTION = "[V4+ Styles]";
private static final Pattern NEWLINE_PATTERN = Pattern.compile("\\n");
- private final Translator> translator;
+ private final Map> translators;
@Inject
- ASSSubtitleConverter(final Translator translator) {
- this.translator = requireNonNull(translator);
+ ASSSubtitleConverter(final Map> translators) {
+ this.translators = Map.copyOf(translators);
}
@Override
@@ -99,7 +97,7 @@ public class ASSSubtitleConverter implements SubtitleConverter {
final var fonts = parseFonts(content, options.defaultFont());
final var subtitles = parseSubtitles(content, fonts);
final var text = subtitles.stream().map(Subtitle::content).collect(Collectors.joining());
- final var language = translator.getLanguage(text);
+ final var language = translators.values().iterator().next().getLanguage(text); //Use any translator for now
return new SubtitleCollectionImpl<>(text, subtitles, language);
}
diff --git a/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/JSONSubtitleConverter.java b/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/JSONSubtitleConverter.java
new file mode 100644
index 0000000..afae575
--- /dev/null
+++ b/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/JSONSubtitleConverter.java
@@ -0,0 +1,74 @@
+package com.github.gtache.autosubtitle.subtitle.converter.json.impl;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.gtache.autosubtitle.subtitle.Subtitle;
+import com.github.gtache.autosubtitle.subtitle.SubtitleCollection;
+import com.github.gtache.autosubtitle.subtitle.converter.FormatException;
+import com.github.gtache.autosubtitle.subtitle.converter.FormatOptions;
+import com.github.gtache.autosubtitle.subtitle.converter.ParseException;
+import com.github.gtache.autosubtitle.subtitle.converter.ParseOptions;
+import com.github.gtache.autosubtitle.subtitle.converter.SubtitleConverter;
+import com.github.gtache.autosubtitle.subtitle.impl.SubtitleCollectionImpl;
+import com.github.gtache.autosubtitle.subtitle.impl.SubtitleImpl;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.nio.file.Path;
+import java.util.Comparator;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * {@link SubtitleConverter} implementation for JSON files
+ */
+@Singleton
+public class JSONSubtitleConverter implements SubtitleConverter {
+
+ private final ObjectMapper mapper;
+
+ @Inject
+ JSONSubtitleConverter(final ObjectMapper mapper) {
+ this.mapper = Objects.requireNonNull(mapper);
+ }
+
+ @Override
+ public String format(final SubtitleCollection> collection, final FormatOptions options) throws FormatException {
+ final var segments = collection.subtitles().stream().map(s -> new JSONSubtitleSegment(s.start(),
+ s.end(), s.content())).toList();
+ final var subtitles = new JSONSubtitles(segments, collection.language());
+ try {
+ return mapper.writeValueAsString(subtitles);
+ } catch (final JsonProcessingException e) {
+ throw new FormatException(e);
+ }
+ }
+
+ @Override
+ public SubtitleCollectionImpl parse(final String content, final ParseOptions options) throws ParseException {
+ try {
+ final var json = mapper.readValue(content, JSONSubtitles.class);
+ final var subtitles = json.segments().stream().flatMap(s -> {
+ final var start = s.start();
+ final var end = s.end();
+ return Stream.of(new SubtitleImpl(s.text(), start, end, null, null));
+ }).sorted(Comparator.comparing(Subtitle::start).thenComparing(Subtitle::end)).toList();
+ final var language = json.language();
+ final var subtitlesText = subtitles.stream().map(s -> s.content().trim()).collect(Collectors.joining(" "));
+ return new SubtitleCollectionImpl<>(subtitlesText, subtitles, language);
+ } catch (final Exception e) {
+ throw new ParseException(e);
+ }
+ }
+
+ @Override
+ public boolean canParse(final Path file) {
+ return file.getFileName().toString().endsWith(".json");
+ }
+
+ @Override
+ public String formatName() {
+ return "json";
+ }
+}
diff --git a/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/JSONSubtitleSegment.java b/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/JSONSubtitleSegment.java
new file mode 100644
index 0000000..357af95
--- /dev/null
+++ b/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/JSONSubtitleSegment.java
@@ -0,0 +1,26 @@
+package com.github.gtache.autosubtitle.subtitle.converter.json.impl;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A subtitle segment as a JSON
+ *
+ * @param start The start in milliseconds
+ * @param end The end in milliseconds
+ * @param text The text
+ */
+public record JSONSubtitleSegment(long start, long end, String text) {
+
+ public JSONSubtitleSegment {
+ if (start < 0) {
+ throw new IllegalArgumentException("start must be >= 0 : " + start);
+ }
+ if (end < 0) {
+ throw new IllegalArgumentException("end must be >= 0 : " + end);
+ }
+ if (start > end) {
+ throw new IllegalArgumentException("start must be <= end : " + start + " > " + end);
+ }
+ requireNonNull(text);
+ }
+}
diff --git a/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/JSONSubtitles.java b/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/JSONSubtitles.java
new file mode 100644
index 0000000..4e4bc4a
--- /dev/null
+++ b/core/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/JSONSubtitles.java
@@ -0,0 +1,21 @@
+package com.github.gtache.autosubtitle.subtitle.converter.json.impl;
+
+import com.github.gtache.autosubtitle.Language;
+
+import java.util.List;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Root json object for subtitles
+ *
+ * @param segments The list of subtitle segments
+ * @param language The subtitles language
+ */
+public record JSONSubtitles(List segments, Language language) {
+
+ public JSONSubtitles {
+ segments = List.copyOf(segments);
+ requireNonNull(language);
+ }
+}
diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java
index ab152e5..2d2592f 100644
--- a/core/src/main/java/module-info.java
+++ b/core/src/main/java/module-info.java
@@ -6,18 +6,22 @@ module com.github.gtache.autosubtitle.core {
requires transitive dagger;
requires transitive java.net.http;
requires transitive javax.inject;
+ requires transitive java.prefs;
+ requires transitive com.fasterxml.jackson.databind;
requires org.apache.logging.log4j;
- requires java.prefs;
exports com.github.gtache.autosubtitle.impl;
exports com.github.gtache.autosubtitle.archive.impl;
exports com.github.gtache.autosubtitle.process.impl;
exports com.github.gtache.autosubtitle.setup.impl;
exports com.github.gtache.autosubtitle.subtitle.impl;
+ exports com.github.gtache.autosubtitle.subtitle.converter.impl;
+ exports com.github.gtache.autosubtitle.subtitle.converter.json.impl;
+ exports com.github.gtache.autosubtitle.subtitle.extractor.impl;
exports com.github.gtache.autosubtitle.modules.impl;
exports com.github.gtache.autosubtitle.modules.setup.impl;
- exports com.github.gtache.autosubtitle.subtitle.extractor.impl;
- exports com.github.gtache.autosubtitle.subtitle.converter.impl;
exports com.github.gtache.autosubtitle.modules.subtitle.impl;
+ exports com.github.gtache.autosubtitle.modules.subtitle.converter.impl;
+ exports com.github.gtache.autosubtitle.modules.subtitle.converter.json.impl;
}
\ No newline at end of file
diff --git a/core/src/test/java/com/github/gtache/autosubtitle/modules/subtitle/converter/json/impl/TestJSONConverterModule.java b/core/src/test/java/com/github/gtache/autosubtitle/modules/subtitle/converter/json/impl/TestJSONConverterModule.java
new file mode 100644
index 0000000..8b56ede
--- /dev/null
+++ b/core/src/test/java/com/github/gtache/autosubtitle/modules/subtitle/converter/json/impl/TestJSONConverterModule.java
@@ -0,0 +1,14 @@
+package com.github.gtache.autosubtitle.modules.subtitle.converter.json.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+
+class TestJSONConverterModule {
+
+ @Test
+ void testProvidesObjectMapper() {
+ assertInstanceOf(ObjectMapper.class, JSONConverterModule.providesObjectMapper());
+ }
+}
diff --git a/core/src/test/java/com/github/gtache/autosubtitle/setup/impl/TestAbstractSetupManager.java b/core/src/test/java/com/github/gtache/autosubtitle/setup/impl/TestAbstractSetupManager.java
index c31d12c..ab90086 100644
--- a/core/src/test/java/com/github/gtache/autosubtitle/setup/impl/TestAbstractSetupManager.java
+++ b/core/src/test/java/com/github/gtache/autosubtitle/setup/impl/TestAbstractSetupManager.java
@@ -1,5 +1,6 @@
package com.github.gtache.autosubtitle.setup.impl;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.process.ProcessRunner;
import com.github.gtache.autosubtitle.setup.SetupAction;
import com.github.gtache.autosubtitle.setup.SetupEvent;
@@ -244,6 +245,11 @@ class TestAbstractSetupManager {
return "dummy";
}
+ @Override
+ public ToolType type() {
+ return ToolType.VIDEO_CONVERTER;
+ }
+
@Override
public void install() {
}
diff --git a/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/impl/TestASSSubtitleConverter.java b/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/impl/TestASSSubtitleConverter.java
index edda285..a1995d9 100644
--- a/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/impl/TestASSSubtitleConverter.java
+++ b/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/impl/TestASSSubtitleConverter.java
@@ -17,6 +17,7 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Arrays;
+import java.util.Map;
import static java.util.Objects.requireNonNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -44,7 +45,7 @@ class TestASSSubtitleConverter {
this.formatOptions = requireNonNull(formatOptions);
this.parseOptions = requireNonNull(parseOptions);
this.videoInfo = requireNonNull(videoInfo);
- this.converter = new ASSSubtitleConverter(translator);
+ this.converter = new ASSSubtitleConverter(Map.of("first", translator));
}
@BeforeEach
diff --git a/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/TestJSONSubtitleConverter.java b/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/TestJSONSubtitleConverter.java
new file mode 100644
index 0000000..ef1e1a4
--- /dev/null
+++ b/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/TestJSONSubtitleConverter.java
@@ -0,0 +1,81 @@
+package com.github.gtache.autosubtitle.subtitle.converter.json.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.gtache.autosubtitle.Language;
+import com.github.gtache.autosubtitle.subtitle.Subtitle;
+import com.github.gtache.autosubtitle.subtitle.converter.FormatException;
+import com.github.gtache.autosubtitle.subtitle.converter.FormatOptions;
+import com.github.gtache.autosubtitle.subtitle.converter.ParseException;
+import com.github.gtache.autosubtitle.subtitle.converter.ParseOptions;
+import com.github.gtache.autosubtitle.subtitle.impl.SubtitleCollectionImpl;
+import com.github.gtache.autosubtitle.subtitle.impl.SubtitleImpl;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Objects;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class TestJSONSubtitleConverter {
+
+ private final ParseOptions parseOptions;
+ private final FormatOptions formatOptions;
+ private final JSONSubtitleConverter converter;
+
+ TestJSONSubtitleConverter(@Mock final ParseOptions parseOptions, @Mock final FormatOptions formatOptions) {
+ this.parseOptions = Objects.requireNonNull(parseOptions);
+ this.formatOptions = Objects.requireNonNull(formatOptions);
+ this.converter = new JSONSubtitleConverter(new ObjectMapper());
+ }
+
+ @BeforeEach
+ void beforeEach() {
+ when(parseOptions.maxLineLength()).thenReturn(100);
+ when(parseOptions.maxLines()).thenReturn(2);
+ }
+
+ @Test
+ void testFormatName() {
+ assertEquals("json", converter.formatName());
+ }
+
+ @Test
+ void testParseFormat() throws IOException, ParseException, FormatException {
+ try (final var inStream = getClass().getResourceAsStream("in.json");
+ final var outStream = getClass().getResourceAsStream("out.json")) {
+ if (inStream == null || outStream == null) {
+ throw new IOException("File not found");
+ }
+ final var in = new String(inStream.readAllBytes(), StandardCharsets.UTF_8);
+ final var out = new String(outStream.readAllBytes(), StandardCharsets.UTF_8);
+ final var expected = new SubtitleCollectionImpl("This is a test. Yes.", List.of(new SubtitleImpl("This is a test.", 9, 410, null, null), new SubtitleImpl("Yes.", 450, 6963, null, null)), Language.FR);
+ assertEquals(expected, converter.parse(in, parseOptions));
+ assertEquals(out, converter.format(expected, formatOptions));
+ }
+ }
+
+ @ParameterizedTest
+ @CsvSource({
+ "test.json,true",
+ ".json,true",
+ "abcd.json,true",
+ "abcd.json2,false",
+ "abcd.js,false",
+ "abcd.jso,false",
+ "json,false",
+ })
+ void testCanParse(final String name, final boolean expected) {
+ assertEquals(expected, converter.canParse(Path.of(name)));
+ }
+}
diff --git a/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/TestJSONSubtitleSegment.java b/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/TestJSONSubtitleSegment.java
new file mode 100644
index 0000000..5d1ddb4
--- /dev/null
+++ b/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/TestJSONSubtitleSegment.java
@@ -0,0 +1,36 @@
+package com.github.gtache.autosubtitle.subtitle.converter.json.impl;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+class TestJSONSubtitleSegment {
+
+ private final long start;
+ private final long end;
+ private final String text;
+ private final JSONSubtitleSegment segment;
+
+ TestJSONSubtitleSegment() {
+ this.start = 2;
+ this.end = 4;
+ this.text = "test";
+ this.segment = new JSONSubtitleSegment(start, end, text);
+ }
+
+ @Test
+ void testGetters() {
+ assertEquals(start, segment.start());
+ assertEquals(end, segment.end());
+ assertEquals(text, segment.text());
+ }
+
+ @Test
+ void testIllegal() {
+ assertThrows(NullPointerException.class, () -> new JSONSubtitleSegment(start, end, null));
+ assertThrows(IllegalArgumentException.class, () -> new JSONSubtitleSegment(-1, end, text));
+ assertThrows(IllegalArgumentException.class, () -> new JSONSubtitleSegment(start, -1, text));
+ assertThrows(IllegalArgumentException.class, () -> new JSONSubtitleSegment(end, start, text));
+ }
+}
diff --git a/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/TestJSONSubtitles.java b/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/TestJSONSubtitles.java
new file mode 100644
index 0000000..392a2d8
--- /dev/null
+++ b/core/src/test/java/com/github/gtache/autosubtitle/subtitle/converter/json/impl/TestJSONSubtitles.java
@@ -0,0 +1,39 @@
+package com.github.gtache.autosubtitle.subtitle.converter.json.impl;
+
+import com.github.gtache.autosubtitle.Language;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.List;
+import java.util.Objects;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@ExtendWith(MockitoExtension.class)
+class TestJSONSubtitles {
+
+ private final List segments;
+ private final Language language;
+ private final JSONSubtitles subtitles;
+
+ TestJSONSubtitles(@Mock final JSONSubtitleSegment segment, @Mock final Language language) {
+ this.segments = List.of(segment);
+ this.language = Objects.requireNonNull(language);
+ this.subtitles = new JSONSubtitles(segments, language);
+ }
+
+ @Test
+ void testGetters() {
+ assertEquals(segments, subtitles.segments());
+ assertEquals(language, subtitles.language());
+ }
+
+ @Test
+ void testIllegal() {
+ assertThrows(NullPointerException.class, () -> new JSONSubtitles(null, language));
+ assertThrows(NullPointerException.class, () -> new JSONSubtitles(segments, null));
+ }
+}
diff --git a/core/src/test/resources/com/github/gtache/autosubtitle/subtitle/converter/json/impl/in.json b/core/src/test/resources/com/github/gtache/autosubtitle/subtitle/converter/json/impl/in.json
new file mode 100644
index 0000000..3084d79
--- /dev/null
+++ b/core/src/test/resources/com/github/gtache/autosubtitle/subtitle/converter/json/impl/in.json
@@ -0,0 +1,15 @@
+{
+ "segments": [
+ {
+ "start": 9,
+ "end": 410,
+ "text": "This is a test."
+ },
+ {
+ "start": 450,
+ "end": 6963,
+ "text": "Yes."
+ }
+ ],
+ "language": "FR"
+}
\ No newline at end of file
diff --git a/core/src/test/resources/com/github/gtache/autosubtitle/subtitle/converter/json/impl/out.json b/core/src/test/resources/com/github/gtache/autosubtitle/subtitle/converter/json/impl/out.json
new file mode 100644
index 0000000..7e6ac99
--- /dev/null
+++ b/core/src/test/resources/com/github/gtache/autosubtitle/subtitle/converter/json/impl/out.json
@@ -0,0 +1 @@
+{"segments":[{"start":9,"end":410,"text":"This is a test."},{"start":450,"end":6963,"text":"Yes."}],"language":"FR"}
\ No newline at end of file
diff --git a/deepl/src/main/java/com/github/gtache/autosubtitle/modules/deepl/DeepLModule.java b/deepl/src/main/java/com/github/gtache/autosubtitle/modules/deepl/DeepLModule.java
index 88f364a..30297c2 100644
--- a/deepl/src/main/java/com/github/gtache/autosubtitle/modules/deepl/DeepLModule.java
+++ b/deepl/src/main/java/com/github/gtache/autosubtitle/modules/deepl/DeepLModule.java
@@ -6,6 +6,8 @@ import com.github.gtache.autosubtitle.translation.deepl.DeepLTranslator;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
+import dagger.multibindings.IntoMap;
+import dagger.multibindings.StringKey;
import org.apache.tika.language.detect.LanguageDetector;
import javax.inject.Singleton;
@@ -18,6 +20,11 @@ import java.io.UncheckedIOException;
@Module(includes = DeepLSetupModule.class)
public abstract class DeepLModule {
+ @Binds
+ @IntoMap
+ @StringKey("deepl")
+ abstract Translator> bindsTranslatorInMap(final DeepLTranslator translator);
+
@Binds
abstract Translator bindsTranslator(final DeepLTranslator translator);
diff --git a/deepl/src/main/java/com/github/gtache/autosubtitle/modules/setup/deepl/DeepLSetupModule.java b/deepl/src/main/java/com/github/gtache/autosubtitle/modules/setup/deepl/DeepLSetupModule.java
index 6f69e7e..8b62e25 100644
--- a/deepl/src/main/java/com/github/gtache/autosubtitle/modules/setup/deepl/DeepLSetupModule.java
+++ b/deepl/src/main/java/com/github/gtache/autosubtitle/modules/setup/deepl/DeepLSetupModule.java
@@ -5,6 +5,8 @@ import com.github.gtache.autosubtitle.setup.SetupManager;
import com.github.gtache.autosubtitle.setup.deepl.DeepLSetupManager;
import dagger.Binds;
import dagger.Module;
+import dagger.multibindings.IntoMap;
+import dagger.multibindings.StringKey;
/**
* Dagger module for DeepL setup
@@ -16,6 +18,12 @@ public abstract class DeepLSetupModule {
@Binds
@TranslatorSetup
+ @IntoMap
+ @StringKey("deepl")
abstract SetupManager bindsSetupManager(final DeepLSetupManager setupManager);
+ @Binds
+ @TranslatorSetup
+ abstract SetupManager bindsDefaultSetupManager(final DeepLSetupManager setupManager);
+
}
diff --git a/deepl/src/main/java/com/github/gtache/autosubtitle/setup/deepl/DeepLSetupManager.java b/deepl/src/main/java/com/github/gtache/autosubtitle/setup/deepl/DeepLSetupManager.java
index af8e88b..ddd2646 100644
--- a/deepl/src/main/java/com/github/gtache/autosubtitle/setup/deepl/DeepLSetupManager.java
+++ b/deepl/src/main/java/com/github/gtache/autosubtitle/setup/deepl/DeepLSetupManager.java
@@ -1,5 +1,6 @@
package com.github.gtache.autosubtitle.setup.deepl;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.process.ProcessRunner;
import com.github.gtache.autosubtitle.setup.SetupException;
import com.github.gtache.autosubtitle.setup.SetupManager;
@@ -8,6 +9,7 @@ import com.github.gtache.autosubtitle.setup.SetupUserBridge;
import com.github.gtache.autosubtitle.setup.impl.AbstractSetupManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.net.http.HttpClient;
import java.util.Objects;
import java.util.prefs.BackingStoreException;
@@ -16,6 +18,7 @@ import java.util.prefs.Preferences;
/**
* {@link SetupManager} for DeepL
*/
+@Singleton
public class DeepLSetupManager extends AbstractSetupManager {
private static final String DEEPL_API_KEY = "deepl.api.key";
@@ -42,6 +45,11 @@ public class DeepLSetupManager extends AbstractSetupManager {
return "DeepL";
}
+ @Override
+ public ToolType type() {
+ return ToolType.TRANSLATOR;
+ }
+
@Override
public void install() throws SetupException {
final var key = userBridge.askForUserInput("Please enter your DeepL API key - https://www.deepl.com/pro-api? (It will be stored unencrypted)");
diff --git a/deepl/src/main/java/module-info.java b/deepl/src/main/java/module-info.java
index 679367f..cfd18f8 100644
--- a/deepl/src/main/java/module-info.java
+++ b/deepl/src/main/java/module-info.java
@@ -7,7 +7,10 @@ module com.github.gtache.autosubtitle.deepl {
requires transitive java.prefs;
requires transitive org.apache.tika.core;
requires transitive language.detector;
- exports com.github.gtache.autosubtitle.modules.deepl;
- exports com.github.gtache.autosubtitle.translation.deepl;
+
exports com.github.gtache.autosubtitle.setup.deepl;
+ exports com.github.gtache.autosubtitle.translation.deepl;
+
+ exports com.github.gtache.autosubtitle.modules.deepl;
+ exports com.github.gtache.autosubtitle.modules.setup.deepl;
}
\ No newline at end of file
diff --git a/deepl/src/test/java/com/github/gtache/autosubtitle/setup/deepl/TestDeepLSetupManager.java b/deepl/src/test/java/com/github/gtache/autosubtitle/setup/deepl/TestDeepLSetupManager.java
index 0f9fc09..9c7210d 100644
--- a/deepl/src/test/java/com/github/gtache/autosubtitle/setup/deepl/TestDeepLSetupManager.java
+++ b/deepl/src/test/java/com/github/gtache/autosubtitle/setup/deepl/TestDeepLSetupManager.java
@@ -1,5 +1,6 @@
package com.github.gtache.autosubtitle.setup.deepl;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.process.ProcessRunner;
import com.github.gtache.autosubtitle.setup.SetupException;
import com.github.gtache.autosubtitle.setup.SetupStatus;
@@ -44,6 +45,11 @@ class TestDeepLSetupManager {
assertEquals(SetupStatus.BUNDLE_INSTALLED, setupManager.getStatus());
}
+ @Test
+ void testType() {
+ assertEquals(ToolType.TRANSLATOR, setupManager.type());
+ }
+
@Test
void testInstall() throws BackingStoreException, SetupException {
final var key = "key";
diff --git a/ffmpeg/src/main/java/com/github/gtache/autosubtitle/modules/ffmpeg/FFmpegModule.java b/ffmpeg/src/main/java/com/github/gtache/autosubtitle/modules/ffmpeg/FFmpegModule.java
index 44bb4d6..783b094 100644
--- a/ffmpeg/src/main/java/com/github/gtache/autosubtitle/modules/ffmpeg/FFmpegModule.java
+++ b/ffmpeg/src/main/java/com/github/gtache/autosubtitle/modules/ffmpeg/FFmpegModule.java
@@ -7,6 +7,8 @@ import com.github.gtache.autosubtitle.ffmpeg.FFprobeVideoLoader;
import com.github.gtache.autosubtitle.modules.setup.ffmpeg.FFmpegSetupModule;
import dagger.Binds;
import dagger.Module;
+import dagger.multibindings.IntoMap;
+import dagger.multibindings.StringKey;
/**
* Dagger module for FFmpeg
@@ -19,8 +21,18 @@ public abstract class FFmpegModule {
}
@Binds
+ @IntoMap
+ @StringKey("ffmpeg")
abstract VideoConverter bindsVideoConverter(final FFmpegVideoConverter converter);
@Binds
+ abstract VideoConverter bindsDefaultVideoConverter(final FFmpegVideoConverter converter);
+
+ @Binds
+ @IntoMap
+ @StringKey("ffprobe")
abstract VideoLoader bindsVideoLoader(final FFprobeVideoLoader loader);
+
+ @Binds
+ abstract VideoLoader bindsDefaultVideoLoader(final FFprobeVideoLoader loader);
}
diff --git a/ffmpeg/src/main/java/com/github/gtache/autosubtitle/modules/setup/ffmpeg/FFmpegSetupModule.java b/ffmpeg/src/main/java/com/github/gtache/autosubtitle/modules/setup/ffmpeg/FFmpegSetupModule.java
index acef204..4172aab 100644
--- a/ffmpeg/src/main/java/com/github/gtache/autosubtitle/modules/setup/ffmpeg/FFmpegSetupModule.java
+++ b/ffmpeg/src/main/java/com/github/gtache/autosubtitle/modules/setup/ffmpeg/FFmpegSetupModule.java
@@ -36,19 +36,25 @@ public abstract class FFmpegSetupModule {
@Binds
- @StringKey("tar")
@IntoMap
+ @StringKey("tar")
abstract Archiver bindsTarDecompresser(final TarArchiver decompresser);
@Binds
- @StringKey("xz")
@IntoMap
+ @StringKey("xz")
abstract Archiver bindsXZDecompresser(final XZArchiver decompresser);
@Binds
@VideoConverterSetup
+ @IntoMap
+ @StringKey("ffmpeg")
abstract SetupManager bindsFFmpegSetupManager(final FFmpegSetupManager manager);
+ @Binds
+ @VideoConverterSetup
+ abstract SetupManager bindsDefaultSetupManager(final FFmpegSetupManager manager);
+
@Provides
static FFmpegSetupConfiguration providesFFmpegSetupConfiguration(@FFBundledRoot final Path root, @FFmpegBundledPath final Path bundledPath, @FFmpegSystemPath final Path systemPath,
@FFmpegInstallerPath final Path ffmpegInstallerPath, @FFProbeInstallerPath final Path ffprobeInstallerPath,
diff --git a/ffmpeg/src/main/java/com/github/gtache/autosubtitle/setup/ffmpeg/FFmpegSetupManager.java b/ffmpeg/src/main/java/com/github/gtache/autosubtitle/setup/ffmpeg/FFmpegSetupManager.java
index 0cd5abe..031b2e2 100644
--- a/ffmpeg/src/main/java/com/github/gtache/autosubtitle/setup/ffmpeg/FFmpegSetupManager.java
+++ b/ffmpeg/src/main/java/com/github/gtache/autosubtitle/setup/ffmpeg/FFmpegSetupManager.java
@@ -1,5 +1,6 @@
package com.github.gtache.autosubtitle.setup.ffmpeg;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.archive.ArchiverProvider;
import com.github.gtache.autosubtitle.impl.Architecture;
import com.github.gtache.autosubtitle.process.ProcessRunner;
@@ -9,6 +10,7 @@ import com.github.gtache.autosubtitle.setup.SetupStatus;
import com.github.gtache.autosubtitle.setup.impl.AbstractSetupManager;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.io.IOException;
import java.net.http.HttpClient;
import java.nio.file.Files;
@@ -24,6 +26,7 @@ import static java.util.Objects.requireNonNull;
* {@link SetupManager} managing the FFmpeg installation
*/
//TODO add gpg/signature check
+@Singleton
public class FFmpegSetupManager extends AbstractSetupManager {
private final FFmpegSetupConfiguration configuration;
private final ArchiverProvider archiverProvider;
@@ -41,6 +44,11 @@ public class FFmpegSetupManager extends AbstractSetupManager {
return "FFmpeg";
}
+ @Override
+ public ToolType type() {
+ return ToolType.VIDEO_CONVERTER;
+ }
+
@Override
public SetupStatus getStatus() throws SetupException {
try {
diff --git a/ffmpeg/src/test/java/com/github/gtache/autosubtitle/setup/ffmpeg/TestFFmpegSetupManager.java b/ffmpeg/src/test/java/com/github/gtache/autosubtitle/setup/ffmpeg/TestFFmpegSetupManager.java
index c49de42..5dd474b 100644
--- a/ffmpeg/src/test/java/com/github/gtache/autosubtitle/setup/ffmpeg/TestFFmpegSetupManager.java
+++ b/ffmpeg/src/test/java/com/github/gtache/autosubtitle/setup/ffmpeg/TestFFmpegSetupManager.java
@@ -1,5 +1,6 @@
package com.github.gtache.autosubtitle.setup.ffmpeg;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.archive.Archiver;
import com.github.gtache.autosubtitle.archive.ArchiverProvider;
import com.github.gtache.autosubtitle.impl.Architecture;
@@ -84,6 +85,11 @@ class TestFFmpegSetupManager {
assertEquals("FFmpeg", setupManager.name());
}
+ @Test
+ void testType() {
+ assertEquals(ToolType.VIDEO_CONVERTER, setupManager.type());
+ }
+
@Test
void testGetStatusSystemFalse() throws IOException, SetupException {
final var ffmpegPath = Paths.get("path");
diff --git a/gui/api/src/main/java/com/github/gtache/autosubtitle/gui/setup/SetupController.java b/gui/api/src/main/java/com/github/gtache/autosubtitle/gui/setup/SetupController.java
index 097dd73..4fad2ca 100644
--- a/gui/api/src/main/java/com/github/gtache/autosubtitle/gui/setup/SetupController.java
+++ b/gui/api/src/main/java/com/github/gtache/autosubtitle/gui/setup/SetupController.java
@@ -1,69 +1,39 @@
package com.github.gtache.autosubtitle.gui.setup;
+import com.github.gtache.autosubtitle.ToolType;
+
/**
* Controller for the setup view
*/
public interface SetupController {
/**
- * Installs the video converter
+ * Installs the tool given by the tool type
+ *
+ * @param type The tool type
*/
- void installVideoConverter();
+ void install(ToolType type);
/**
- * Uninstalls the video converter
+ * Uninstalls the tool given by the tool type
+ *
+ * @param type The tool type
*/
- void uninstallVideoConverter();
+ void uninstall(ToolType type);
/**
- * Updates the video converter
+ * Updates the tool given by the tool type
+ *
+ * @param type The tool type
*/
- void updateVideoConverter();
+ void update(ToolType type);
/**
- * Reinstalls the video converter
+ * Reinstalls the tool given by the tool type
+ *
+ * @param type The tool type
*/
- void reinstallVideoConverter();
-
- /**
- * Installs the subtitle extractor
- */
- void installSubtitleExtractor();
-
- /**
- * Uninstalls the subtitle extractor
- */
- void uninstallSubtitleExtractor();
-
- /**
- * Updates the subtitle extractor
- */
- void updateSubtitleExtractor();
-
- /**
- * Reinstalls the subtitle extractor
- */
- void reinstallSubtitleExtractor();
-
- /**
- * Installs the translator
- */
- void installTranslator();
-
- /**
- * Uninstalls the translator
- */
- void uninstallTranslator();
-
- /**
- * Updates the translator
- */
- void updateTranslator();
-
- /**
- * Reinstalls the translator
- */
- void reinstallTranslator();
+ void reinstall(ToolType type);
/**
* @return the model
diff --git a/gui/api/src/main/java/com/github/gtache/autosubtitle/gui/setup/SetupModel.java b/gui/api/src/main/java/com/github/gtache/autosubtitle/gui/setup/SetupModel.java
index ca78259..dd4f23c 100644
--- a/gui/api/src/main/java/com/github/gtache/autosubtitle/gui/setup/SetupModel.java
+++ b/gui/api/src/main/java/com/github/gtache/autosubtitle/gui/setup/SetupModel.java
@@ -1,117 +1,101 @@
package com.github.gtache.autosubtitle.gui.setup;
+import com.github.gtache.autosubtitle.ToolType;
+import com.github.gtache.autosubtitle.setup.SetupManager;
import com.github.gtache.autosubtitle.setup.SetupStatus;
+import java.util.List;
+
/**
* Model for the setup view
*/
public interface SetupModel {
/**
- * @return the status of the subtitle extractor
+ * Returns the list of available setup managers for the given tool type
+ *
+ * @param type The tool type
+ * @return The list of managers
*/
- SetupStatus subtitleExtractorStatus();
+ List availableSetupManagers(ToolType type);
/**
- * Sets the status of the subtitle extractor
+ * Returns the selected setup manager for the given tool type
*
+ * @param type The tool type
+ * @return The manager
+ */
+ SetupManager selectedSetupManager(ToolType type);
+
+ /**
+ * Sets the selected setup manager for the given tool type
+ *
+ * @param type The tool type
+ * @param manager the new subtitle extractor
+ */
+ void setSelectedSetupManager(ToolType type, SetupManager manager);
+
+ /**
+ * Returns the selected tool for the given tool type
+ *
+ * @param type The tool type
+ * @return the selected tool
+ */
+ String selectedTool(ToolType type);
+
+ /**
+ * Returns the status of the setup manager for the given tool type
+ *
+ * @param type The tool type
+ * @return the status of the setup manager
+ */
+ SetupStatus managerStatus(ToolType type);
+
+ /**
+ * Sets the status of the setup manager for the given tool type
+ *
+ * @param type The tool type
* @param status the new status
*/
- void setSubtitleExtractorStatus(SetupStatus status);
+ void setManagerStatus(ToolType type, SetupStatus status);
/**
- * @return the progress of the subtitle extractor setup
- */
- double subtitleExtractorSetupProgress();
-
- /**
- * Sets the progress of the subtitle extractor setup
+ * Returns the progress of the tool setup for the given tool type
*
+ * @param type The tool type
+ * @return the progress of the tool setup
+ */
+ double setupProgress(ToolType type);
+
+ /**
+ * Sets the progress of the tool setup for the given tool type
+ *
+ * @param type The tool type
* @param progress the new progress
*/
- void setSubtitleExtractorSetupProgress(double progress);
+ void setSetupProgress(ToolType type, double progress);
/**
- * @return the text of the subtitle extractor setup progress
- */
- String subtitleExtractorSetupProgressLabel();
-
- /**
- * Sets the text of the subtitle extractor setup progress
+ * Returns the text of the setup progress for the given tool type
*
+ * @param type The tool type
+ * @return the text of the setup progress label
+ */
+ String setupProgressLabel(ToolType type);
+
+ /**
+ * Sets the text of the setup progress for the given tool type
+ *
+ * @param type The tool type
* @param label the new text
*/
- void setSubtitleExtractorSetupProgressLabel(String label);
+ void setSetupProgressLabel(ToolType type, String label);
/**
- * @return the status of the video converter
- */
- SetupStatus videoConverterStatus();
-
- /**
- * Sets the status of the video converter
+ * Returns true if the setup is editable
*
- * @param status the new status
+ * @param type The tool type
+ * @return true if the setup is editable
*/
- void setVideoConverterStatus(SetupStatus status);
-
- /**
- * @return the progress of the video converter setup
- */
- double videoConverterSetupProgress();
-
- /**
- * Sets the progress of the video converter setup
- *
- * @param progress the new progress
- */
- void setVideoConverterSetupProgress(double progress);
-
- /**
- * @return the text of the video converter setup progress
- */
- String videoConverterSetupProgressLabel();
-
- /**
- * Sets the text of the video converter setup progress
- *
- * @param label the new text
- */
- void setVideoConverterSetupProgressLabel(String label);
-
- /**
- * @return the status of the translator
- */
- SetupStatus translatorStatus();
-
- /**
- * Sets the status of the translator
- *
- * @param status the new status
- */
- void setTranslatorStatus(SetupStatus status);
-
- /**
- * @return the progress of the translator setup
- */
- double translatorSetupProgress();
-
- /**
- * Sets the progress of the translator setup
- *
- * @param progress the new progress
- */
- void setTranslatorSetupProgress(double progress);
-
- /**
- * @return the text of the translator setup progress
- */
- String translatorSetupProgressLabel();
-
- /**
- * Sets the text of the translator setup progress
- *
- * @param label the new text
- */
- void setTranslatorSetupProgressLabel(String label);
+ boolean isSetupInProgress(ToolType type);
}
diff --git a/gui/core/src/main/resources/com/github/gtache/autosubtitle/gui/impl/SetupBundle.properties b/gui/core/src/main/resources/com/github/gtache/autosubtitle/gui/impl/SetupBundle.properties
index 5b51250..8aeeefc 100644
--- a/gui/core/src/main/resources/com/github/gtache/autosubtitle/gui/impl/SetupBundle.properties
+++ b/gui/core/src/main/resources/com/github/gtache/autosubtitle/gui/impl/SetupBundle.properties
@@ -26,7 +26,10 @@ setup.status.installed.label=is installed.
setup.status.not_installed.label=is not installed.
setup.status.system_installed.label=is installed (system).
setup.status.update_available.label=has an available update.
+setup.subtitle_extractor.choice.label=Subtitle extractor
+setup.subtitle_translator.choice.label=Subtitle translator
setup.uninstall.error.label=An error occurred while uninstalling : {0}
setup.uninstall.error.title=Error uninstalling
setup.update.error.label=An error occurred while updating : {0}
-setup.update.error.title=Error updating
\ No newline at end of file
+setup.update.error.title=Error updating
+setup.video_converter.choice.label=Video Converter
\ No newline at end of file
diff --git a/gui/core/src/main/resources/com/github/gtache/autosubtitle/gui/impl/SetupBundle_fr.properties b/gui/core/src/main/resources/com/github/gtache/autosubtitle/gui/impl/SetupBundle_fr.properties
index 8a7b4a8..fcab630 100644
--- a/gui/core/src/main/resources/com/github/gtache/autosubtitle/gui/impl/SetupBundle_fr.properties
+++ b/gui/core/src/main/resources/com/github/gtache/autosubtitle/gui/impl/SetupBundle_fr.properties
@@ -1,3 +1,4 @@
+setup.converter.choice.label=Convertisseur vid\u00E9o
setup.description.label=Statut des outils utilis\u00E9s par l'application
setup.event.check.end.label=Contr\u00F4le de {0} termin\u00E9
setup.event.check.start.label=Contr\u00F4le de {0} en cours
@@ -11,6 +12,7 @@ setup.event.uninstall.end.label=D\u00E9sinstallation de {0} termin\u00E9e
setup.event.uninstall.start.label=D\u00E9sinstallation de {0} en cours
setup.event.update.end.label=Mise \u00E0 jour de {0} termin\u00E9e
setup.event.update.start.label=Mise \u00E0 jour de {0} en cours
+setup.extractor.choice.label=Extracteur de sous-titres
setup.install.error.label=Une erreur s''est produite lors de l''installation: {0}
setup.install.error.title=Erreur d'installation
setup.menu.install.label=Installer
@@ -26,7 +28,11 @@ setup.status.installed.label=est install\u00E9.
setup.status.not_installed.label=n'est pas install\u00E9.
setup.status.system_installed.label=est install\u00E9 (syst\u00E8me).
setup.status.update_available.label=a une mise \u00E0 jour disponible.
+setup.subtitle_extractor.choice.label=Extracteur de sous-titres
+setup.subtitle_translator.choice.label=Traducteur de sous-titres
+setup.translator.choice.label=Traducteur de sous-titres
setup.uninstall.error.label=Une erreur s''est produite lors de la d\u00E9sinstallation : {0}
setup.uninstall.error.title=Erreur de d\u00E9sinstallation
setup.update.error.label=Une erreur s''est produite lors de la mise \u00E0 jour : {0}
-setup.update.error.title=Erreur de mise \u00E0 jour
\ No newline at end of file
+setup.update.error.title=Erreur de mise \u00E0 jour
+setup.video_converter.choice.label=Convertisseur de vid\u00E9o
\ No newline at end of file
diff --git a/gui/fx/pom.xml b/gui/fx/pom.xml
index 87a03b1..f99bf3c 100644
--- a/gui/fx/pom.xml
+++ b/gui/fx/pom.xml
@@ -13,7 +13,7 @@
11.2.1
- 22.0.2
+ 23
4.0.18
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/media/fx/FXMediaController.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/media/fx/FXMediaController.java
index 3417977..eaef8b0 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/media/fx/FXMediaController.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/media/fx/FXMediaController.java
@@ -60,7 +60,6 @@ public class FXMediaController implements MediaController {
private Label volumeValueLabel;
private final FXMediaModel model;
- private final FXMediaBinder binder;
private final TimeFormatter timeFormatter;
private final Image playImage;
private final Image pauseImage;
@@ -71,10 +70,10 @@ public class FXMediaController implements MediaController {
FXMediaController(final FXMediaModel model, final FXMediaBinder binder, final TimeFormatter timeFormatter,
@Play final Image playImage, @Pause final Image pauseImage) {
this.model = requireNonNull(model);
- this.binder = requireNonNull(binder);
this.timeFormatter = requireNonNull(timeFormatter);
this.playImage = requireNonNull(playImage);
this.pauseImage = requireNonNull(pauseImage);
+ binder.createBindings();
}
@FXML
@@ -116,7 +115,6 @@ public class FXMediaController implements MediaController {
stackPane.widthProperty().addListener((observable, oldValue, newValue) -> resizeMediaView());
stackPane.heightProperty().addListener((observable, oldValue, newValue) -> resizeMediaView());
- binder.createBindings();
}
private void resizeMediaView() {
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersBinder.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersBinder.java
new file mode 100644
index 0000000..9f7e2e3
--- /dev/null
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersBinder.java
@@ -0,0 +1,35 @@
+package com.github.gtache.autosubtitle.gui.parameters.fx;
+
+import com.github.gtache.autosubtitle.ToolType;
+import com.github.gtache.autosubtitle.gui.fx.FXBinder;
+import com.github.gtache.autosubtitle.gui.setup.fx.FXSetupModel;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Binds the subtitles model
+ */
+@Singleton
+public class FXParametersBinder implements FXBinder {
+
+ private final FXParametersModel parametersModel;
+ private final FXSetupModel setupModel;
+
+ @Inject
+ FXParametersBinder(final FXParametersModel parametersModel, final FXSetupModel setupModel) {
+ this.parametersModel = requireNonNull(parametersModel);
+ this.setupModel = requireNonNull(setupModel);
+ }
+
+ @Override
+ public void createBindings() {
+ setupModel.selectedToolProperty(ToolType.SUBTITLE_EXTRACTOR).addListener((observable, oldValue, newValue) -> {
+ if (newValue != null) {
+ parametersModel.extractionModelProviderProperty().set(parametersModel.availableExtractionModelProviders().get(newValue));
+ }
+ });
+ }
+}
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersController.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersController.java
index db39f75..87076f5 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersController.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersController.java
@@ -4,7 +4,7 @@ import com.github.gtache.autosubtitle.gui.fx.AbstractFXController;
import com.github.gtache.autosubtitle.gui.parameters.ParametersController;
import com.github.gtache.autosubtitle.subtitle.OutputFormat;
import com.github.gtache.autosubtitle.subtitle.extractor.ExtractionModel;
-import com.github.gtache.autosubtitle.subtitle.extractor.ExtractionModelProvider;
+import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.control.TextFormatter;
@@ -47,13 +47,12 @@ public class FXParametersController extends AbstractFXController implements Para
private final FXParametersModel model;
private final Preferences preferences;
- private final ExtractionModelProvider extractionModelProvider;
@Inject
- FXParametersController(final FXParametersModel model, final Preferences preferences, final ExtractionModelProvider extractionModelProvider) {
+ FXParametersController(final FXParametersModel model, final FXParametersBinder binder, final Preferences preferences) {
this.model = requireNonNull(model);
this.preferences = requireNonNull(preferences);
- this.extractionModelProvider = requireNonNull(extractionModelProvider);
+ binder.createBindings();
}
@FXML
@@ -83,17 +82,31 @@ public class FXParametersController extends AbstractFXController implements Para
maxLinesField.textProperty().bindBidirectional(model.maxLinesProperty(), new NumberStringConverter());
loadPreferences();
+
+ model.extractionModelProviderProperty().addListener((observable, oldValue, newValue) -> {
+ if (newValue != null) {
+ final var name = newValue.getClass().getSimpleName();
+ Platform.runLater(() -> {
+ final var modelName = preferences.get(name + ".extractionModel", model.extractionModel().name());
+ final var loadedModel = newValue.getExtractionModel(modelName);
+ model.setExtractionModel(loadedModel);
+ });
+ }
+ });
}
private void loadPreferences() {
- final var extractionModel = preferences.get("extractionModel", model.extractionModel().name());
final var outputFormat = preferences.get("outputFormat", model.outputFormat().name());
final var fontFamily = preferences.get("fontName", model.fontName());
final var fontSize = preferences.getInt("fontSize", model.fontSize());
final var maxLineLength = preferences.getInt("maxLineLength", model.maxLineLength());
final var maxLines = preferences.getInt("maxLines", model.maxLines());
- model.setExtractionModel(extractionModelProvider.getExtractionModel(extractionModel));
+ final var extractionModelProvider = model.extractionModelProviderProperty().get();
+ final var name = extractionModelProvider.getClass().getSimpleName();
+ final var modelName = preferences.get(name + ".extractionModel", model.extractionModel().name());
+
+ model.setExtractionModel(extractionModelProvider.getExtractionModel(modelName));
model.setOutputFormat(OutputFormat.valueOf(outputFormat));
model.setFontName(fontFamily);
model.setFontSize(fontSize);
@@ -106,7 +119,7 @@ public class FXParametersController extends AbstractFXController implements Para
@Override
public void save() {
logger.info("Saving preferences");
- preferences.put("extractionModel", model.extractionModel().name());
+ preferences.put(model.extractionModelProviderProperty().get().getClass().getSimpleName() + ".extractionModel", model.extractionModel().name());
preferences.put("outputFormat", model.outputFormat().name());
preferences.put("fontName", model.fontName());
preferences.putInt("fontSize", model.fontSize());
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersModel.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersModel.java
index 924c645..76299ab 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersModel.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/parameters/fx/FXParametersModel.java
@@ -21,9 +21,11 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
+import javafx.collections.ObservableMap;
import javax.inject.Inject;
import javax.inject.Singleton;
+import java.util.Map;
/**
* FX implementation of {@link ParametersModel}
@@ -31,6 +33,8 @@ import javax.inject.Singleton;
@Singleton
public class FXParametersModel implements ParametersModel {
+ private final ObservableMap availableExtractionModelProviders;
+ private final ObjectProperty extractionModelProvider;
private final ObservableList availableExtractionModels;
private final ObjectProperty extractionModel;
private final ObservableList availableOutputFormats;
@@ -43,10 +47,12 @@ public class FXParametersModel implements ParametersModel {
private final IntegerProperty maxLines;
@Inject
- FXParametersModel(final ExtractionModelProvider extractionModelProvider, @FontName final String defaultFontFamily,
+ FXParametersModel(final Map extractionModelProviders, final ExtractionModelProvider defaultProvider, @FontName final String defaultFontFamily,
@FontSize final int defaultFontSize, @MaxLineLength final int defaultMaxLineLength, @MaxLines final int defaultMaxLines) {
- this.availableExtractionModels = FXCollections.unmodifiableObservableList(FXCollections.observableArrayList(extractionModelProvider.getAvailableExtractionModels()));
- this.extractionModel = new SimpleObjectProperty<>(extractionModelProvider.getDefaultExtractionModel());
+ this.availableExtractionModelProviders = FXCollections.unmodifiableObservableMap(FXCollections.observableMap(extractionModelProviders));
+ this.extractionModelProvider = new SimpleObjectProperty<>(defaultProvider);
+ this.availableExtractionModels = FXCollections.observableArrayList(defaultProvider.getAvailableExtractionModels());
+ this.extractionModel = new SimpleObjectProperty<>(defaultProvider.getDefaultExtractionModel());
this.availableOutputFormats = FXCollections.unmodifiableObservableList(FXCollections.observableArrayList(OutputFormat.SRT));
this.outputFormat = new SimpleObjectProperty<>(OutputFormat.SRT);
this.availableFontFamilies = FXCollections.unmodifiableObservableList(FXCollections.observableArrayList("Arial"));
@@ -57,6 +63,12 @@ public class FXParametersModel implements ParametersModel {
this.maxLines = new SimpleIntegerProperty(defaultMaxLines);
font.bind(Bindings.createObjectBinding(() -> new FontImpl(fontName(), fontSize()), fontName, fontSize));
+ extractionModelProvider.addListener((observable, oldValue, newValue) -> {
+ if (newValue != null) {
+ availableExtractionModels.setAll(newValue.getAvailableExtractionModels());
+ extractionModel.set(newValue.getDefaultExtractionModel());
+ }
+ });
}
@Override
@@ -166,4 +178,12 @@ public class FXParametersModel implements ParametersModel {
public IntegerProperty maxLinesProperty() {
return maxLines;
}
+
+ ObservableMap availableExtractionModelProviders() {
+ return availableExtractionModelProviders;
+ }
+
+ ObjectProperty extractionModelProviderProperty() {
+ return extractionModelProvider;
+ }
}
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/FXSetupController.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/FXSetupController.java
index 808947b..c655108 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/FXSetupController.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/FXSetupController.java
@@ -1,10 +1,8 @@
package com.github.gtache.autosubtitle.gui.setup.fx;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.gui.fx.AbstractFXController;
import com.github.gtache.autosubtitle.gui.setup.SetupController;
-import com.github.gtache.autosubtitle.modules.setup.impl.SubtitleExtractorSetup;
-import com.github.gtache.autosubtitle.modules.setup.impl.TranslatorSetup;
-import com.github.gtache.autosubtitle.modules.setup.impl.VideoConverterSetup;
import com.github.gtache.autosubtitle.setup.SetupEvent;
import com.github.gtache.autosubtitle.setup.SetupException;
import com.github.gtache.autosubtitle.setup.SetupListener;
@@ -12,26 +10,29 @@ import com.github.gtache.autosubtitle.setup.SetupManager;
import com.github.gtache.autosubtitle.setup.SetupStatus;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
-import javafx.beans.property.DoubleProperty;
-import javafx.beans.property.ObjectProperty;
-import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.control.ProgressBar;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.Priority;
+import javafx.scene.layout.RowConstraints;
import javafx.stage.Window;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.controlsfx.control.PrefixSelectionComboBox;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
+import java.util.Arrays;
import java.util.ResourceBundle;
import java.util.concurrent.CompletableFuture;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+
+import static java.util.Objects.requireNonNull;
/**
* FX implementation of {@link SetupController}
@@ -41,233 +42,81 @@ public class FXSetupController extends AbstractFXController implements SetupCont
private static final Logger logger = LogManager.getLogger(FXSetupController.class);
+ @FXML
+ private GridPane setupGrid;
@FXML
private ResourceBundle resources;
- @FXML
- private Label converterNameLabel;
- @FXML
- private Label converterStatusLabel;
- @FXML
- private Label extractorNameLabel;
- @FXML
- private Label extractorStatusLabel;
- @FXML
- private Label translatorNameLabel;
- @FXML
- private Label translatorStatusLabel;
- @FXML
- private MenuButton converterButton;
- @FXML
- private MenuButton extractorButton;
- @FXML
- private MenuButton translatorButton;
- @FXML
- private ProgressBar converterProgress;
- @FXML
- private ProgressBar extractorProgress;
- @FXML
- private ProgressBar translatorProgress;
- @FXML
- private Label converterProgressLabel;
- @FXML
- private Label extractorProgressLabel;
- @FXML
- private Label translatorProgressLabel;
private final FXSetupModel model;
- private final SetupManager converterManager;
- private final SetupManager extractorManager;
- private final SetupManager translatorManager;
-
- private final Map> statusMap;
- private final Map setupProgressMessageMap;
- private final Map setupProgressMap;
+ private final Preferences preferences;
@Inject
- FXSetupController(final FXSetupModel model,
- @VideoConverterSetup final SetupManager converterManager,
- @SubtitleExtractorSetup final SetupManager extractorManager,
- @TranslatorSetup final SetupManager translatorManager) {
- this.model = Objects.requireNonNull(model);
- this.converterManager = Objects.requireNonNull(converterManager);
- this.extractorManager = Objects.requireNonNull(extractorManager);
- this.translatorManager = Objects.requireNonNull(translatorManager);
- statusMap = HashMap.newHashMap(3);
- setupProgressMessageMap = HashMap.newHashMap(3);
- setupProgressMap = HashMap.newHashMap(3);
+ FXSetupController(final FXSetupModel model, final Preferences preferences) {
+ this.model = requireNonNull(model);
+ this.preferences = requireNonNull(preferences);
}
@FXML
void initialize() {
- statusMap.put(converterManager, model.videoConverterStatusProperty());
- statusMap.put(extractorManager, model.subtitleExtractorStatusProperty());
- statusMap.put(translatorManager, model.translatorStatusProperty());
- setupProgressMessageMap.put(converterManager, model.videoConverterSetupProgressLabelProperty());
- setupProgressMessageMap.put(extractorManager, model.subtitleExtractorSetupProgressLabelProperty());
- setupProgressMessageMap.put(translatorManager, model.translatorSetupProgressLabelProperty());
- setupProgressMap.put(converterManager, model.videoConverterSetupProgressProperty());
- setupProgressMap.put(extractorManager, model.subtitleExtractorSetupProgressProperty());
- setupProgressMap.put(translatorManager, model.translatorSetupProgressProperty());
-
- bindMenu(converterButton, converterManager);
- bindMenu(extractorButton, extractorManager);
- bindMenu(translatorButton, translatorManager);
-
- model.setSubtitleExtractorStatus(extractorManager.status());
- model.setVideoConverterStatus(converterManager.status());
- model.setTranslatorStatus(translatorManager.status());
-
- converterNameLabel.setText(converterManager.name());
- extractorNameLabel.setText(extractorManager.name());
- translatorNameLabel.setText(translatorManager.name());
- bindLabelStatus(converterStatusLabel, model.videoConverterStatusProperty());
- bindLabelStatus(extractorStatusLabel, model.subtitleExtractorStatusProperty());
- bindLabelStatus(translatorStatusLabel, model.translatorStatusProperty());
-
- converterProgress.progressProperty().bindBidirectional(model.videoConverterSetupProgressProperty());
- extractorProgress.progressProperty().bindBidirectional(model.subtitleExtractorSetupProgressProperty());
- translatorProgress.progressProperty().bindBidirectional(model.translatorSetupProgressProperty());
-
- converterProgress.visibleProperty().bind(model.videoConverterSetupProgressProperty().greaterThan(-2));
- extractorProgress.visibleProperty().bind(model.subtitleExtractorSetupProgressProperty().greaterThan(-2));
- translatorProgress.visibleProperty().bind(model.translatorSetupProgressProperty().greaterThan(-2));
-
- converterProgressLabel.textProperty().bind(model.videoConverterSetupProgressLabelProperty());
- extractorProgressLabel.textProperty().bind(model.subtitleExtractorSetupProgressLabelProperty());
- translatorProgressLabel.textProperty().bind(model.translatorSetupProgressLabelProperty());
-
- converterProgressLabel.visibleProperty().bind(converterProgress.visibleProperty());
- extractorProgressLabel.visibleProperty().bind(extractorProgress.visibleProperty());
- translatorProgressLabel.visibleProperty().bind(translatorProgress.visibleProperty());
+ createGridRows();
+ Arrays.stream(ToolType.values()).forEach(t -> model.selectedToolProperty(t)
+ .addListener((observable, oldValue, newValue) -> saveSelectedTool(t, newValue)));
+ loadPreferences();
}
- private void bindMenu(final MenuButton button, final SetupManager setupManager) {
- button.disableProperty().bind(Bindings.isEmpty(button.getItems()));
- statusMap.get(setupManager).addListener((observable, oldValue, newValue) -> {
- button.getItems().clear();
- switch (newValue) {
- case NOT_INSTALLED -> {
- final var installItem = new MenuItem(resources.getString("setup.menu.install.label"));
- installItem.setOnAction(e -> tryInstall(setupManager));
- button.getItems().add(installItem);
- }
- case BUNDLE_INSTALLED -> {
- final var reinstallItem = new MenuItem(resources.getString("setup.menu.reinstall.label"));
- reinstallItem.setOnAction(e -> tryReinstall(setupManager));
- final var uninstallItem = new MenuItem(resources.getString("setup.menu.uninstall.label"));
- uninstallItem.setOnAction(e -> tryUninstall(setupManager));
- button.getItems().addAll(reinstallItem, uninstallItem);
- }
- case UPDATE_AVAILABLE -> {
- final var updateItem = new MenuItem(resources.getString("setup.menu.update.label"));
- updateItem.setOnAction(e -> tryUpdate(setupManager));
- final var reinstallItem = new MenuItem(resources.getString("setup.menu.reinstall.label"));
- reinstallItem.setOnAction(e -> tryReinstall(setupManager));
- final var uninstallItem = new MenuItem(resources.getString("setup.menu.uninstall.label"));
- uninstallItem.setOnAction(e -> tryUninstall(setupManager));
- button.getItems().addAll(updateItem, reinstallItem, uninstallItem);
- }
- case null, default -> {
- // Do nothing, buttons are cleared
- }
+ private void saveSelectedTool(final ToolType type, final String value) {
+ if (value != null) {
+ preferences.put(type.name(), value);
+ try {
+ preferences.flush();
+ } catch (final BackingStoreException e) {
+ logger.error("Error saving preferences", e);
}
- });
+ }
}
- private void bindLabelStatus(final Label label, final ObjectProperty status) {
- label.textProperty().bind(Bindings.createStringBinding(() -> resources.getString("setup.status." + status.get().name().toLowerCase() + ".label"), status));
+ private void loadPreferences() {
+ for (final var type : ToolType.values()) {
+ final var value = preferences.get(type.name(), model.selectedTool(type));
+ model.selectedToolProperty(type).set(value);
+ }
}
@Override
- public void installVideoConverter() {
- tryInstall(converterManager);
+ public void install(final ToolType type) {
+ trySetup(type, SetupManager::install, "install");
}
@Override
- public void uninstallVideoConverter() {
- tryUninstall(converterManager);
+ public void uninstall(final ToolType type) {
+ trySetup(type, SetupManager::uninstall, "uninstall");
}
@Override
- public void updateVideoConverter() {
- tryUpdate(converterManager);
+ public void update(final ToolType type) {
+ trySetup(type, SetupManager::update, "update");
}
@Override
- public void reinstallVideoConverter() {
- tryReinstall(converterManager);
+ public void reinstall(final ToolType type) {
+ trySetup(type, SetupManager::reinstall, "reinstall");
}
- @Override
- public void installSubtitleExtractor() {
- tryInstall(extractorManager);
- }
-
- @Override
- public void uninstallSubtitleExtractor() {
- tryUninstall(extractorManager);
- }
-
- @Override
- public void updateSubtitleExtractor() {
- tryUpdate(extractorManager);
- }
-
- @Override
- public void reinstallSubtitleExtractor() {
- tryReinstall(extractorManager);
- }
-
- @Override
- public void installTranslator() {
- tryInstall(translatorManager);
- }
-
- @Override
- public void uninstallTranslator() {
- tryUninstall(translatorManager);
- }
-
- @Override
- public void updateTranslator() {
- tryUpdate(translatorManager);
- }
-
- @Override
- public void reinstallTranslator() {
- tryReinstall(translatorManager);
- }
-
- private void tryInstall(final SetupManager manager) {
- trySetup(manager, SetupManager::install, "install");
- }
-
- private void tryUninstall(final SetupManager manager) {
- trySetup(manager, SetupManager::uninstall, "uninstall");
- }
-
- private void tryReinstall(final SetupManager manager) {
- trySetup(manager, SetupManager::reinstall, "reinstall");
- }
-
- private void tryUpdate(final SetupManager manager) {
- trySetup(manager, SetupManager::update, "update");
- }
-
- private void trySetup(final SetupManager manager, final SetupConsumer consumer, final String operation) {
+ private void trySetup(final ToolType type, final SetupConsumer consumer, final String operation) {
+ final var manager = model.selectedSetupManager(type);
manager.addListener(this);
CompletableFuture.runAsync(() -> {
try {
consumer.accept(manager);
Platform.runLater(() -> {
- statusMap.get(manager).set(manager.status());
- setupProgressMap.get(manager).set(-2);
+ model.setManagerStatus(type, manager.status());
+ model.setSetupProgress(type, -2);
});
} catch (final SetupException e) {
logger.error("Error {}ing {}", operation, manager.name(), e);
Platform.runLater(() -> {
- statusMap.get(manager).set(SetupStatus.ERRORED);
- setupProgressMap.get(manager).set(-2);
+ model.setManagerStatus(type, SetupStatus.ERRORED);
+ model.setSetupProgress(type, -2);
showErrorDialog(resources.getString("setup." + operation + ".error.title"),
MessageFormat.format(resources.getString("setup." + operation + ".error.label"), e.getMessage()));
});
@@ -300,15 +149,105 @@ public class FXSetupController extends AbstractFXController implements SetupCont
private void onAction(final SetupEvent event, final String display) {
final var manager = event.setupManager();
- final var property = setupProgressMessageMap.get(manager);
+ final var type = manager.type();
final var progress = event.progress();
- final var progressProperty = setupProgressMap.get(manager);
Platform.runLater(() -> {
- property.set(display);
- progressProperty.set(progress);
+ model.setSetupProgressLabel(type, display);
+ model.setSetupProgress(type, progress);
});
}
+ private void createGridRows() {
+ for (final var value : ToolType.values()) {
+ createGridRow(value);
+ }
+ }
+
+ private void createGridRow(final ToolType type) {
+ if (!model.availableSetupManagers(type).isEmpty()) {
+ createSelectionRow(type);
+ createProgressRow(type);
+ }
+ }
+
+ private void createSelectionRow(final ToolType type) {
+ final var label = new Label(resources.getString("setup." + type.name().toLowerCase() + ".choice.label"));
+ final var comboBox = new PrefixSelectionComboBox();
+ comboBox.setItems(model.availableSetupManagers(type));
+ comboBox.setConverter(new SetupManagerStringConverter());
+ comboBox.valueProperty().bindBidirectional(model.selectedSetupManagerProperty(type));
+ comboBox.disableProperty().bind(model.setupInProgressProperty(type));
+
+ final var rowIndex = setupGrid.getRowCount() - 1;
+ final var constraints = new RowConstraints();
+ constraints.setFillHeight(true);
+ constraints.setVgrow(Priority.SOMETIMES);
+ setupGrid.getRowConstraints().add(rowIndex, constraints);
+ setupGrid.add(label, 0, rowIndex);
+ setupGrid.add(comboBox, 1, rowIndex);
+ }
+
+ private void createProgressRow(final ToolType type) {
+ final var statusLabel = new Label();
+ final var installationButton = new MenuButton(resources.getString("setup.menu.label"));
+ final var progressBar = new ProgressBar();
+ final var progressLabel = new Label();
+ statusLabel.textProperty().bind(model.managerStatusProperty(type).map(s -> resources.getString("setup.status." + s.name().toLowerCase() + ".label")));
+ progressLabel.textProperty().bind(model.setupProgressLabelProperty(type));
+ progressLabel.visibleProperty().bind(model.setupInProgressProperty(type));
+ progressBar.progressProperty().bind(model.setupProgressProperty(type));
+ progressBar.visibleProperty().bind(model.setupInProgressProperty(type));
+ installationButton.disableProperty().bind(model.setupInProgressProperty(type).or(Bindings.isEmpty(installationButton.getItems())));
+ bindMenu(installationButton, type);
+ fillMenu(installationButton, type);
+
+ final var rowIndex = setupGrid.getRowCount() - 1;
+ final var constraints = new RowConstraints();
+ constraints.setFillHeight(true);
+ constraints.setVgrow(Priority.SOMETIMES);
+ setupGrid.getRowConstraints().add(rowIndex, constraints);
+ setupGrid.add(statusLabel, 1, rowIndex);
+ setupGrid.add(installationButton, 2, rowIndex);
+ setupGrid.add(progressBar, 3, rowIndex);
+ setupGrid.add(progressLabel, 4, rowIndex);
+ }
+
+ private void bindMenu(final MenuButton button, final ToolType type) {
+ model.managerStatusProperty(type).addListener((observable, oldValue, newValue) -> fillMenu(button, type));
+ }
+
+ private void fillMenu(final MenuButton button, final ToolType type) {
+ final var value = model.managerStatus(type);
+ button.getItems().clear();
+ switch (value) {
+ case NOT_INSTALLED -> {
+ final var installItem = new MenuItem(resources.getString("setup.menu.install.label"));
+ installItem.setOnAction(e -> install(type));
+ button.getItems().add(installItem);
+ }
+ case BUNDLE_INSTALLED -> {
+ final var reinstallItem = new MenuItem(resources.getString("setup.menu.reinstall.label"));
+ reinstallItem.setOnAction(e -> reinstall(type));
+ final var uninstallItem = new MenuItem(resources.getString("setup.menu.uninstall.label"));
+ uninstallItem.setOnAction(e -> uninstall(type));
+ button.getItems().addAll(reinstallItem, uninstallItem);
+ }
+ case UPDATE_AVAILABLE -> {
+ final var updateItem = new MenuItem(resources.getString("setup.menu.update.label"));
+ updateItem.setOnAction(e -> update(type));
+ final var reinstallItem = new MenuItem(resources.getString("setup.menu.reinstall.label"));
+ reinstallItem.setOnAction(e -> reinstall(type));
+ final var uninstallItem = new MenuItem(resources.getString("setup.menu.uninstall.label"));
+ uninstallItem.setOnAction(e -> uninstall(type));
+ button.getItems().addAll(updateItem, reinstallItem, uninstallItem);
+ }
+ case null, default -> {
+ // Do nothing, buttons are cleared
+ }
+ }
+ }
+
+
@FunctionalInterface
private interface SetupConsumer {
void accept(SetupManager manager) throws SetupException;
@@ -321,6 +260,7 @@ public class FXSetupController extends AbstractFXController implements SetupCont
@Override
public Window window() {
- return converterNameLabel.getScene().getWindow();
+ return setupGrid.getScene().getWindow();
}
+
}
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/FXSetupModel.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/FXSetupModel.java
index b8fb6aa..64f0c42 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/FXSetupModel.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/FXSetupModel.java
@@ -1,16 +1,25 @@
package com.github.gtache.autosubtitle.gui.setup.fx;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.gui.setup.SetupModel;
+import com.github.gtache.autosubtitle.setup.SetupManager;
import com.github.gtache.autosubtitle.setup.SetupStatus;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
+import javafx.beans.property.ReadOnlyBooleanProperty;
+import javafx.beans.property.ReadOnlyBooleanWrapper;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.collections.ObservableMap;
import javax.inject.Inject;
import javax.inject.Singleton;
+import java.util.Collection;
+import java.util.Map;
/**
* FX implementation of {@link SetupModel}
@@ -18,152 +27,146 @@ import javax.inject.Singleton;
@Singleton
public class FXSetupModel implements SetupModel {
- private final ObjectProperty subtitleExtractorStatus;
- private final DoubleProperty subtitleExtractorSetupProgress;
- private final StringProperty subtitleExtractorSetupProgressLabel;
- private final ObjectProperty videoConverterStatus;
- private final DoubleProperty videoConverterSetupProgress;
- private final StringProperty videoConverterSetupProgressLabel;
- private final ObjectProperty translatorStatus;
- private final DoubleProperty translatorSetupProgress;
- private final StringProperty translatorSetupProgressLabel;
+ private final ObservableMap> availableSetupManagers;
+ private final ObservableMap selectedTools;
+ private final ObservableMap> selectedSetupManagers;
+ private final ObservableMap> setupStatuses;
+ private final ObservableMap setupProgresses;
+ private final ObservableMap setupProgressLabels;
+ private final ObservableMap setupInProgress;
@Inject
- FXSetupModel() {
- this.subtitleExtractorStatus = new SimpleObjectProperty<>(SetupStatus.ERRORED);
- this.subtitleExtractorSetupProgress = new SimpleDoubleProperty(-2);
- this.subtitleExtractorSetupProgressLabel = new SimpleStringProperty("");
- this.videoConverterStatus = new SimpleObjectProperty<>(SetupStatus.ERRORED);
- this.videoConverterSetupProgress = new SimpleDoubleProperty(-2);
- this.videoConverterSetupProgressLabel = new SimpleStringProperty("");
- this.translatorStatus = new SimpleObjectProperty<>(SetupStatus.ERRORED);
- this.translatorSetupProgress = new SimpleDoubleProperty(-2);
- this.translatorSetupProgressLabel = new SimpleStringProperty("");
+ FXSetupModel(final Map> setupManagers,
+ final Map defaultManagers) {
+ final var tmpAvailableSetupManagers = FXCollections.>observableHashMap();
+ final var tmpSelectedTools = FXCollections.observableHashMap();
+ final var tmpSelectedSetupManagers = FXCollections.>observableHashMap();
+ final var tmpSetupStatuses = FXCollections.>observableHashMap();
+ final var tmpSetupProgresses = FXCollections.observableHashMap();
+ final var tmpSetupProgressLabels = FXCollections.observableHashMap();
+ final var tmpSetupEditables = FXCollections.observableHashMap();
+ setupManagers.forEach((type, managers) -> {
+ tmpAvailableSetupManagers.put(type, getUnmodifiableObservableList(managers.values()));
+ tmpSelectedTools.put(type, new SimpleStringProperty(getKeyForValue(managers, defaultManagers.get(type))));
+ tmpSelectedSetupManagers.put(type, new SimpleObjectProperty<>());
+ tmpSetupStatuses.put(type, new SimpleObjectProperty<>(SetupStatus.ERRORED));
+ tmpSetupProgresses.put(type, new SimpleDoubleProperty(-2));
+ tmpSetupProgressLabels.put(type, new SimpleStringProperty(""));
+ tmpSetupEditables.put(type, new ReadOnlyBooleanWrapper(false));
+ });
+ this.availableSetupManagers = FXCollections.unmodifiableObservableMap(tmpAvailableSetupManagers);
+ this.selectedTools = FXCollections.unmodifiableObservableMap(tmpSelectedTools);
+ this.selectedSetupManagers = FXCollections.unmodifiableObservableMap(tmpSelectedSetupManagers);
+ this.setupStatuses = FXCollections.unmodifiableObservableMap(tmpSetupStatuses);
+ this.setupProgresses = FXCollections.unmodifiableObservableMap(tmpSetupProgresses);
+ this.setupProgressLabels = FXCollections.unmodifiableObservableMap(tmpSetupProgressLabels);
+ this.setupInProgress = FXCollections.unmodifiableObservableMap(tmpSetupEditables);
+
+ selectedSetupManagers.forEach((type, value) -> value.addListener((observable, oldValue, newValue) ->
+ {
+ setupStatuses.get(type).set(newValue == null ? SetupStatus.ERRORED : newValue.status());
+ selectedTools.get(type).set(newValue == null ?
+ getKeyForValue(setupManagers.get(type), defaultManagers.get(type)) :
+ getKeyForValue(setupManagers.get(type), newValue));
+ }));
+ selectedTools.forEach((type, value) -> value.addListener((observable, oldValue, newValue) -> {
+ if (newValue != null) {
+ final var manager = setupManagers.get(type).get(newValue);
+ if (manager != null) {
+ setSelectedSetupManager(type, manager);
+ }
+ }
+ }));
+
+ setupInProgress.forEach((type, value) -> value.bind(setupProgresses.get(type).greaterThan(-2)));
+
+ defaultManagers.forEach(this::setSelectedSetupManager);
+ }
+
+ private static String getKeyForValue(final Map managers, final SetupManager manager) {
+ return managers.entrySet().stream().filter(e -> e.getValue() == manager).findFirst().orElseThrow().getKey();
}
@Override
- public SetupStatus subtitleExtractorStatus() {
- return subtitleExtractorStatus.get();
+ public ObservableList availableSetupManagers(final ToolType type) {
+ return this.availableSetupManagers.getOrDefault(type, FXCollections.emptyObservableList());
}
@Override
- public void setSubtitleExtractorStatus(final SetupStatus status) {
- subtitleExtractorStatus.set(status);
- }
-
- ObjectProperty subtitleExtractorStatusProperty() {
- return subtitleExtractorStatus;
+ public SetupManager selectedSetupManager(final ToolType type) {
+ return this.selectedSetupManagers.get(type).get();
}
@Override
- public double subtitleExtractorSetupProgress() {
- return subtitleExtractorSetupProgress.get();
+ public void setSelectedSetupManager(final ToolType type, final SetupManager manager) {
+ this.selectedSetupManagers.get(type).set(manager);
+ }
+
+ ObjectProperty selectedSetupManagerProperty(final ToolType type) {
+ return this.selectedSetupManagers.get(type);
}
@Override
- public void setSubtitleExtractorSetupProgress(final double progress) {
- subtitleExtractorSetupProgress.set(progress);
+ public String selectedTool(final ToolType type) {
+ return this.selectedTools.get(type).get();
}
- DoubleProperty subtitleExtractorSetupProgressProperty() {
- return subtitleExtractorSetupProgress;
+ public StringProperty selectedToolProperty(final ToolType type) {
+ return this.selectedTools.get(type);
}
@Override
- public String subtitleExtractorSetupProgressLabel() {
- return subtitleExtractorSetupProgressLabel.get();
+ public SetupStatus managerStatus(final ToolType type) {
+ return this.setupStatuses.get(type).get();
}
@Override
- public void setSubtitleExtractorSetupProgressLabel(final String label) {
- subtitleExtractorSetupProgressLabel.set(label);
+ public void setManagerStatus(final ToolType type, final SetupStatus status) {
+ this.setupStatuses.get(type).set(status);
}
- StringProperty subtitleExtractorSetupProgressLabelProperty() {
- return subtitleExtractorSetupProgressLabel;
+ ObjectProperty managerStatusProperty(final ToolType type) {
+ return this.setupStatuses.get(type);
}
@Override
- public SetupStatus videoConverterStatus() {
- return videoConverterStatus.get();
+ public double setupProgress(final ToolType type) {
+ return this.setupProgresses.get(type).get();
}
@Override
- public void setVideoConverterStatus(final SetupStatus status) {
- videoConverterStatus.set(status);
+ public void setSetupProgress(final ToolType type, final double progress) {
+ this.setupProgresses.get(type).set(progress);
}
- ObjectProperty videoConverterStatusProperty() {
- return videoConverterStatus;
+ DoubleProperty setupProgressProperty(final ToolType type) {
+ return this.setupProgresses.get(type);
}
@Override
- public double videoConverterSetupProgress() {
- return videoConverterSetupProgress.get();
+ public String setupProgressLabel(final ToolType type) {
+ return this.setupProgressLabels.get(type).get();
}
@Override
- public void setVideoConverterSetupProgress(final double progress) {
- videoConverterSetupProgress.set(progress);
+ public void setSetupProgressLabel(final ToolType type, final String label) {
+ this.setupProgressLabels.get(type).set(label);
}
- DoubleProperty videoConverterSetupProgressProperty() {
- return videoConverterSetupProgress;
+ StringProperty setupProgressLabelProperty(final ToolType type) {
+ return this.setupProgressLabels.get(type);
}
@Override
- public String videoConverterSetupProgressLabel() {
- return videoConverterSetupProgressLabel.get();
+ public boolean isSetupInProgress(final ToolType type) {
+ return this.setupInProgress.get(type).get();
}
- @Override
- public void setVideoConverterSetupProgressLabel(final String label) {
- videoConverterSetupProgressLabel.set(label);
+ ReadOnlyBooleanProperty setupInProgressProperty(final ToolType type) {
+ return this.setupInProgress.get(type).getReadOnlyProperty();
}
- StringProperty videoConverterSetupProgressLabelProperty() {
- return videoConverterSetupProgressLabel;
- }
-
- @Override
- public SetupStatus translatorStatus() {
- return translatorStatus.get();
- }
-
- @Override
- public void setTranslatorStatus(final SetupStatus status) {
- translatorStatus.set(status);
- }
-
- ObjectProperty translatorStatusProperty() {
- return translatorStatus;
- }
-
- @Override
- public double translatorSetupProgress() {
- return translatorSetupProgress.get();
- }
-
- @Override
- public void setTranslatorSetupProgress(final double progress) {
- translatorSetupProgress.set(progress);
- }
-
- DoubleProperty translatorSetupProgressProperty() {
- return translatorSetupProgress;
- }
-
- @Override
- public String translatorSetupProgressLabel() {
- return translatorSetupProgressLabel.get();
- }
-
- @Override
- public void setTranslatorSetupProgressLabel(final String label) {
- translatorSetupProgressLabel.set(label);
- }
-
- StringProperty translatorSetupProgressLabelProperty() {
- return translatorSetupProgressLabel;
+ private static ObservableList getUnmodifiableObservableList(final Collection extends T> collection) {
+ return FXCollections.unmodifiableObservableList(FXCollections.observableArrayList(collection));
}
}
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/SetupManagerStringConverter.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/SetupManagerStringConverter.java
new file mode 100644
index 0000000..a216268
--- /dev/null
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/setup/fx/SetupManagerStringConverter.java
@@ -0,0 +1,16 @@
+package com.github.gtache.autosubtitle.gui.setup.fx;
+
+import com.github.gtache.autosubtitle.setup.SetupManager;
+import javafx.util.StringConverter;
+
+class SetupManagerStringConverter extends StringConverter {
+ @Override
+ public String toString(final SetupManager object) {
+ return object.name();
+ }
+
+ @Override
+ public SetupManager fromString(final String string) {
+ return null;
+ }
+}
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesBinder.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesBinder.java
index fe4e535..a00d665 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesBinder.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesBinder.java
@@ -1,8 +1,10 @@
package com.github.gtache.autosubtitle.gui.subtitles.fx;
import com.github.gtache.autosubtitle.Language;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.gui.fx.FXBinder;
import com.github.gtache.autosubtitle.gui.parameters.fx.FXParametersModel;
+import com.github.gtache.autosubtitle.gui.setup.fx.FXSetupModel;
import com.github.gtache.autosubtitle.gui.work.WorkStatus;
import com.github.gtache.autosubtitle.gui.work.fx.FXWorkModel;
import com.github.gtache.autosubtitle.subtitle.converter.impl.FormatOptionsImpl;
@@ -14,7 +16,8 @@ import javafx.beans.binding.Bindings;
import javax.inject.Inject;
import javax.inject.Singleton;
-import java.util.Objects;
+
+import static java.util.Objects.requireNonNull;
/**
* Binds the subtitles model
@@ -24,13 +27,15 @@ public class FXSubtitlesBinder implements FXBinder {
private final FXWorkModel workModel;
private final FXParametersModel parametersModel;
+ private final FXSetupModel setupModel;
private final FXSubtitlesModel subtitlesModel;
@Inject
- FXSubtitlesBinder(final FXWorkModel workModel, final FXParametersModel parametersModel, final FXSubtitlesModel subtitlesModel) {
- this.workModel = Objects.requireNonNull(workModel);
- this.parametersModel = Objects.requireNonNull(parametersModel);
- this.subtitlesModel = Objects.requireNonNull(subtitlesModel);
+ FXSubtitlesBinder(final FXWorkModel workModel, final FXParametersModel parametersModel, final FXSetupModel setupModel, final FXSubtitlesModel subtitlesModel) {
+ this.workModel = requireNonNull(workModel);
+ this.parametersModel = requireNonNull(parametersModel);
+ this.setupModel = requireNonNull(setupModel);
+ this.subtitlesModel = requireNonNull(subtitlesModel);
}
@Override
@@ -74,5 +79,12 @@ public class FXSubtitlesBinder implements FXBinder {
final var parseOptions = new ParseOptionsImpl(parametersModel.maxLineLength(), parametersModel.maxLines(), parametersModel.font());
return new ImportOptionsImpl(parseOptions);
}, parametersModel.maxLineLengthProperty(), parametersModel.maxLinesProperty(), parametersModel.fontProperty()));
+
+
+ setupModel.selectedToolProperty(ToolType.TRANSLATOR).addListener((observable, oldValue, newValue) -> {
+ if (newValue != null) {
+ subtitlesModel.translatorProperty().set(subtitlesModel.availableTranslators().get(newValue));
+ }
+ });
}
}
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesController.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesController.java
index af666ec..d91f5ff 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesController.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesController.java
@@ -10,7 +10,6 @@ import com.github.gtache.autosubtitle.subtitle.converter.ParseException;
import com.github.gtache.autosubtitle.subtitle.gui.fx.ObservableSubtitleCollectionImpl;
import com.github.gtache.autosubtitle.subtitle.gui.fx.ObservableSubtitleImpl;
import com.github.gtache.autosubtitle.translation.TranslationException;
-import com.github.gtache.autosubtitle.translation.Translator;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleObjectProperty;
@@ -87,21 +86,18 @@ public class FXSubtitlesController extends AbstractFXController implements Subti
private TableColumn textColumn;
private final FXSubtitlesModel model;
- private final FXSubtitlesBinder binder;
private final SubtitleImporterExporter> importerExporter;
private final TimeFormatter timeFormatter;
private final List subtitleExtensions;
- private final Translator> translator;
@Inject
- FXSubtitlesController(final FXSubtitlesModel model, final FXSubtitlesBinder binder, final SubtitleImporterExporter importerExporter, final TimeFormatter timeFormatter,
- final Translator translator) {
+ FXSubtitlesController(final FXSubtitlesModel model, final FXSubtitlesBinder binder,
+ final SubtitleImporterExporter importerExporter, final TimeFormatter timeFormatter) {
this.model = requireNonNull(model);
- this.binder = requireNonNull(binder);
this.importerExporter = requireNonNull(importerExporter);
this.timeFormatter = requireNonNull(timeFormatter);
this.subtitleExtensions = importerExporter.supportedSingleFileExtensions().stream().map(c -> "*." + c).sorted().toList();
- this.translator = requireNonNull(translator);
+ binder.createBindings();
}
@FXML
@@ -135,7 +131,6 @@ public class FXSubtitlesController extends AbstractFXController implements Subti
});
translationsCombobox.setOnAction(e -> translateToNewLanguage());
- binder.createBindings();
}
private void translateToNewLanguage() {
@@ -149,10 +144,10 @@ public class FXSubtitlesController extends AbstractFXController implements Subti
if (model.selectedCollection() == null) {
return null;
} else {
- return translator.translate(model.selectedCollection(), value);
+ return model.translatorProperty().get().translate(model.selectedCollection(), value);
}
} else {
- return translator.translate(mainCollection, value);
+ return model.translatorProperty().get().translate(mainCollection, value);
}
} catch (final TranslationException ex) {
throw new CompletionException(ex);
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesModel.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesModel.java
index 697f6fd..9bea1e8 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesModel.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/subtitles/fx/FXSubtitlesModel.java
@@ -6,6 +6,7 @@ import com.github.gtache.autosubtitle.subtitle.ExportOptions;
import com.github.gtache.autosubtitle.subtitle.ImportOptions;
import com.github.gtache.autosubtitle.subtitle.gui.fx.ObservableSubtitleCollectionImpl;
import com.github.gtache.autosubtitle.subtitle.gui.fx.ObservableSubtitleImpl;
+import com.github.gtache.autosubtitle.translation.Translator;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
@@ -22,6 +23,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.Map;
/**
* FX implementation of {@link SubtitlesModel}
@@ -39,6 +41,8 @@ public class FXSubtitlesModel implements SubtitlesModel selectedCollection;
private final ObservableList selectedSubtitles;
private final ObjectProperty selectedSubtitle;
+ private final ObservableMap> availableTranslators;
+ private final ObjectProperty> translator;
private final BooleanProperty canLoadSubtitles;
private final BooleanProperty canAddSubtitle;
@@ -50,7 +54,8 @@ public class FXSubtitlesModel implements SubtitlesModel importOptions;
@Inject
- FXSubtitlesModel() {
+ FXSubtitlesModel(final Map> translators, final Translator defaultTranslator) {
+ this.availableTranslators = FXCollections.unmodifiableObservableMap(FXCollections.observableMap(translators));
this.availableVideoLanguages = FXCollections.unmodifiableObservableList(FXCollections.observableArrayList(Arrays.stream(Language.values())
.sorted((o1, o2) -> {
if (o1 == Language.AUTO) {
@@ -78,6 +83,7 @@ public class FXSubtitlesModel implements SubtitlesModel();
this.importOptions = new SimpleObjectProperty<>();
+ this.translator = new SimpleObjectProperty<>(defaultTranslator);
canSaveSubtitles.bind(Bindings.isNotEmpty(collections));
collections.addListener((MapChangeListener) change ->
@@ -275,4 +281,12 @@ public class FXSubtitlesModel implements SubtitlesModel importOptionsProperty() {
return importOptions;
}
+
+ public ObservableMap> availableTranslators() {
+ return availableTranslators;
+ }
+
+ public ObjectProperty> translatorProperty() {
+ return translator;
+ }
}
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/work/fx/FXWorkController.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/work/fx/FXWorkController.java
index f9c2a62..16c3855 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/work/fx/FXWorkController.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/work/fx/FXWorkController.java
@@ -1,7 +1,5 @@
package com.github.gtache.autosubtitle.gui.work.fx;
-import com.github.gtache.autosubtitle.VideoConverter;
-import com.github.gtache.autosubtitle.VideoLoader;
import com.github.gtache.autosubtitle.gui.fx.AbstractFXController;
import com.github.gtache.autosubtitle.gui.media.fx.FXMediaController;
import com.github.gtache.autosubtitle.gui.work.WorkController;
@@ -9,7 +7,6 @@ import com.github.gtache.autosubtitle.gui.work.WorkStatus;
import com.github.gtache.autosubtitle.subtitle.SubtitleCollection;
import com.github.gtache.autosubtitle.subtitle.extractor.ExtractEvent;
import com.github.gtache.autosubtitle.subtitle.extractor.ExtractException;
-import com.github.gtache.autosubtitle.subtitle.extractor.SubtitleExtractor;
import com.github.gtache.autosubtitle.subtitle.extractor.SubtitleExtractorListener;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
@@ -52,18 +49,14 @@ public class FXWorkController extends AbstractFXController implements WorkContro
@FXML
private TextField fileField;
-
@FXML
private Button extractButton;
-
@FXML
private Button exportSoftButton;
@FXML
private Button exportHardButton;
-
@FXML
private FXMediaController mediaController;
-
@FXML
private Label progressLabel;
@FXML
@@ -74,19 +67,11 @@ public class FXWorkController extends AbstractFXController implements WorkContro
private ResourceBundle resources;
private final FXWorkModel model;
- private final FXWorkBinder binder;
- private final SubtitleExtractor> subtitleExtractor;
- private final VideoConverter videoConverter;
- private final VideoLoader videoLoader;
@Inject
- FXWorkController(final FXWorkModel model, final FXWorkBinder binder, final SubtitleExtractor subtitleExtractor,
- final VideoLoader videoLoader, final VideoConverter videoConverter) {
+ FXWorkController(final FXWorkModel model, final FXWorkBinder binder) {
this.model = requireNonNull(model);
- this.binder = requireNonNull(binder);
- this.subtitleExtractor = requireNonNull(subtitleExtractor);
- this.videoConverter = requireNonNull(videoConverter);
- this.videoLoader = requireNonNull(videoLoader);
+ binder.createBindings();
}
@FXML
@@ -103,9 +88,11 @@ public class FXWorkController extends AbstractFXController implements WorkContro
}
});
- binder.createBindings();
-
- subtitleExtractor.addListener(this);
+ model.subtitleExtractorProperty().addListener((observable, oldValue, newValue) -> {
+ if (newValue != null) {
+ newValue.addListener(FXWorkController.this);
+ }
+ });
}
private void bindProgress() {
@@ -142,7 +129,7 @@ public class FXWorkController extends AbstractFXController implements WorkContro
private SubtitleCollection> extractAsync() {
try {
- return subtitleExtractor.extract(model.video(), model.extractOptions());
+ return model.subtitleExtractorProperty().get().extract(model.video(), model.extractOptions());
} catch (final ExtractException e) {
throw new CompletionException(e);
}
@@ -161,7 +148,7 @@ public class FXWorkController extends AbstractFXController implements WorkContro
@Override
public void loadVideo(final Path file) {
try {
- final var loadedVideo = videoLoader.loadVideo(file);
+ final var loadedVideo = model.videoLoaderProperty().get().loadVideo(file);
fileField.setText(file.toAbsolutePath().toString());
model.videoProperty().set(loadedVideo);
} catch (final IOException e) {
@@ -182,7 +169,7 @@ public class FXWorkController extends AbstractFXController implements WorkContro
model.setStatus(WorkStatus.EXPORTING);
CompletableFuture.runAsync(() -> {
try {
- videoConverter.addSoftSubtitles(model.video(), model.collections().values(), model.exportOptions(), file.toPath());
+ model.videoConverterProperty().get().addSoftSubtitles(model.video(), model.collections().values(), model.exportOptions(), file.toPath());
} catch (final IOException e) {
throw new CompletionException(e);
}
@@ -207,7 +194,7 @@ public class FXWorkController extends AbstractFXController implements WorkContro
model.setStatus(WorkStatus.EXPORTING);
CompletableFuture.runAsync(() -> {
try {
- videoConverter.addHardSubtitles(model.video(), model.collections().get(model.extractOptions().language()), model.exportOptions(), file.toPath());
+ model.videoConverterProperty().get().addHardSubtitles(model.video(), model.collections().get(model.extractOptions().language()), model.exportOptions(), file.toPath());
} catch (final IOException e) {
throw new CompletionException(e);
}
diff --git a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/work/fx/FXWorkModel.java b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/work/fx/FXWorkModel.java
index b3658c8..bb4561b 100644
--- a/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/work/fx/FXWorkModel.java
+++ b/gui/fx/src/main/java/com/github/gtache/autosubtitle/gui/work/fx/FXWorkModel.java
@@ -2,12 +2,15 @@ package com.github.gtache.autosubtitle.gui.work.fx;
import com.github.gtache.autosubtitle.Language;
import com.github.gtache.autosubtitle.Video;
+import com.github.gtache.autosubtitle.VideoConverter;
+import com.github.gtache.autosubtitle.VideoLoader;
import com.github.gtache.autosubtitle.gui.work.WorkModel;
import com.github.gtache.autosubtitle.gui.work.WorkStatus;
import com.github.gtache.autosubtitle.subtitle.EditableSubtitle;
import com.github.gtache.autosubtitle.subtitle.ExportOptions;
import com.github.gtache.autosubtitle.subtitle.SubtitleCollection;
import com.github.gtache.autosubtitle.subtitle.extractor.ExtractOptions;
+import com.github.gtache.autosubtitle.subtitle.extractor.SubtitleExtractor;
import com.github.gtache.autosubtitle.subtitle.gui.fx.ObservableSubtitleCollectionImpl;
import com.github.gtache.autosubtitle.subtitle.gui.fx.ObservableSubtitleImpl;
import javafx.beans.property.BooleanProperty;
@@ -24,6 +27,7 @@ import javafx.collections.ObservableMap;
import javax.inject.Inject;
import javax.inject.Singleton;
+import java.util.Map;
/**
* FX implementation of {@link WorkModel}
@@ -31,6 +35,12 @@ import javax.inject.Singleton;
@Singleton
public class FXWorkModel implements WorkModel {
+ private final ObservableMap> availableSubtitleExtractors;
+ private final ObjectProperty> subtitleExtractor;
+ private final ObservableMap availableVideoLoaders;
+ private final ObjectProperty videoLoader;
+ private final ObservableMap availableVideoConverters;
+ private final ObjectProperty videoConverter;
private final ObjectProperty
+
+ com.github.gtache.autosubtitle
+ autosubtitle-whisper-base
+
com.github.gtache.autosubtitle
autosubtitle-whisperx
diff --git a/gui/run/src/main/java/com/github/gtache/autosubtitle/modules/gui/run/RunComponent.java b/gui/run/src/main/java/com/github/gtache/autosubtitle/modules/gui/run/RunComponent.java
index 7066b1d..623b9e6 100644
--- a/gui/run/src/main/java/com/github/gtache/autosubtitle/modules/gui/run/RunComponent.java
+++ b/gui/run/src/main/java/com/github/gtache/autosubtitle/modules/gui/run/RunComponent.java
@@ -5,6 +5,7 @@ import com.github.gtache.autosubtitle.modules.ffmpeg.FFmpegModule;
import com.github.gtache.autosubtitle.modules.gui.fx.FXModule;
import com.github.gtache.autosubtitle.modules.gui.impl.GuiCoreModule;
import com.github.gtache.autosubtitle.modules.impl.CoreModule;
+import com.github.gtache.autosubtitle.modules.whisper.base.WhisperModule;
import com.github.gtache.autosubtitle.modules.whisperx.WhisperXModule;
import dagger.Component;
import javafx.fxml.FXMLLoader;
@@ -17,7 +18,7 @@ import javax.inject.Singleton;
@FunctionalInterface
@Singleton
@Component(modules = {CoreModule.class, GuiCoreModule.class, FXModule.class, FFmpegModule.class,
- WhisperXModule.class, DeepLModule.class})
+ WhisperModule.class, WhisperXModule.class, DeepLModule.class})
public interface RunComponent {
/**
diff --git a/gui/run/src/main/java/module-info.java b/gui/run/src/main/java/module-info.java
index c6c0877..27da7f2 100644
--- a/gui/run/src/main/java/module-info.java
+++ b/gui/run/src/main/java/module-info.java
@@ -5,6 +5,7 @@ module com.github.gtache.autosubtitle.gui.run {
requires com.github.gtache.autosubtitle.deepl;
requires com.github.gtache.autosubtitle.ffmpeg;
requires com.github.gtache.autosubtitle.gui.fx;
+ requires com.github.gtache.autosubtitle.whisper.base;
requires com.github.gtache.autosubtitle.whisperx;
requires javafx.fxml;
requires javafx.graphics;
diff --git a/pom.xml b/pom.xml
index d5d21bb..26d863e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,12 +26,12 @@
21
UTF-8
- 1.27.0
- 2.51.1
- 2.17.2
- 5.10.3
+ 1.27.1
+ 2.52
+ 2.18.0
+ 5.11.1
2.23.1
- 5.12.0
+ 5.14.0
4.7.6
1.10
@@ -88,6 +88,11 @@
autosubtitle-whisper
${project.version}
+
+ com.github.gtache.autosubtitle
+ autosubtitle-whisper-base
+ ${project.version}
+
com.github.gtache.autosubtitle
autosubtitle-whisperx
@@ -238,9 +243,31 @@
true
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+
+ properties
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ @{argLine} -javaagent:${org.mockito:mockito-core:jar}
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
org.jacoco
jacoco-maven-plugin
diff --git a/whisper/base/pom.xml b/whisper/base/pom.xml
index fa02a0c..16cf185 100644
--- a/whisper/base/pom.xml
+++ b/whisper/base/pom.xml
@@ -15,9 +15,5 @@
com.github.gtache.autosubtitle
autosubtitle-whisper-common
-
- com.fasterxml.jackson.core
- jackson-databind
-
\ No newline at end of file
diff --git a/whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/PythonVersion.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/Whisper.java
similarity index 79%
rename from whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/PythonVersion.java
rename to whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/Whisper.java
index dfec987..1da1e39 100644
--- a/whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/PythonVersion.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/Whisper.java
@@ -1,4 +1,4 @@
-package com.github.gtache.autosubtitle.modules.setup.whisper;
+package com.github.gtache.autosubtitle.modules.setup.whisper.base;
import javax.inject.Qualifier;
import java.lang.annotation.Documented;
@@ -12,5 +12,5 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Documented
@Retention(RUNTIME)
@Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
-public @interface PythonVersion {
+public @interface Whisper {
}
diff --git a/whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/WhisperBundledRoot.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperBundledRoot.java
similarity index 85%
rename from whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/WhisperBundledRoot.java
rename to whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperBundledRoot.java
index ef225c8..34221e6 100644
--- a/whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/WhisperBundledRoot.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperBundledRoot.java
@@ -1,4 +1,4 @@
-package com.github.gtache.autosubtitle.modules.setup.whisper;
+package com.github.gtache.autosubtitle.modules.setup.whisper.base;
import javax.inject.Qualifier;
import java.lang.annotation.Documented;
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperPythonVersion.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperPythonVersion.java
new file mode 100644
index 0000000..774778b
--- /dev/null
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperPythonVersion.java
@@ -0,0 +1,16 @@
+package com.github.gtache.autosubtitle.modules.setup.whisper.base;
+
+import javax.inject.Qualifier;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Qualifier
+@Documented
+@Retention(RUNTIME)
+@Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
+public @interface WhisperPythonVersion {
+}
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperSetupModule.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperSetupModule.java
index 51383ab..dc92d1a 100644
--- a/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperSetupModule.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperSetupModule.java
@@ -1,30 +1,33 @@
package com.github.gtache.autosubtitle.modules.setup.whisper.base;
+import com.github.gtache.autosubtitle.impl.OS;
+import com.github.gtache.autosubtitle.modules.setup.conda.CondaSetupModule;
import com.github.gtache.autosubtitle.modules.setup.impl.SubtitleExtractorSetup;
import com.github.gtache.autosubtitle.modules.setup.impl.ToolsRoot;
-import com.github.gtache.autosubtitle.modules.setup.whisper.PythonVersion;
-import com.github.gtache.autosubtitle.modules.setup.whisper.WhisperBundledRoot;
-import com.github.gtache.autosubtitle.modules.setup.whisper.WhisperCommonSetupModule;
-import com.github.gtache.autosubtitle.modules.setup.whisper.WhisperVenvPath;
import com.github.gtache.autosubtitle.setup.SetupManager;
+import com.github.gtache.autosubtitle.setup.whisper.WhisperSetupConfiguration;
import com.github.gtache.autosubtitle.setup.whisper.base.WhisperSetupManager;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
+import dagger.multibindings.IntoMap;
+import dagger.multibindings.StringKey;
import java.nio.file.Path;
/**
* Setup module for Whisper
*/
-@Module(includes = WhisperCommonSetupModule.class)
+@Module(includes = CondaSetupModule.class)
public abstract class WhisperSetupModule {
@Binds
@SubtitleExtractorSetup
+ @IntoMap
+ @StringKey("whisper")
abstract SetupManager bindsSubtitleExtractorSetupManager(final WhisperSetupManager manager);
@Provides
- @PythonVersion
+ @WhisperPythonVersion
static String providesPythonVersion() {
return "3.9.19";
}
@@ -40,4 +43,13 @@ public abstract class WhisperSetupModule {
static Path providesWhisperVenvPath(@WhisperBundledRoot final Path root) {
return root.resolve("whisper-env");
}
+
+ @Provides
+ @Whisper
+ static WhisperSetupConfiguration providesWhisperSetupConfiguration(@WhisperBundledRoot final Path root,
+ @WhisperVenvPath final Path venvPath,
+ @WhisperPythonVersion final String pythonVersion,
+ final OS os) {
+ return new WhisperSetupConfiguration(root, venvPath, pythonVersion, os);
+ }
}
diff --git a/whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/WhisperVenvPath.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperVenvPath.java
similarity index 85%
rename from whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/WhisperVenvPath.java
rename to whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperVenvPath.java
index 85d9eeb..9977780 100644
--- a/whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/WhisperVenvPath.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/base/WhisperVenvPath.java
@@ -1,4 +1,4 @@
-package com.github.gtache.autosubtitle.modules.setup.whisper;
+package com.github.gtache.autosubtitle.modules.setup.whisper.base;
import javax.inject.Qualifier;
import java.lang.annotation.Documented;
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/extractor/whisper/base/WhisperExtractorModule.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/extractor/whisper/base/WhisperExtractorModule.java
index ed0bfbd..1d9002f 100644
--- a/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/extractor/whisper/base/WhisperExtractorModule.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/extractor/whisper/base/WhisperExtractorModule.java
@@ -4,6 +4,8 @@ import com.github.gtache.autosubtitle.subtitle.extractor.SubtitleExtractor;
import com.github.gtache.autosubtitle.subtitle.extractor.whisper.base.WhisperSubtitleExtractor;
import dagger.Binds;
import dagger.Module;
+import dagger.multibindings.IntoMap;
+import dagger.multibindings.StringKey;
/**
* Dagger module for Whisper
@@ -16,5 +18,7 @@ public abstract class WhisperExtractorModule {
}
@Binds
- abstract SubtitleExtractor bindsSubtitleExtractor(final WhisperSubtitleExtractor extractor);
+ @IntoMap
+ @StringKey("whisper")
+ abstract SubtitleExtractor> bindsSubtitleExtractor(final WhisperSubtitleExtractor extractor);
}
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/parser/json/whisper/base/WhisperJsonModule.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/parser/json/whisper/base/WhisperJsonModule.java
deleted file mode 100644
index 4ff93e6..0000000
--- a/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/subtitle/parser/json/whisper/base/WhisperJsonModule.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.github.gtache.autosubtitle.modules.subtitle.parser.json.whisper.base;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.gtache.autosubtitle.subtitle.converter.SubtitleConverter;
-import com.github.gtache.autosubtitle.subtitle.parser.json.whisper.base.JSONSubtitleConverter;
-import dagger.Binds;
-import dagger.Module;
-import dagger.Provides;
-import dagger.multibindings.IntoMap;
-import dagger.multibindings.StringKey;
-
-import javax.inject.Singleton;
-
-@Module
-public abstract class WhisperJsonModule {
-
- private WhisperJsonModule() {
-
- }
-
- @Binds
- @IntoMap
- @StringKey("json")
- abstract SubtitleConverter bindsJSONSubtitleConverter(final JSONSubtitleConverter subtitleConverter);
-
- @Provides
- @Singleton
- static ObjectMapper providesObjectMapper() {
- return new ObjectMapper();
- }
-}
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/whisper/base/WhisperModule.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/whisper/base/WhisperModule.java
index 1921f89..c9d1ed9 100644
--- a/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/whisper/base/WhisperModule.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/modules/whisper/base/WhisperModule.java
@@ -2,16 +2,17 @@ package com.github.gtache.autosubtitle.modules.whisper.base;
import com.github.gtache.autosubtitle.modules.setup.whisper.base.WhisperSetupModule;
import com.github.gtache.autosubtitle.modules.subtitle.extractor.whisper.base.WhisperExtractorModule;
-import com.github.gtache.autosubtitle.modules.subtitle.parser.json.whisper.base.WhisperJsonModule;
import com.github.gtache.autosubtitle.subtitle.extractor.ExtractionModelProvider;
import com.github.gtache.autosubtitle.whisper.base.WhisperExtractionModelProvider;
import dagger.Binds;
import dagger.Module;
+import dagger.multibindings.IntoMap;
+import dagger.multibindings.StringKey;
/**
* Dagger module for Whisper
*/
-@Module(includes = {WhisperSetupModule.class, WhisperJsonModule.class, WhisperExtractorModule.class})
+@Module(includes = {WhisperSetupModule.class, WhisperExtractorModule.class})
public abstract class WhisperModule {
private WhisperModule() {
@@ -19,5 +20,7 @@ public abstract class WhisperModule {
}
@Binds
+ @IntoMap
+ @StringKey("whisper")
abstract ExtractionModelProvider bindsExtractionModelProvider(final WhisperExtractionModelProvider provider);
}
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/setup/whisper/base/WhisperSetupManager.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/setup/whisper/base/WhisperSetupManager.java
index 876851a..e36ff8b 100644
--- a/whisper/base/src/main/java/com/github/gtache/autosubtitle/setup/whisper/base/WhisperSetupManager.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/setup/whisper/base/WhisperSetupManager.java
@@ -1,7 +1,9 @@
package com.github.gtache.autosubtitle.setup.whisper.base;
+import com.github.gtache.autosubtitle.modules.setup.whisper.base.Whisper;
import com.github.gtache.autosubtitle.process.ProcessRunner;
import com.github.gtache.autosubtitle.setup.SetupException;
+import com.github.gtache.autosubtitle.setup.SetupManager;
import com.github.gtache.autosubtitle.setup.conda.CondaSetupManager;
import com.github.gtache.autosubtitle.setup.whisper.AbstractWhisperSetupManager;
import com.github.gtache.autosubtitle.setup.whisper.WhisperSetupConfiguration;
@@ -17,7 +19,7 @@ import java.time.Duration;
import java.util.List;
/**
- * {@link com.github.gtache.autosubtitle.setup.SetupManager} for Whisper
+ * {@link SetupManager} for Whisper
*/
@Singleton
public class WhisperSetupManager extends AbstractWhisperSetupManager {
@@ -25,7 +27,7 @@ public class WhisperSetupManager extends AbstractWhisperSetupManager {
private static final Logger logger = LogManager.getLogger(WhisperSetupManager.class);
@Inject
- WhisperSetupManager(final CondaSetupManager condaSetupManager, final WhisperSetupConfiguration configuration,
+ WhisperSetupManager(final CondaSetupManager condaSetupManager, @Whisper final WhisperSetupConfiguration configuration,
final ProcessRunner processRunner, final HttpClient httpClient) {
super(condaSetupManager, configuration, processRunner, httpClient);
}
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/parser/json/whisper/base/JSONSubtitleConverter.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/whisper/base/JSONSubtitleConverter.java
similarity index 97%
rename from whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/parser/json/whisper/base/JSONSubtitleConverter.java
rename to whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/whisper/base/JSONSubtitleConverter.java
index b5c2688..a4e83dd 100644
--- a/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/parser/json/whisper/base/JSONSubtitleConverter.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/whisper/base/JSONSubtitleConverter.java
@@ -1,4 +1,4 @@
-package com.github.gtache.autosubtitle.subtitle.parser.json.whisper.base;
+package com.github.gtache.autosubtitle.subtitle.converter.json.whisper.base;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/parser/json/whisper/base/JSONSubtitleSegment.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/whisper/base/JSONSubtitleSegment.java
similarity index 79%
rename from whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/parser/json/whisper/base/JSONSubtitleSegment.java
rename to whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/whisper/base/JSONSubtitleSegment.java
index 61d37cd..4d964f3 100644
--- a/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/parser/json/whisper/base/JSONSubtitleSegment.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/whisper/base/JSONSubtitleSegment.java
@@ -1,4 +1,4 @@
-package com.github.gtache.autosubtitle.subtitle.parser.json.whisper.base;
+package com.github.gtache.autosubtitle.subtitle.converter.json.whisper.base;
import java.util.List;
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/parser/json/whisper/base/JSONSubtitles.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/whisper/base/JSONSubtitles.java
similarity index 61%
rename from whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/parser/json/whisper/base/JSONSubtitles.java
rename to whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/whisper/base/JSONSubtitles.java
index 37009ef..01cb43f 100644
--- a/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/parser/json/whisper/base/JSONSubtitles.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/converter/json/whisper/base/JSONSubtitles.java
@@ -1,4 +1,4 @@
-package com.github.gtache.autosubtitle.subtitle.parser.json.whisper.base;
+package com.github.gtache.autosubtitle.subtitle.converter.json.whisper.base;
import java.util.List;
diff --git a/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/extractor/whisper/base/WhisperSubtitleExtractor.java b/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/extractor/whisper/base/WhisperSubtitleExtractor.java
index 5b5eab4..b98fc45 100644
--- a/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/extractor/whisper/base/WhisperSubtitleExtractor.java
+++ b/whisper/base/src/main/java/com/github/gtache/autosubtitle/subtitle/extractor/whisper/base/WhisperSubtitleExtractor.java
@@ -2,9 +2,9 @@ package com.github.gtache.autosubtitle.subtitle.extractor.whisper.base;
import com.github.gtache.autosubtitle.Language;
import com.github.gtache.autosubtitle.impl.OS;
-import com.github.gtache.autosubtitle.modules.setup.whisper.WhisperVenvPath;
+import com.github.gtache.autosubtitle.modules.setup.whisper.base.WhisperVenvPath;
import com.github.gtache.autosubtitle.process.ProcessRunner;
-import com.github.gtache.autosubtitle.subtitle.converter.SubtitleConverterProvider;
+import com.github.gtache.autosubtitle.subtitle.converter.json.whisper.base.JSONSubtitleConverter;
import com.github.gtache.autosubtitle.subtitle.extractor.ExtractOptions;
import com.github.gtache.autosubtitle.subtitle.extractor.SubtitleExtractor;
import com.github.gtache.autosubtitle.subtitle.extractor.whisper.AbstractWhisperSubtitleExtractor;
@@ -24,9 +24,9 @@ public class WhisperSubtitleExtractor extends AbstractWhisperSubtitleExtractor {
@Inject
- WhisperSubtitleExtractor(@WhisperVenvPath final Path venvPath, final SubtitleConverterProvider converterProvider,
+ WhisperSubtitleExtractor(@WhisperVenvPath final Path venvPath, final JSONSubtitleConverter converter,
final ProcessRunner processRunner, final OS os) {
- super(venvPath, converterProvider, processRunner, os);
+ super(venvPath, converter, processRunner, os);
}
@Override
diff --git a/whisper/base/src/main/java/module-info.java b/whisper/base/src/main/java/module-info.java
index 8e9dab7..77c7a4a 100644
--- a/whisper/base/src/main/java/module-info.java
+++ b/whisper/base/src/main/java/module-info.java
@@ -3,13 +3,13 @@
*/
module com.github.gtache.autosubtitle.whisper.base {
requires transitive com.github.gtache.autosubtitle.whisper.common;
- requires com.fasterxml.jackson.databind;
- requires com.github.gtache.autosubtitle.core;
requires org.apache.logging.log4j;
exports com.github.gtache.autosubtitle.setup.whisper.base;
+ exports com.github.gtache.autosubtitle.subtitle.converter.json.whisper.base;
exports com.github.gtache.autosubtitle.subtitle.extractor.whisper.base;
exports com.github.gtache.autosubtitle.whisper.base;
+
exports com.github.gtache.autosubtitle.modules.setup.whisper.base;
exports com.github.gtache.autosubtitle.modules.subtitle.extractor.whisper.base;
exports com.github.gtache.autosubtitle.modules.whisper.base;
diff --git a/whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/WhisperCommonSetupModule.java b/whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/WhisperCommonSetupModule.java
deleted file mode 100644
index f4498e0..0000000
--- a/whisper/common/src/main/java/com/github/gtache/autosubtitle/modules/setup/whisper/WhisperCommonSetupModule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.github.gtache.autosubtitle.modules.setup.whisper;
-
-import com.github.gtache.autosubtitle.impl.OS;
-import com.github.gtache.autosubtitle.modules.setup.conda.CondaSetupModule;
-import com.github.gtache.autosubtitle.setup.whisper.WhisperSetupConfiguration;
-import dagger.Module;
-import dagger.Provides;
-
-import java.nio.file.Path;
-
-@Module(includes = CondaSetupModule.class)
-public final class WhisperCommonSetupModule {
-
- private WhisperCommonSetupModule() {
-
- }
-
- @Provides
- static WhisperSetupConfiguration providesWhisperSetupConfiguration(@WhisperBundledRoot final Path root,
- @WhisperVenvPath final Path venvPath,
- @PythonVersion final String pythonVersion,
- final OS os) {
- return new WhisperSetupConfiguration(root, venvPath, pythonVersion, os);
- }
-}
diff --git a/whisper/common/src/main/java/com/github/gtache/autosubtitle/setup/whisper/AbstractWhisperSetupManager.java b/whisper/common/src/main/java/com/github/gtache/autosubtitle/setup/whisper/AbstractWhisperSetupManager.java
index aa1d57d..f3c93d3 100644
--- a/whisper/common/src/main/java/com/github/gtache/autosubtitle/setup/whisper/AbstractWhisperSetupManager.java
+++ b/whisper/common/src/main/java/com/github/gtache/autosubtitle/setup/whisper/AbstractWhisperSetupManager.java
@@ -1,5 +1,6 @@
package com.github.gtache.autosubtitle.setup.whisper;
+import com.github.gtache.autosubtitle.ToolType;
import com.github.gtache.autosubtitle.impl.OS;
import com.github.gtache.autosubtitle.process.ProcessRunner;
import com.github.gtache.autosubtitle.setup.SetupAction;
@@ -35,6 +36,11 @@ public abstract class AbstractWhisperSetupManager extends AbstractSetupManager {
this.configuration = requireNonNull(configuration);
}
+ @Override
+ public ToolType type() {
+ return ToolType.SUBTITLE_EXTRACTOR;
+ }
+
@Override
protected SetupStatus getStatus() throws SetupException {
if (isWhisperInstalled()) {
diff --git a/whisper/common/src/main/java/com/github/gtache/autosubtitle/subtitle/extractor/whisper/AbstractWhisperSubtitleExtractor.java b/whisper/common/src/main/java/com/github/gtache/autosubtitle/subtitle/extractor/whisper/AbstractWhisperSubtitleExtractor.java
index eed44bc..8e98cff 100644
--- a/whisper/common/src/main/java/com/github/gtache/autosubtitle/subtitle/extractor/whisper/AbstractWhisperSubtitleExtractor.java
+++ b/whisper/common/src/main/java/com/github/gtache/autosubtitle/subtitle/extractor/whisper/AbstractWhisperSubtitleExtractor.java
@@ -5,17 +5,16 @@ import com.github.gtache.autosubtitle.File;
import com.github.gtache.autosubtitle.Video;
import com.github.gtache.autosubtitle.impl.OS;
import com.github.gtache.autosubtitle.process.ProcessRunner;
-import com.github.gtache.autosubtitle.subtitle.Subtitle;
import com.github.gtache.autosubtitle.subtitle.SubtitleCollection;
import com.github.gtache.autosubtitle.subtitle.converter.ParseException;
import com.github.gtache.autosubtitle.subtitle.converter.SubtitleConverter;
-import com.github.gtache.autosubtitle.subtitle.converter.SubtitleConverterProvider;
import com.github.gtache.autosubtitle.subtitle.extractor.ExtractEvent;
import com.github.gtache.autosubtitle.subtitle.extractor.ExtractException;
import com.github.gtache.autosubtitle.subtitle.extractor.ExtractOptions;
import com.github.gtache.autosubtitle.subtitle.extractor.SubtitleExtractor;
import com.github.gtache.autosubtitle.subtitle.extractor.SubtitleExtractorListener;
import com.github.gtache.autosubtitle.subtitle.extractor.impl.ExtractEventImpl;
+import com.github.gtache.autosubtitle.subtitle.impl.SubtitleImpl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -34,7 +33,7 @@ import static java.util.Objects.requireNonNull;
/**
* Base implementation of {@link SubtitleExtractor} for Whisper
*/
-public abstract class AbstractWhisperSubtitleExtractor implements SubtitleExtractor {
+public abstract class AbstractWhisperSubtitleExtractor implements SubtitleExtractor {
private static final Logger logger = LogManager.getLogger(AbstractWhisperSubtitleExtractor.class);
@@ -44,14 +43,14 @@ public abstract class AbstractWhisperSubtitleExtractor implements SubtitleExtrac
private static final Pattern TQDM_PROGRESS_PATTERN = Pattern.compile("^(?