mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 04:33:04 +01:00
[subtitleformat] - remove generic functionality (decode-time-code)
This commit is contained in:
parent
212c2f8912
commit
a449720dc4
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)))
|
||||
|
@ -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)
|
||||
|
@ -96,7 +96,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
try
|
||||
{
|
||||
p.StartTime = DecodeTimeCodeFrames(parts);
|
||||
p.StartTime = DecodeTimeCodeFramesFourParts(parts);
|
||||
expectActor = true;
|
||||
expectStartTime = false;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user