* make subtitle parser less verbose

This commit is contained in:
Reinhard Pointner 2011-11-21 12:01:05 +00:00
parent 99a61f53ce
commit 9657bc904d
3 changed files with 8 additions and 1 deletions

View File

@ -48,6 +48,9 @@ public class MicroDVDReader extends SubtitleReader {
int endFrame = Integer.parseInt(properties.get(1));
String text = line.substring(from).trim();
// cancel format markers
text = text.replaceAll("\\{[^\\}]*\\}", "");
if (startFrame == 1 && endFrame == 1) {
// override fps
fps = Double.parseDouble(text);

View File

@ -6,6 +6,7 @@ import static java.util.regex.Pattern.*;
import static net.sourceforge.tuned.StringUtilities.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.InputMismatchException;
import java.util.regex.Pattern;
@ -39,6 +40,9 @@ public class SubViewerReader extends SubtitleReader {
String[] lines = newline.split(scanner.nextLine());
return new SubtitleElement(t1, t2, join(lines, "\n"));
} catch (ParseException e) {
// can't parse interval, ignore line
return null;
} catch (InputMismatchException e) {
// can't parse interval, ignore line
return null;

View File

@ -33,7 +33,7 @@ public abstract class SubtitleReader implements Iterator<SubtitleElement>, Close
current = readNext();
} catch (Exception e) {
// log and ignore
Logger.getLogger(getClass().getName()).log(Level.WARNING, e.toString(), e);
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal input: " + e.getMessage());
}
}