Extraction works

This commit is contained in:
Guillaume Tâche
2024-08-04 21:55:30 +02:00
parent 8002fc6719
commit 5efdaa6f63
121 changed files with 3360 additions and 400 deletions

41
cli/pom.xml Normal file
View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.gtache.autosubtitle</groupId>
<artifactId>autosubtitle</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>autosubtitle-cli</artifactId>
<dependencies>
<dependency>
<groupId>com.github.gtache.autosubtitle</groupId>
<artifactId>autosubtitle-deepl</artifactId>
</dependency>
<dependency>
<groupId>com.github.gtache.autosubtitle</groupId>
<artifactId>autosubtitle-ffmpeg</artifactId>
</dependency>
<dependency>
<groupId>com.github.gtache.autosubtitle</groupId>
<artifactId>autosubtitle-whisper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,61 @@
package com.github.gtache.autosubtitle.cli;
import com.github.gtache.autosubtitle.modules.cli.DaggerCliComponent;
import picocli.CommandLine;
import java.util.Set;
@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")
private boolean burn;
@CommandLine.Option(names = {"-e", "--extractor"}, description = "The subtitle extractor to use [whisper]", defaultValue = "whisper")
private String extractor;
@CommandLine.Option(names = {"-i", "--input"}, description = "The input file", required = true)
private String input;
@CommandLine.Option(names = {"-l", "--loader"}, description = "The video loader to use [ffprobe]", defaultValue = "ffprobe")
private String loader;
@CommandLine.Option(names = {"-o", "--output"}, description = "The output file", required = true)
private String output;
@CommandLine.Option(names = {"-s", "--subtitle-converter"}, description = "The subtitle converter to use [srt|ass]", defaultValue = "srt")
private String subtitleConverter;
@CommandLine.Option(names = {"-c", "--video-converter"}, description = "The video converter to use [ffmpeg]", defaultValue = "ffmpeg")
private String videoConverter;
@CommandLine.Option(names = {"--translations"}, description = "The list of translations to create. Ignored if burn is specified", split = ",", arity = "0..*")
private Set<String> translations;
@CommandLine.Option(names = {"-t", "--translator"}, description = "The translator to use [deepl]. Ignored if burn is specified", defaultValue = "deepl")
private String translator;
@CommandLine.Option(names = {"-w", "--wait"}, description = "Allow modifying subtitle files before creating output", defaultValue = "false")
private boolean wait;
private Cli() {
}
@Override
public void run() {
if (!extractor.equals("whisper")) {
throw new IllegalArgumentException("Unknown extractor : " + extractor);
}
if (!loader.equals("ffprobe")) {
throw new IllegalArgumentException("Unknown loader : " + loader);
}
if (!subtitleConverter.equals("srt")) {
throw new IllegalArgumentException("Unknown subtitle converter : " + subtitleConverter);
}
if (!videoConverter.equals("ffmpeg")) {
throw new IllegalArgumentException("Unknown video converter : " + videoConverter);
}
if (!translator.equals("deepl")) {
throw new IllegalArgumentException("Unknown translator : " + translator);
}
final var component = DaggerCliComponent.create();
}
public static void main(final String[] args) {
System.exit(new CommandLine(new Cli()).execute(args));
}
}

View File

@@ -0,0 +1,18 @@
package com.github.gtache.autosubtitle.modules.cli;
import com.github.gtache.autosubtitle.modules.deepl.DeepLModule;
import com.github.gtache.autosubtitle.modules.ffmpeg.FFmpegModule;
import com.github.gtache.autosubtitle.modules.impl.CoreModule;
import com.github.gtache.autosubtitle.modules.subtitles.impl.ConverterModule;
import com.github.gtache.autosubtitle.modules.whisper.WhisperModule;
import com.github.gtache.autosubtitle.subtitle.SubtitleConverter;
import dagger.Component;
import javax.inject.Singleton;
@Component(modules = {ConverterModule.class, CoreModule.class, DeepLModule.class, FFmpegModule.class, WhisperModule.class})
@Singleton
public interface CliComponent {
SubtitleConverter getSubtitleConverter();
}

View File

@@ -0,0 +1,9 @@
/**
* CLI module for autosubtitle
*/
module com.github.gtache.autosubtitle.cli {
requires com.github.gtache.autosubtitle.deepl;
requires com.github.gtache.autosubtitle.ffmpeg;
requires com.github.gtache.autosubtitle.whisper;
requires info.picocli;
}