// 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 DateFormat timeFormat = new SubtitleTimeFormat();
|
||||||
private final Pattern newline = Pattern.compile(Pattern.quote("\\n"), Pattern.CASE_INSENSITIVE);
|
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 String[] format;
|
||||||
private int formatIndexStart;
|
private int formatIndexStart;
|
||||||
|
@ -81,12 +82,16 @@ public class SubStationAlphaReader extends SubtitleReader {
|
||||||
long end = timeFormat.parse(values[formatIndexEnd].trim()).getTime();
|
long end = timeFormat.parse(values[formatIndexEnd].trim()).getTime();
|
||||||
String text = values[formatIndexText].trim();
|
String text = values[formatIndexText].trim();
|
||||||
|
|
||||||
|
// ignore drawing instructions
|
||||||
|
if (drawingTags.matcher(text).find())
|
||||||
|
return null;
|
||||||
|
|
||||||
return new SubtitleElement(start, end, resolve(text));
|
return new SubtitleElement(start, end, resolve(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String resolve(String text) {
|
protected String resolve(String text) {
|
||||||
// remove tags
|
// remove tags
|
||||||
text = tag.matcher(text).replaceAll("");
|
text = tags.matcher(text).replaceAll("");
|
||||||
|
|
||||||
// resolve line breaks
|
// resolve line breaks
|
||||||
return newline.matcher(text).replaceAll("\n");
|
return newline.matcher(text).replaceAll("\n");
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
|
|
||||||
package net.filebot.subtitle;
|
package net.filebot.subtitle;
|
||||||
|
|
||||||
|
|
||||||
import net.filebot.MediaTypes;
|
import net.filebot.MediaTypes;
|
||||||
import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
||||||
|
|
||||||
|
|
||||||
public enum SubtitleFormat {
|
public enum SubtitleFormat {
|
||||||
|
|
||||||
SubRip {
|
SubRip {
|
||||||
|
@ -42,9 +40,8 @@ public enum SubtitleFormat {
|
||||||
|
|
||||||
public abstract SubtitleReader newReader(Readable readable);
|
public abstract SubtitleReader newReader(Readable readable);
|
||||||
|
|
||||||
|
|
||||||
public ExtensionFileFilter getFilter() {
|
public ExtensionFileFilter getFilter() {
|
||||||
return MediaTypes.getDefaultFilter("subtitle/" + this.name());
|
return MediaTypes.getDefaultFilter("subtitle/" + name());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue