mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Fix for .ismt loading
This commit is contained in:
parent
a8e5eb8596
commit
996a84df64
@ -24,10 +24,16 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var fine = 0;
|
||||
var errors = 0;
|
||||
var sb = new StringBuilder();
|
||||
foreach (var line in lines)
|
||||
for (var index = 0; index < lines.Count; index++)
|
||||
{
|
||||
var line = lines[index];
|
||||
if (index == 0 && line.StartsWith("<tt xmlns"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sb.Append(line);
|
||||
if (line.IndexOf(':') > 0 &&
|
||||
if (line.IndexOf(':') > 0 &&
|
||||
(CsvLine.IsMatch(line) ||
|
||||
CsvLineNoQuotes.IsMatch(line) ||
|
||||
CsvLineAllQuotes.IsMatch(line) ||
|
||||
|
@ -8,6 +8,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle65 : SubtitleFormat
|
||||
{
|
||||
|
||||
private readonly Regex _regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d,\d\d:\d\d:\d\d$", RegexOptions.Compiled);
|
||||
|
||||
private enum ExpectingLine
|
||||
{
|
||||
TimeCodes,
|
||||
@ -57,8 +60,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
var regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d,\d\d:\d\d:\d\d$", RegexOptions.Compiled);
|
||||
|
||||
var paragraph = new Paragraph();
|
||||
ExpectingLine expecting = ExpectingLine.TimeCodes;
|
||||
_errorCount = 0;
|
||||
@ -66,7 +67,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Paragraphs.Clear();
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (line.Length == 17 && regexTimeCodes.IsMatch(line))
|
||||
if (line.Length == 17 && _regexTimeCodes.IsMatch(line))
|
||||
{
|
||||
string[] parts = line.Split(new[] { ':', ',', '.', ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 6)
|
||||
|
@ -11,6 +11,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
/// </summary>
|
||||
public class UnknownSubtitle7 : SubtitleFormat
|
||||
{
|
||||
private readonly Regex _regexTimeCode = new Regex(@"^\d\d:\d\d:\d\d:\d\d ", RegexOptions.Compiled);
|
||||
private readonly Regex _regexTimeCodeEnd = new Regex(@"^\d\d:\d\d:\d\d:\d\d\t$", RegexOptions.Compiled);
|
||||
|
||||
private enum ExpectingLine
|
||||
{
|
||||
TimeStart,
|
||||
@ -42,9 +45,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
var regexTimeCode = new Regex(@"^\d\d:\d\d:\d\d:\d\d ", RegexOptions.Compiled);
|
||||
var regexTimeCodeEnd = new Regex(@"^\d\d:\d\d:\d\d:\d\d\t$", RegexOptions.Compiled);
|
||||
|
||||
var paragraph = new Paragraph();
|
||||
var expecting = ExpectingLine.TimeStart;
|
||||
_errorCount = 0;
|
||||
@ -54,7 +54,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
foreach (string line in lines)
|
||||
{
|
||||
count++;
|
||||
if (regexTimeCode.IsMatch(line))
|
||||
if (_regexTimeCode.IsMatch(line))
|
||||
{
|
||||
string[] parts = line.Substring(0, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 4)
|
||||
@ -81,7 +81,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (regexTimeCodeEnd.IsMatch(line) || (count == lines.Count && regexTimeCodeEnd.IsMatch(line + "\t")))
|
||||
else if (_regexTimeCodeEnd.IsMatch(line) || (count == lines.Count && _regexTimeCodeEnd.IsMatch(line + "\t")))
|
||||
{
|
||||
string[] parts = line.Substring(0, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 4)
|
||||
|
Loading…
Reference in New Issue
Block a user