mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 08:18:52 -05:00
// ignore drawing commands (http://docs.aegisub.org/3.2/ASS_Tags/#drawing-commands)
This commit is contained in:
parent
416eb0095d
commit
06815469f6
@ -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");
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user