mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
parent
f343c0eba7
commit
cb88036f97
@ -164,13 +164,16 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var header = new StringBuilder();
|
||||
header.AppendLine("WEBVTT");
|
||||
header.AppendLine();
|
||||
|
||||
for (var index = 0; index < lines.Count; index++)
|
||||
{
|
||||
string line = lines[index];
|
||||
string next = string.Empty;
|
||||
var line = lines[index];
|
||||
var next = string.Empty;
|
||||
var isNextTimeCode = false;
|
||||
if (index < lines.Count - 1)
|
||||
{
|
||||
next = lines[index + 1];
|
||||
isNextTimeCode = next.Contains("-->");
|
||||
}
|
||||
|
||||
if (index == 0 && line.StartsWith("WEBVTT", StringComparison.Ordinal))
|
||||
@ -248,7 +251,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
s = "00:" + s.Replace("--> ", "--> 00:");
|
||||
}
|
||||
|
||||
if (index == 1 && s.StartsWith("X-TIMESTAMP-MAP=", StringComparison.OrdinalIgnoreCase) &&
|
||||
if (isNextTimeCode && Utilities.IsNumber(s) && p?.Text.Length > 0)
|
||||
{
|
||||
numbers++;
|
||||
}
|
||||
else if (index == 1 && s.StartsWith("X-TIMESTAMP-MAP=", StringComparison.OrdinalIgnoreCase) &&
|
||||
s.IndexOf("MPEGTS:", StringComparison.OrdinalIgnoreCase) > 0)
|
||||
{
|
||||
addSeconds = GetXTimeStampSeconds(s);
|
||||
@ -316,7 +323,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
|
||||
if (subtitle.Paragraphs.Count > 5 &&
|
||||
if (subtitle.Paragraphs.Count > 3 &&
|
||||
numbers >= subtitle.Paragraphs.Count - 1 &&
|
||||
lines[0] == "WEBVTT FILE")
|
||||
{
|
||||
|
@ -63,11 +63,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
bool hadEmptyLine = false;
|
||||
for (var index = 0; index < lines.Count; index++)
|
||||
{
|
||||
string line = lines[index];
|
||||
string next = string.Empty;
|
||||
var line = lines[index];
|
||||
var next = string.Empty;
|
||||
var isNextTimeCode = false;
|
||||
if (index < lines.Count - 1)
|
||||
{
|
||||
next = lines[index + 1];
|
||||
isNextTimeCode = next.Contains("-->");
|
||||
}
|
||||
|
||||
string s = line;
|
||||
@ -82,7 +84,12 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
s = "00:" + s.Replace("--> ", "--> 00:");
|
||||
}
|
||||
|
||||
if (isTimeCode && RegexTimeCodes.IsMatch(s))
|
||||
|
||||
if (isNextTimeCode && Utilities.IsNumber(s) && p?.Text.Length > 0)
|
||||
{
|
||||
// skip number
|
||||
}
|
||||
else if (isTimeCode && RegexTimeCodes.IsMatch(s))
|
||||
{
|
||||
if (p != null)
|
||||
{
|
||||
@ -164,6 +171,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
new WebVTT().RemoveNativeFormatting(subtitle, newFormat);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user