Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Convert TTML into ASS #765

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/mediathek/tool/MVSubtitle.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

public class MVSubtitle {

private static final String SUFFIX_ASS = "ass";
private static final String SUFFIX_SRT = "srt";
private static final String SUFFIX_TTML = "ttml";
private static final String SUFFIX_VTT = "vtt";
Expand Down Expand Up @@ -126,12 +127,15 @@ private void convertSubtitle(@NotNull Path ttmlPath) {
var subtitleFileStr = GuiFunktionen.getFileNameWithoutExtension(ttmlPath.toAbsolutePath().toString());

try (TimedTextMarkupLanguageParser parser = new TimedTextMarkupLanguageParser()) {
if (!subtitleFileStr.endsWith('.' + SUFFIX_SRT) && !subtitleFileStr.endsWith("." + SUFFIX_VTT)) {
if (!subtitleFileStr.endsWith("." + SUFFIX_ASS) && !subtitleFileStr.endsWith('.' + SUFFIX_SRT) && !subtitleFileStr.endsWith("." + SUFFIX_VTT)) {
final Path ass = Paths.get(subtitleFileStr + "." + SUFFIX_ASS);
final Path srt = Paths.get(subtitleFileStr + "." + SUFFIX_SRT);
if (parser.parse(ttmlPath)) {
parser.toSrt(srt);
parser.toAss(ass);
} else if (parser.parseXmlFlash(ttmlPath)) {
parser.toSrt(srt);
parser.toAss(ass);
}
logger.info("Untertitel-Datei wurde konvertiert.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mediathek/tool/ttml/StyledString.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package mediathek.tool.ttml

internal data class StyledString( var text: String = "", var color: String = "")
internal data class StyledString( var text: String = "", var color: String = "", var backgroundColor: String = "" )
2 changes: 2 additions & 0 deletions src/main/java/mediathek/tool/ttml/Subtitle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ internal class Subtitle {
var end: Date? = null
@JvmField
val listOfStrings: List<StyledString> = ArrayList()
@JvmField
var region: String? = null
}
Loading