mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-26 13:12:39 +01:00
commit
77ce703016
@ -34,21 +34,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return time.ToHHMMSSFF();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string s)
|
||||
{
|
||||
var parts = s.Split(new[] { ':', ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
int milliseconds = (int)Math.Round(((TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate) * int.Parse(frames)));
|
||||
if (milliseconds > 999)
|
||||
milliseconds = 999;
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), milliseconds);
|
||||
}
|
||||
|
||||
public override string ToText(Subtitle subtitle, string title)
|
||||
{
|
||||
//<TitlerData>
|
||||
@ -164,6 +149,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return;
|
||||
}
|
||||
|
||||
char[] splitChars = { ':', ';' };
|
||||
foreach (XmlNode node in xml.DocumentElement.SelectNodes("Data"))
|
||||
{
|
||||
try
|
||||
@ -173,7 +159,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
string text = node.Attributes.GetNamedItem("Title").InnerText.Trim();
|
||||
string start = node.Attributes.GetNamedItem("StartTimecode").InnerText;
|
||||
string end = node.Attributes.GetNamedItem("EndTimecode").InnerText;
|
||||
subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text));
|
||||
subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCode(start, splitChars), DecodeTimeCode(end, splitChars), text));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -250,10 +250,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
var p = new Paragraph();
|
||||
const string expectedChars = @"""'0123456789";
|
||||
while (syncStartPos >= 0)
|
||||
{
|
||||
string millisecAsString = string.Empty;
|
||||
while (index < allInput.Length && @"""'0123456789".Contains(allInput[index]))
|
||||
while (index < allInput.Length && expectedChars.Contains(allInput[index]))
|
||||
{
|
||||
if (allInput[index] != '"' && allInput[index] != '\'')
|
||||
millisecAsString += allInput[index];
|
||||
|
@ -77,6 +77,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
subtitle.Paragraphs.Clear();
|
||||
char[] splitChar = { ':' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (line.IndexOf(':') == 5 && RegexTimeCodes.IsMatch(line))
|
||||
@ -87,8 +88,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
string start = line.Substring(7, 11);
|
||||
string end = line.Substring(19, 11);
|
||||
|
||||
string[] startParts = start.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] endParts = end.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] startParts = start.Split(splitChar);
|
||||
string[] endParts = end.Split(splitChar);
|
||||
if (startParts.Length == 4 && endParts.Length == 4)
|
||||
{
|
||||
p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), string.Empty);
|
||||
|
Loading…
Reference in New Issue
Block a user