Allows choosing and managing each tool
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user