Minor fix for subtitle format not beeing too 'greedy'

This commit is contained in:
niksedk 2014-07-01 20:09:04 +02:00
parent 65f8bce6cc
commit dc050bc837
5 changed files with 24 additions and 2 deletions

View File

@ -114,6 +114,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
expectStartTime = true;
}
else
{
_errorCount++;
}
}
if (p != null && p.StartTime.TotalMilliseconds > 0)
subtitle.Paragraphs.Add(p);

View File

@ -23,7 +23,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
//«Steppe»
//Bogdan Voloshin, Yaroslavl
static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d.\d\d\d$", RegexOptions.Compiled);
static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d.\d{1,3}$", RegexOptions.Compiled);
public override string Extension
{
@ -117,6 +117,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
int startMinutes = int.Parse(parts[1]);
int startSeconds = int.Parse(parts[2]);
int startMilliseconds = int.Parse(parts[3]);
if (parts[3].Length == 2)
_errorCount++;
paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds);
return true;
}

View File

@ -75,6 +75,12 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
p.Text = line;
else
p.Text = p.Text + Environment.NewLine + line;
if (p.Text.Length > 800)
{
_errorCount++;
return;
}
}
}
foreach (Paragraph p2 in subtitle.Paragraphs)

View File

@ -68,7 +68,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
}
else
{
_errorCount++;
_errorCount+=2;
}
}
foreach (Paragraph p2 in subtitle.Paragraphs)

View File

@ -187,6 +187,14 @@ namespace Nikse.SubtitleEdit.Logic
return false;
}
public static bool IsLong(string s)
{
long i;
if (long.TryParse(s, out i))
return true;
return false;
}
public static SubtitleFormat GetSubtitleFormatByFriendlyName(string friendlyName)
{
foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats)