SRT works ; adds support for export/import ass

This commit is contained in:
Guillaume Tâche
2024-08-24 20:52:01 +02:00
parent d14e32bfd0
commit 728b563d8b
37 changed files with 552 additions and 145 deletions

View File

@@ -0,0 +1,22 @@
package com.github.gtache.autosubtitle.archive;
import java.util.Collection;
/**
* Provider of {@link Archiver}s
*/
public interface ArchiverProvider {
/**
* @return the list of all available archivers
*/
Collection<Archiver> allArchivers();
/**
* Returns the archiver for the given extension
*
* @param extension The extension
* @return The archiver (or null if not found)
*/
Archiver getArchiver(String extension);
}

View File

@@ -1,6 +1,7 @@
package com.github.gtache.autosubtitle.subtitle;
import com.github.gtache.autosubtitle.Language;
import com.github.gtache.autosubtitle.VideoInfo;
import com.github.gtache.autosubtitle.subtitle.converter.ParseException;
import java.io.IOException;
@@ -28,20 +29,22 @@ public interface SubtitleImporterExporter<T extends Subtitle> {
* Exports multiple collections to a file
*
* @param collections The subtitle collections
* @param videoInfo The video info (e.g. ASS format uses it)
* @param file The path to the file
* @throws IOException If an error occurred
*/
void exportSubtitles(final Collection<? extends SubtitleCollection<?>> collections, final Path file) throws IOException;
void exportSubtitles(final Collection<? extends SubtitleCollection<?>> collections, final VideoInfo videoInfo, final Path file) throws IOException;
/**
* Exports a single collection to a file
*
* @param collection The subtitle collection
* @param videoInfo The video info (e.g. ASS format uses it)
* @param file The path to the file
* @throws IOException If an error occurred
*/
default void exportSubtitles(final SubtitleCollection<?> collection, final Path file) throws IOException {
exportSubtitles(List.of(collection), file);
default void exportSubtitles(final SubtitleCollection<?> collection, final VideoInfo videoInfo, final Path file) throws IOException {
exportSubtitles(List.of(collection), videoInfo, file);
}
/**

View File

@@ -1,5 +1,6 @@
package com.github.gtache.autosubtitle.subtitle.converter;
import com.github.gtache.autosubtitle.VideoInfo;
import com.github.gtache.autosubtitle.subtitle.Subtitle;
import com.github.gtache.autosubtitle.subtitle.SubtitleCollection;
@@ -16,9 +17,10 @@ public interface SubtitleConverter<T extends Subtitle> {
* Converts the subtitle collection
*
* @param collection The collection
* @param videoInfo The video info (e.g. ASS format uses it)
* @return The converted subtitles as the content of a file
*/
String format(final SubtitleCollection<?> collection);
String format(final SubtitleCollection<?> collection, final VideoInfo videoInfo);
/**
* Parses a subtitle collection

View File

@@ -0,0 +1,22 @@
package com.github.gtache.autosubtitle.subtitle.converter;
import java.util.Collection;
/**
* Provider of {@link SubtitleConverter}s
*/
public interface SubtitleConverterProvider {
/**
* @return the list of all available converters
*/
Collection<SubtitleConverter<?>> allConverters();
/**
* Returns the converter for the given format
*
* @param format The format
* @return The converter (or null if not found)
*/
SubtitleConverter<?> getConverter(final String format);
}

View File

@@ -8,7 +8,7 @@ import com.github.gtache.autosubtitle.subtitle.SubtitleCollection;
* Translates texts and subtitles
*/
public interface Translator<T extends Subtitle> {
/**
* Guesses the language of the given text
*