[subtitleformat] - remove generic functionality (decode-time-code)

This commit is contained in:
Ivandro Ismael 2016-02-06 22:19:59 +00:00
parent 212c2f8912
commit a449720dc4
47 changed files with 99 additions and 98 deletions

View File

@ -108,7 +108,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
text = HtmlUtil.FixInvalidItalicTags(text);
}
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
subtitle.Paragraphs.Add(p);
}
catch (Exception exception)

View File

@ -103,7 +103,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
text = HtmlUtil.FixInvalidItalicTags(text);
}
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
subtitle.Paragraphs.Add(p);
}
catch (Exception exception)

View File

@ -75,7 +75,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string text = line.Remove(0, RegexTimeCodes.Match(line).Length - 1).Trim();
if (!text.Contains(Environment.NewLine))
text = text.Replace("\r", Environment.NewLine);
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -80,7 +80,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (startParts.Length == 4 && endParts.Length == 4)
{
string text = line.Remove(0, RegexTimeCodes.Match(line).Length - 1).Trim();
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -78,7 +78,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (startParts.Length == 4 && endParts.Length == 4)
{
string text = line.Remove(0, RegexTimeCodes.Match(line).Length - 1).Trim();
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -102,7 +102,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
if (startParts.Length == 4 && endParts.Length == 4)
{
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), string.Empty);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -230,9 +230,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
paragraph.Text = DecodeText(sb);
}
var start = DecodeTimeCodeFrames(parts);
var start = DecodeTimeCodeFramesFourParts(parts);
parts = line.Substring(16, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
var end = DecodeTimeCodeFrames(parts);
var end = DecodeTimeCodeFramesFourParts(parts);
paragraph = new Paragraph { StartTime = start, EndTime = end };
subtitle.Paragraphs.Add(paragraph);
sb.Clear();

View File

@ -180,7 +180,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string timeCode = Encoding.ASCII.GetString(buffer, i + 1, 11);
if (timeCode != "00:00:00:00" && RegexTimeCodes.IsMatch(timeCode))
{
var p = new Paragraph { StartTime = DecodeTimeCodeFrames(timeCode.Split(':')) };
var p = new Paragraph { StartTime = DecodeTimeCodeFramesFourParts(timeCode.Split(':')) };
bool italic = buffer[i + 22] == 3; // 3=italic, 1=normal
int textStart = i + 25; // text starts 25 chars after time code
int textLength = 0;
@ -254,7 +254,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
try
{
string adjust = Encoding.GetEncoding(1252).GetString(buffer, 1354, 11); // 00:59:59:28
TimeCode tc = DecodeTimeCodeFrames(adjust.Split(':'));
TimeCode tc = DecodeTimeCodeFramesFourParts(adjust.Split(':'));
if (tc.TotalMilliseconds > 0)
subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-tc.TotalMilliseconds));
}

View File

@ -59,9 +59,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var start = DecodeTimeCodeFrames(parts);
var start = DecodeTimeCodeFramesFourParts(parts);
parts = line.Substring(12, 11).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var end = DecodeTimeCodeFrames(parts);
var end = DecodeTimeCodeFramesFourParts(parts);
paragraph = new Paragraph();
paragraph.StartTime = start;
paragraph.EndTime = end;

View File

@ -64,7 +64,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string text = temp[5];
try
{
p = new Paragraph(DecodeTimeCodeFrames(start.Split(':')), DecodeTimeCodeFrames(end.Split(':')), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(start.Split(':')), DecodeTimeCodeFramesFourParts(end.Split(':')), text);
subtitle.Paragraphs.Add(p);
}
catch (Exception exception)

View File

@ -76,7 +76,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
string text = line.Remove(0, RegexTimeCodes.Match(line).Length - 1).Trim();
text = text.Replace("//", Environment.NewLine);
var p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), text);
var p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -88,13 +88,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
string start = node.Attributes["timecode"].InnerText;
if (lastParagraph != null)
lastParagraph.EndTime = DecodeTimeCodeFrames(start.Split(':'));
lastParagraph.EndTime = DecodeTimeCodeFramesFourParts(start.Split(':'));
XmlNode text = node.SelectSingleNode("Text");
if (text != null)
{
string s = text.InnerText;
s = s.Replace("<br />", Environment.NewLine).Replace("<br/>", Environment.NewLine);
TimeCode startTime = DecodeTimeCodeFrames(start.Split(':'));
TimeCode startTime = DecodeTimeCodeFramesFourParts(start.Split(':'));
lastParagraph = new Paragraph(s, startTime.TotalMilliseconds, startTime.TotalMilliseconds + 3000);
subtitle.Paragraphs.Add(lastParagraph);
}

View File

@ -72,7 +72,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
if (startParts.Length == 4 && endParts.Length == 4)
{
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), string.Empty);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -82,7 +82,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
if (startParts.Length == 4 && endParts.Length == 4)
{
var p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), sb.ToString().Trim());
var p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), sb.ToString().Trim());
subtitle.Paragraphs.Add(p);
}
sb.Clear();

View File

@ -85,7 +85,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
if (expecting == ExpectingLine.TimeStart)
{
paragraph = new Paragraph();
@ -107,7 +107,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] parts = line.Substring(0, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 4)
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.EndTime = tc;
subtitle.Paragraphs.Add(paragraph);
if (paragraph.StartTime.TotalMilliseconds < 0.001)

View File

@ -911,7 +911,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
else if (_codePage == CodePageJapanese)
textBuffer = GetW16Bytes(text, alignment, EncodingJapanese);
else if (_codePage == CodePageThai)
textBuffer = encoding.GetBytes(text.Replace("ต", "€"));
textBuffer = encoding.GetBytes(text.Replace('ต', '€'));
else
textBuffer = encoding.GetBytes(text);

View File

@ -83,14 +83,14 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
if (expectStartTime)
{
p.StartTime = DecodeTimeCodeFrames(parts);
p.StartTime = DecodeTimeCodeFramesFourParts(parts);
expectStartTime = false;
}
else
{
if (p.EndTime.TotalMilliseconds < 0.01)
_errorCount++;
p.EndTime = DecodeTimeCodeFrames(parts);
p.EndTime = DecodeTimeCodeFramesFourParts(parts);
}
}
catch (Exception exception)

View File

@ -94,7 +94,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
int indexOfEndTime = line.IndexOf(']');
if (indexOfEndTime > 0 && indexOfEndTime + 1 < line.Length)
text = line.Substring(indexOfEndTime + 1);
p = new Paragraph(DecodeTimeCodeFrames(parts), DecodeTimeCodeFrames(parts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(parts), DecodeTimeCodeFramesFourParts(parts), text);
}
catch
{
@ -103,14 +103,14 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
else
{
p.EndTime = DecodeTimeCodeFrames(parts);
p.EndTime = DecodeTimeCodeFramesFourParts(parts);
subtitle.Paragraphs.Add(p);
string text = string.Empty;
int indexOfEndTime = line.IndexOf(']');
if (indexOfEndTime > 0 && indexOfEndTime + 1 < line.Length)
text = line.Substring(indexOfEndTime + 1);
p = new Paragraph(DecodeTimeCodeFrames(parts), DecodeTimeCodeFrames(parts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(parts), DecodeTimeCodeFramesFourParts(parts), text);
}
}
}

View File

@ -79,7 +79,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string text = line.Remove(0, RegexTimeCodes.Match(line).Length - 1).Trim();
if (!text.Contains(Environment.NewLine))
text = text.Replace("\t", Environment.NewLine);
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -159,8 +159,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
try
{
p = new Paragraph();
p.StartTime = DecodeTimeCodeFrames(startParts);
p.EndTime = DecodeTimeCodeFrames(endParts);
p.StartTime = DecodeTimeCodeFramesFourParts(startParts);
p.EndTime = DecodeTimeCodeFramesFourParts(endParts);
string text = sb.ToString().Trim();
bool positionTop = false;

View File

@ -160,8 +160,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
try
{
p = new Paragraph();
p.StartTime = DecodeTimeCodeFrames(startParts);
p.EndTime = DecodeTimeCodeFrames(endParts);
p.StartTime = DecodeTimeCodeFramesFourParts(startParts);
p.EndTime = DecodeTimeCodeFramesFourParts(endParts);
string text = sb.ToString().Trim();
bool positionTop = false;

View File

@ -77,7 +77,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string text = line.Remove(0, lastIndexOfTab + 1).Trim();
if (!text.Contains(Environment.NewLine))
text = text.Replace("\t", Environment.NewLine);
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -91,7 +91,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] endParts = end.Split(SplitCharColon);
if (startParts.Length == 4 && endParts.Length == 4)
{
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), string.Empty);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty);
}
}
else if (p != null && RegexText.IsMatch(line))

