* make subtitle parser less verbose
This commit is contained in:
parent
99a61f53ce
commit
9657bc904d
|
@ -48,6 +48,9 @@ public class MicroDVDReader extends SubtitleReader {
|
||||||
int endFrame = Integer.parseInt(properties.get(1));
|
int endFrame = Integer.parseInt(properties.get(1));
|
||||||
String text = line.substring(from).trim();
|
String text = line.substring(from).trim();
|
||||||
|
|
||||||
|
// cancel format markers
|
||||||
|
text = text.replaceAll("\\{[^\\}]*\\}", "");
|
||||||
|
|
||||||
if (startFrame == 1 && endFrame == 1) {
|
if (startFrame == 1 && endFrame == 1) {
|
||||||
// override fps
|
// override fps
|
||||||
fps = Double.parseDouble(text);
|
fps = Double.parseDouble(text);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import static java.util.regex.Pattern.*;
|
||||||
import static net.sourceforge.tuned.StringUtilities.*;
|
import static net.sourceforge.tuned.StringUtilities.*;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.InputMismatchException;
|
import java.util.InputMismatchException;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -39,6 +40,9 @@ public class SubViewerReader extends SubtitleReader {
|
||||||
String[] lines = newline.split(scanner.nextLine());
|
String[] lines = newline.split(scanner.nextLine());
|
||||||
|
|
||||||
return new SubtitleElement(t1, t2, join(lines, "\n"));
|
return new SubtitleElement(t1, t2, join(lines, "\n"));
|
||||||
|
} catch (ParseException e) {
|
||||||
|
// can't parse interval, ignore line
|
||||||
|
return null;
|
||||||
} catch (InputMismatchException e) {
|
} catch (InputMismatchException e) {
|
||||||
// can't parse interval, ignore line
|
// can't parse interval, ignore line
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public abstract class SubtitleReader implements Iterator<SubtitleElement>, Close
|
||||||
current = readNext();
|
current = readNext();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// log and ignore
|
// log and ignore
|
||||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, e.toString(), e);
|
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal input: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue