1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00
This commit is contained in:
Reinhard Pointner 2016-04-30 22:43:30 +08:00
parent 416eb0095d
commit 06815469f6
2 changed files with 8 additions and 6 deletions

View File

@ -11,7 +11,8 @@ public class SubStationAlphaReader extends SubtitleReader {
private final DateFormat timeFormat = new SubtitleTimeFormat();
private final Pattern newline = Pattern.compile(Pattern.quote("\\n"), Pattern.CASE_INSENSITIVE);
private final Pattern tag = Pattern.compile("[{]\\\\[^}]+[}]");
private final Pattern tags = Pattern.compile("[{]\\\\[^}]+[}]");
private final Pattern drawingTags = Pattern.compile("\\\\[p][0-4]"); // ignore drawing commands (http://docs.aegisub.org/3.2/ASS_Tags/#drawing-commands)
private String[] format;
private int formatIndexStart;
@ -81,12 +82,16 @@ public class SubStationAlphaReader extends SubtitleReader {
long end = timeFormat.parse(values[formatIndexEnd].trim()).getTime();
String text = values[formatIndexText].trim();
// ignore drawing instructions
if (drawingTags.matcher(text).find())
return null;
return new SubtitleElement(start, end, resolve(text));
}
protected String resolve(String text) {
// remove tags
text = tag.matcher(text).replaceAll("");
text = tags.matcher(text).replaceAll("");
// resolve line breaks
return newline.matcher(text).replaceAll("\n");

View File

@ -1,11 +1,9 @@
package net.filebot.subtitle;
import net.filebot.MediaTypes;
import net.filebot.util.FileUtilities.ExtensionFileFilter;
public enum SubtitleFormat {
SubRip {
@ -42,9 +40,8 @@ public enum SubtitleFormat {
public abstract SubtitleReader newReader(Readable readable);
public ExtensionFileFilter getFilter() {
return MediaTypes.getDefaultFilter("subtitle/" + this.name());
return MediaTypes.getDefaultFilter("subtitle/" + name());
}
}