View File

@ -397,41 +397,39 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
protected static TimeCode DecodeTimeCodeFrames(string[] parts)
protected TimeCode DecodeTimeCodeFramesTwoParts(string[] parts)
{
if (parts == null)
return new TimeCode(0, 0, 0, 0);
int hour = 0;
int minutes = 0;
int seconds = 0;
int frames = 0;
if (parts.Length == 4)
{
hour = int.Parse(parts[0]);
minutes = int.Parse(parts[1]);
seconds = int.Parse(parts[2]);
frames = int.Parse(parts[3]);
}
else if (parts.Length == 3)
{
minutes = int.Parse(parts[0]);
seconds = int.Parse(parts[1]);
frames = int.Parse(parts[2]);
}
else if (parts.Length == 2)
{
seconds = int.Parse(parts[0]);
frames = int.Parse(parts[1]);
}
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
if (parts.Length != 2)
throw new InvalidOperationException();
// 00:00
return new TimeCode(0, 0, int.Parse(parts[0]), FramesToMillisecondsMax999(int.Parse(parts[1])));
}
protected static TimeCode DecodeTimeCodeFrames(string part, char[] splitChars)
protected TimeCode DecodeTimeCodeFramesThreeParts(string[] parts)
{
return DecodeTimeCodeFrames(part.Split(splitChars, StringSplitOptions.RemoveEmptyEntries));
if (parts == null)
return new TimeCode(0, 0, 0, 0);
if (parts.Length != 3)
throw new InvalidOperationException();
// 00:00:00
return new TimeCode(0, int.Parse(parts[0]), int.Parse(parts[1]), FramesToMillisecondsMax999(int.Parse(parts[2])));
}
protected TimeCode DecodeTimeCodeFramesFourParts(string[] parts)
{
if (parts == null)
return new TimeCode(0, 0, 0, 0);
if (parts.Length != 4)
throw new InvalidOperationException();
// 00:00:00:00
return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), FramesToMillisecondsMax999(int.Parse(parts[3])));
}
protected TimeCode DecodeTimeCodeFrames(string part, char[] splitChars)
{
return DecodeTimeCodeFramesFourParts(part.Split(splitChars, StringSplitOptions.RemoveEmptyEntries));
}
}

View File

@ -92,7 +92,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.StartTime = tc;
expecting = ExpectingLine.TimeEnd;
}
@ -110,7 +110,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.EndTime = tc;
expecting = ExpectingLine.Text;
}

View File

@ -99,7 +99,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
text = HtmlUtil.FixInvalidItalicTags(text);
}
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text);
subtitle.Paragraphs.Add(p);
}
catch (Exception exception)

View File

@ -95,7 +95,7 @@ ATTENTION : Pas plus de 40 caractères PAR LIGNE
string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
if (startParts.Length == 4 && endParts.Length == 4)
{
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), string.Empty);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -107,7 +107,7 @@ DIGITAL_CINEMA=YES
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.StartTime = tc;
expecting = ExpectingLine.TimeEnd;
}
@ -125,7 +125,7 @@ DIGITAL_CINEMA=YES
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.EndTime = tc;
expecting = ExpectingLine.Text;
}

View File

@ -97,7 +97,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.StartTime = tc;
expecting = ExpectingLine.TimeEnd;
}
@ -115,7 +115,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.EndTime = tc;
expecting = ExpectingLine.Text;
}

View File

@ -72,6 +72,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
_errorCount = 0;
subtitle.Paragraphs.Clear();
char[] splitChar = { '.' };
foreach (string line in lines)
{
if (line.EndsWith('.') && Utilities.IsInteger(line.TrimEnd('.')))
@ -88,7 +89,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesTwoParts(parts);
paragraph.StartTime = tc;
expecting = ExpectingLine.TimeEnd;
}
@ -101,12 +102,12 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
else if (paragraph != null && expecting == ExpectingLine.TimeEnd && RegexTimeCode.IsMatch(line))
{
string[] parts = line.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
string[] parts = line.Split(splitChar, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 2)
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesTwoParts(parts);
paragraph.EndTime = tc;
expecting = ExpectingLine.Text;
}

View File

@ -83,11 +83,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
// parts1/2 most have length of 2
if (parts1.Length + parts2.Length == 4)
{
p = new Paragraph(DecodeTimeCodeFrames(parts1), DecodeTimeCodeFrames(parts2), string.Empty);
p = new Paragraph(DecodeTimeCodeFramesTwoParts(parts1), DecodeTimeCodeFramesTwoParts(parts2), string.Empty);
}
else
{
p = new Paragraph(DecodeTimeCodeFrames(new[] { parts1[0], parts1[1] }), DecodeTimeCodeFrames(new[] { parts2[0], parts2[1] }), string.Empty);
p = new Paragraph(DecodeTimeCodeFramesTwoParts(parts1), DecodeTimeCodeFramesTwoParts(parts2), string.Empty);
}
}
}

View File

@ -100,7 +100,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
p = new Paragraph(DecodeTimeCodeFrames(startParts), new TimeCode(0, 0, 0, 0), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), new TimeCode(0, 0, 0, 0), text);
subtitle.Paragraphs.Add(p);
}
catch (Exception exception)

View File

@ -79,6 +79,7 @@ ST 0 EB 3.10
string[] arr = rtf.FromRtf().SplitToLines();
Paragraph p = null;
subtitle.Paragraphs.Clear();
char[] splitChar = { '.' };
foreach (string line in arr)
{
if (regexTimeCodes.IsMatch(line.Trim()))
@ -89,11 +90,11 @@ ST 0 EB 3.10
string start = temp[0];
string end = temp[1];
string[] startParts = start.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
string[] endParts = end.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
string[] startParts = start.Split(splitChar, StringSplitOptions.RemoveEmptyEntries);
string[] endParts = end.Split(splitChar, StringSplitOptions.RemoveEmptyEntries);
if (startParts.Length == 2 && endParts.Length == 2)
{
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), string.Empty); //00119.12
p = new Paragraph(DecodeTimeCodeFramesTwoParts(startParts), DecodeTimeCodeFramesTwoParts(endParts), string.Empty); //00119.12
subtitle.Paragraphs.Add(p);
}
}

View File

@ -68,7 +68,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (arr.Length == 4)
{
p = new Paragraph();
p.StartTime = DecodeTimeCodeFrames(arr);
p.StartTime = DecodeTimeCodeFramesFourParts(arr);
p.Text = s.Substring(0, s.IndexOf(timeCode, StringComparison.Ordinal)).Trim();
subtitle.Paragraphs.Add(p);
}

View File

@ -61,7 +61,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (arr.Length == 4)
{
var p = new Paragraph();
p.StartTime = DecodeTimeCodeFrames(arr);
p.StartTime = DecodeTimeCodeFramesFourParts(arr);
p.Text = s.Remove(0, 10).Trim();
subtitle.Paragraphs.Add(p);
}

View File

@ -98,7 +98,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.StartTime = tc;
expecting = ExpectingLine.TimeEnd;
}
@ -116,7 +116,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.EndTime = tc;
expecting = ExpectingLine.Text;
}

View File

@ -71,7 +71,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] arr = s.Substring(0, 11).Split(':');
if (arr.Length == 4)
{
p.StartTime = DecodeTimeCodeFrames(arr);
p.StartTime = DecodeTimeCodeFramesFourParts(arr);
string text = s.Substring(11).Trim();
p.Text = text;
if (text.Length > 1 && Utilities.IsInteger(text.Substring(0, 2)))

View File

@ -80,7 +80,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
if (expectStartTime)
{
p.StartTime = DecodeTimeCodeFrames(parts);
p.StartTime = DecodeTimeCodeFramesFourParts(parts);
expectStartTime = false;
}
else
@ -90,7 +90,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!string.IsNullOrEmpty(p.Text))
_errorCount++;
p.EndTime = DecodeTimeCodeFrames(parts);
p.EndTime = DecodeTimeCodeFramesFourParts(parts);
}
}
catch (Exception exception)

View File

@ -96,7 +96,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
p.StartTime = DecodeTimeCodeFrames(parts);
p.StartTime = DecodeTimeCodeFramesFourParts(parts);
expectActor = true;
expectStartTime = false;
}

View File

@ -68,6 +68,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
bool expectStartTime = true;
var p = new Paragraph();
subtitle.Paragraphs.Clear();
char[] splitChars = { ':', '.' };
foreach (string line in lines)
{
string s = line.Trim();
@ -85,7 +86,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
p = new Paragraph();
string[] parts = s.Split(new[] { ':', '.' }, StringSplitOptions.RemoveEmptyEntries);
string[] parts = s.Split(splitChars, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 4)
{
try

View File

@ -93,7 +93,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.StartTime = tc;
expecting = ExpectingLine.TimeEnd;
}
@ -111,7 +111,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.EndTime = tc;
expecting = ExpectingLine.Text;
}

View File

@ -78,7 +78,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
if (expecting == ExpectingLine.TimeStart)
{
paragraph = new Paragraph();
@ -103,7 +103,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] parts = line.Substring(0, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 4)
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.EndTime = tc;
subtitle.Paragraphs.Add(paragraph);
paragraph = new Paragraph();

View File

@ -131,7 +131,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.StartTime = tc;
expecting = ExpectingLine.TimeEnd;
}
@ -149,7 +149,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var tc = DecodeTimeCodeFrames(parts);
var tc = DecodeTimeCodeFramesFourParts(parts);
paragraph.EndTime = tc;
expecting = ExpectingLine.Text;
}

View File

@ -86,7 +86,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), string.Empty);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty);
subtitle.Paragraphs.Add(p);
}
catch (Exception exception)

View File

@ -65,7 +65,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
if (startParts.Length == 4 && endParts.Length == 4)
{
p = new Paragraph(DecodeTimeCodeFrames(startParts), DecodeTimeCodeFrames(endParts), string.Empty);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty);
subtitle.Paragraphs.Add(p);
}
}

View File

@ -75,7 +75,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] startTimeParts = { startTime.Substring(0, 2), startTime.Substring(2, 2), startTime.Substring(4, 2), startTime.Substring(6, 2) };
string[] endTimeParts = { startTime.Substring(0, 2), startTime.Substring(2, 2), startTime.Substring(4, 2), startTime.Substring(6, 2) };
paragraph = new Paragraph { StartTime = DecodeTimeCodeFrames(startTimeParts), EndTime = DecodeTimeCodeFrames(endTimeParts) };
paragraph = new Paragraph { StartTime = DecodeTimeCodeFramesFourParts(startTimeParts), EndTime = DecodeTimeCodeFramesFourParts(endTimeParts) };
subtitle.Paragraphs.Add(paragraph);
text = new StringBuilder();
s = s.Remove(0, 18 + lineParts[0].Length).Trim();

View File

@ -84,7 +84,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string[] startTimeParts = { starTime.Substring(0, 2), starTime.Substring(2, 2), starTime.Substring(4, 2), starTime.Substring(6, 2) };
string[] endTimeParts = { starTime.Substring(0, 2), starTime.Substring(2, 2), starTime.Substring(4, 2), starTime.Substring(6, 2) };
p = new Paragraph(DecodeTimeCodeFrames(startTimeParts), DecodeTimeCodeFrames(endTimeParts), text);
p = new Paragraph(DecodeTimeCodeFramesFourParts(startTimeParts), DecodeTimeCodeFramesFourParts(endTimeParts), text);
subtitle.Paragraphs.Add(p);
}
catch (Exception exception)