Minor performance fixes (mostly subtitle loading)

This commit is contained in:
niksedk 2014-09-12 23:53:10 +02:00
parent 2315a0f9cf
commit 19b1822e7d
11 changed files with 169 additions and 136 deletions

View File

@ -102,7 +102,7 @@ Email: mailto:nikse.dk@gmail.com</AboutText1>
<SourceVideoFile>Source video file:</SourceVideoFile>
<GenerateWaveFormData>Generate wave form data</GenerateWaveFormData>
<PleaseWait>This may take a few minutes - please wait</PleaseWait>
<VlcMediaPlayerNotFoundTitle>VLC Media Player not found</VlcMediaPlayerNotFoundTitle>
<VlcMediaPlayerNotFoundTitle>VLC media player not found</VlcMediaPlayerNotFoundTitle>
<VlcMediaPlayerNotFound>Subtitle Edit needs VLC media player 1.1.x or newer for extracting audio data.</VlcMediaPlayerNotFound>
<GoToVlcMediaPlayerHomePage>Do you want to go to the VLC media player home page?</GoToVlcMediaPlayerHomePage>
<GeneratingPeakFile>Generating peak file...</GeneratingPeakFile>
@ -1497,8 +1497,8 @@ can edit in same subtitle file (collaboration)</Information>
<ManagedDirectXDescription>Microsoft.DirectX.AudioVideoPlayback - .NET Managed code from DirectX</ManagedDirectXDescription>
<MPlayer>MPlayer</MPlayer>
<MPlayerDescription>MPlayer2/Mplayer</MPlayerDescription>
<VlcMediaPlayer>VLC Media Player</VlcMediaPlayer>
<VlcMediaPlayerDescription>libvlc.dll from VLC Media Player 1.1.0 or newer</VlcMediaPlayerDescription>
<VlcMediaPlayer>VLC media player</VlcMediaPlayer>
<VlcMediaPlayerDescription>libvlc.dll from VLC media player 1.1.0 or newer</VlcMediaPlayerDescription>
<VlcBrowseToLabel>VLC path (only needed if you're using the portable version of VLC)</VlcBrowseToLabel>
<ShowStopButton>Show stop button</ShowStopButton>
<ShowMuteButton>Show mute button</ShowMuteButton>

View File

@ -185,7 +185,7 @@ namespace Nikse.SubtitleEdit.Forms
}
else
{
int index = newText.ToLower().IndexOf(findWhat.ToLower());
int index = newText.IndexOf(findWhat, StringComparison.OrdinalIgnoreCase);
while (index >= 0)
{
if (index < newText.Length)
@ -194,7 +194,7 @@ namespace Nikse.SubtitleEdit.Forms
newText = newText.Substring(0, index) + replaceWith;
hit = true;
index = newText.ToLower().IndexOf(findWhat.ToLower(), index + replaceWith.Length);
index = newText.IndexOf(findWhat, index + replaceWith.Length, StringComparison.OrdinalIgnoreCase);
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
@ -764,7 +765,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
if (code.Length == 4)
{
sb.Append(code + " ");
if (code.StartsWith("9") || code.StartsWith("8")) // control codes must be double
if (code.StartsWith('9') || code.StartsWith('8')) // control codes must be double
sb.Append(code + " ");
code = string.Empty;
}
@ -849,7 +850,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public static SCCPositionAndStyle GetColorAndPosition(string code)
{
switch (code.ToLower())
switch (code.ToLower(CultureInfo.InvariantCulture))
{
//NO x-coordinate?
@ -1598,7 +1599,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
TimeCode startTime = ParseTimeCode(s.Substring(0, match.Length - 1));
string text = GetSccText(s.Substring(match.Index), ref _errorCount);
if (text == "942c 942c" || text == "942c")
if (string.Compare(text, "942c 942c", StringComparison.Ordinal) == 0 || string.Compare(text, "942c", StringComparison.Ordinal) == 0)
{
p.EndTime = new TimeCode(startTime.TotalMilliseconds);
}
@ -1638,13 +1639,13 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
string part = parts[k];
if (part.Length == 4)
{
if (part == "94ae" || part == "9420" || string.Compare(part, "94ad", StringComparison.OrdinalIgnoreCase) == 0 || part == "9426")
if (string.Compare(part, "94ae", StringComparison.Ordinal) == 0 || string.Compare(part, "9420", StringComparison.Ordinal) == 0 || string.Compare(part, "94ad", StringComparison.OrdinalIgnoreCase) == 0 || part == "9426")
{
}
else
{
string nextPart = string.Empty;
if (part.StartsWith("9") || part.StartsWith("8"))
if (part.StartsWith('9') || part.StartsWith('8'))
{
if (k + 1 < parts.Length && parts[k + 1] == part)
k++;
@ -1717,7 +1718,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
private static string GetLetter(string hexCode)
{
int index = _letterCodes.IndexOf(hexCode.ToLower());
int index = _letterCodes.IndexOf(hexCode.ToLower(CultureInfo.InvariantCulture));
if (index < 0)
return null;

View File

@ -7,6 +7,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class SonyDVDArchitectExplicitDuration : SubtitleFormat
{
private static Regex regex = new Regex(@"^\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+", RegexOptions.Compiled);
public override string Extension
{
get { return ".sub"; }
@ -50,7 +53,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
//00:02:14.018 00:02:19.018 00:00:05.000 - Prøvetekst 2- Linie 2
//newline = \r (0D)
var regex = new Regex(@"^\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+", RegexOptions.Compiled);
_errorCount = 0;
Paragraph lastParagraph = null;
foreach (string line in lines)
@ -60,38 +62,45 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
string l = line;
string s = l;
bool success = false;
var match = regex.Match(s);
if (s.Length > 26 && match.Success)
bool isTimeCode = false;
if (s.Length > 26 && s.IndexOf(':') == 2)
{
s = s.Substring(0, match.Length);
s = s.Replace("\t", ":");
s = s.Replace(".", ":");
s = s.Replace(" ", string.Empty);
s = s.Trim().TrimEnd(':').TrimEnd();
string[] parts = s.Split(':');
if (parts.Length == 12)
var match = regex.Match(s);
if (match.Success)
{
int hours = int.Parse(parts[0]);
int minutes = int.Parse(parts[1]);
int seconds = int.Parse(parts[2]);
int milliseconds = int.Parse(parts[3]);
var start = new TimeCode(hours, minutes, seconds, milliseconds);
isTimeCode = true;
s = s.Substring(0, match.Length);
s = s.Replace("\t", ":");
s = s.Replace(".", ":");
s = s.Replace(" ", string.Empty);
s = s.Trim().TrimEnd(':').TrimEnd();
string[] parts = s.Split(':');
if (parts.Length == 12)
{
int hours = int.Parse(parts[0]);
int minutes = int.Parse(parts[1]);
int seconds = int.Parse(parts[2]);
int milliseconds = int.Parse(parts[3]);
var start = new TimeCode(hours, minutes, seconds, milliseconds);
hours = int.Parse(parts[4]);
minutes = int.Parse(parts[5]);
seconds = int.Parse(parts[6]);
milliseconds = int.Parse(parts[7]);
var end = new TimeCode(hours, minutes, seconds, milliseconds);
hours = int.Parse(parts[4]);
minutes = int.Parse(parts[5]);
seconds = int.Parse(parts[6]);
milliseconds = int.Parse(parts[7]);
var end = new TimeCode(hours, minutes, seconds, milliseconds);
string text = l.Substring(match.Length).TrimStart();
text = text.Replace("|", Environment.NewLine);
string text = l.Substring(match.Length).TrimStart();
text = text.Replace("|", Environment.NewLine);
lastParagraph = new Paragraph(start, end, text);
subtitle.Paragraphs.Add(lastParagraph);
success = true;
lastParagraph = new Paragraph(start, end, text);
subtitle.Paragraphs.Add(lastParagraph);
success = true;
}
}
}
else if (l.Trim().Length > 0 && lastParagraph != null && Utilities.CountTagInText(lastParagraph.Text, Environment.NewLine) < 4)
if (!isTimeCode && l.Trim().Length > 0 && lastParagraph != null && Utilities.CountTagInText(lastParagraph.Text, Environment.NewLine) < 4)
{
lastParagraph.Text += Environment.NewLine + l.Trim();
success = true;

View File

@ -7,6 +7,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class SonyDVDArchitectLineAndDuration : SubtitleFormat
{
private static Regex regex = new Regex(@"^\d+\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled);
public override string Extension
{
get { return ".txt"; }
@ -61,30 +63,33 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{ //22 00:04:19:12 00:04:21:09 00:00:01:21
var regex = new Regex(@"^\d+\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled);
_errorCount = 0;
Paragraph lastParagraph = null;
int count = 0;
foreach (string line in lines)
{
string s = line;
bool isTimeCode = false;
if (s.Length > 0)
{
bool success = false;
var match = regex.Match(s);
if (s.Length > 31 && match.Success)
if (s.Length > 31 && s.IndexOf(':') > 1)
{
if (lastParagraph != null)
subtitle.Paragraphs.Add(lastParagraph);
var match = regex.Match(s);
if (match.Success)
{
isTimeCode = true;
if (lastParagraph != null)
subtitle.Paragraphs.Add(lastParagraph);
var arr = s.Split('\t');
TimeCode start = DecodeTimeCode(arr[1]);
TimeCode end = DecodeTimeCode(arr[2]);
lastParagraph = new Paragraph(start, end, string.Empty);
success = true;
var arr = s.Split('\t');
TimeCode start = DecodeTimeCode(arr[1]);
TimeCode end = DecodeTimeCode(arr[2]);
lastParagraph = new Paragraph(start, end, string.Empty);
success = true;
}
}
else if (line.Trim().Length > 0 && lastParagraph != null && Utilities.CountTagInText(lastParagraph.Text, Environment.NewLine) < 4)
if (!isTimeCode && line.Trim().Length > 0 && lastParagraph != null && Utilities.CountTagInText(lastParagraph.Text, Environment.NewLine) < 4)
{
lastParagraph.Text = (lastParagraph.Text + Environment.NewLine + line).Trim();
success = true;
@ -112,5 +117,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
TimeCode tc = new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
return tc;
}
}
}

View File

@ -7,6 +7,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class SonyDVDArchitectTabs : SubtitleFormat
{
private static Regex regex = new Regex(@"^\d\d:\d\d:\d\d:\d\d[ \t]+\d\d:\d\d:\d\d:\d\d[ \t]+", RegexOptions.Compiled);
public override string Extension
{
get { return ".sub"; }
@ -49,7 +51,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
//00:02:14:02 00:02:16:41 - Var det den rigtige der vandt?- Ja, bestemt.
//newline = \r (0D)
var regex = new Regex(@"^\d\d:\d\d:\d\d:\d\d[ \t]+\d\d:\d\d:\d\d:\d\d[ \t]+", RegexOptions.Compiled);
_errorCount = 0;
Paragraph lastParagraph = null;
foreach (string line in lines)
@ -57,37 +58,42 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
if (line.Trim().Length > 0)
{
bool success = false;
var match = regex.Match(line);
if (line.Length > 26 && match.Success)
bool isTimeCode = false;
if (line.Length > 26 && line.IndexOf(':') == 2)
{
string s = line.Substring(0, match.Length);
s = s.Replace("\t", ":");
s = s.Replace(" ", string.Empty);
s = s.Trim().TrimEnd(':').TrimEnd();
string[] parts = s.Split(':');
if (parts.Length == 8)
var match = regex.Match(line);
if (match.Success)
{
int hours = int.Parse(parts[0]);
int minutes = int.Parse(parts[1]);
int seconds = int.Parse(parts[2]);
int milliseconds = int.Parse(parts[3]) * 10;
var start = new TimeCode(hours, minutes, seconds, milliseconds);
isTimeCode = true;
string s = line.Substring(0, match.Length);
s = s.Replace("\t", ":");
s = s.Replace(" ", string.Empty);
s = s.Trim().TrimEnd(':').TrimEnd();
string[] parts = s.Split(':');
if (parts.Length == 8)
{
int hours = int.Parse(parts[0]);
int minutes = int.Parse(parts[1]);
int seconds = int.Parse(parts[2]);
int milliseconds = int.Parse(parts[3]) * 10;
var start = new TimeCode(hours, minutes, seconds, milliseconds);
hours = int.Parse(parts[4]);
minutes = int.Parse(parts[5]);
seconds = int.Parse(parts[6]);
milliseconds = int.Parse(parts[7]) * 10;
var end = new TimeCode(hours, minutes, seconds, milliseconds);
hours = int.Parse(parts[4]);
minutes = int.Parse(parts[5]);
seconds = int.Parse(parts[6]);
milliseconds = int.Parse(parts[7]) * 10;
var end = new TimeCode(hours, minutes, seconds, milliseconds);
string text = line.Substring(match.Length).TrimStart();
text = text.Replace("|", Environment.NewLine);
string text = line.Substring(match.Length).TrimStart();
text = text.Replace("|", Environment.NewLine);
lastParagraph = new Paragraph(start, end, text);
subtitle.Paragraphs.Add(lastParagraph);
success = true;
}
lastParagraph = new Paragraph(start, end, text);
subtitle.Paragraphs.Add(lastParagraph);
success = true;
}
}
}
else if (line.Trim().Length > 0 && lastParagraph != null && Utilities.CountTagInText(lastParagraph.Text, Environment.NewLine) < 4)
if (!isTimeCode && line.Trim().Length > 0 && lastParagraph != null && Utilities.CountTagInText(lastParagraph.Text, Environment.NewLine) < 4)
{
lastParagraph.Text += Environment.NewLine + line.Trim();
success = true;

View File

@ -7,6 +7,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class SonyDVDArchitectWithLineNumbers : SubtitleFormat
{
private static Regex regexTimeCode = new Regex(@"^\d\d\d\d \d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d", RegexOptions.Compiled);
private static Regex regex1DigitMillisecs = new Regex(@"^\d\d\d\d \d\d\d:\d\d:\d\d:\d \d\d\d:\d\d:\d\d:\d", RegexOptions.Compiled);
public override string Extension
{
get { return ".sub"; }
@ -48,8 +51,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{ // 00:04:10:92 - 00:04:13:32 Raise Yourself To Help Mankind
// 00:04:27:92 - 00:04:30:92 الجهة المتولية للمسئولية الاجتماعية لشركتنا.
var regex = new Regex(@"^\d\d\d\d \d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d", RegexOptions.Compiled);
var regex1DigitMillisecs = new Regex(@"^\d\d\d\d \d\d\d:\d\d:\d\d:\d \d\d\d:\d\d:\d\d:\d", RegexOptions.Compiled);
_errorCount = 0;
Paragraph lastParagraph = null;
foreach (string line in lines)
@ -58,61 +59,69 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
if (s.Length > 0)
{
bool success = false;
var match = regex.Match(s);
var match1DigitMillisecs = regex1DigitMillisecs.Match(s);
if (s.Length > 31 && match.Success)
if (line.IndexOf(':') > 0)
{
s = s.Substring(5, match.Length - 5).TrimStart();
s = s.Replace(" ", ":");
s = s.Replace(" ", string.Empty);
string[] parts = s.Split(':');
if (parts.Length == 8)
var match = regexTimeCode.Match(s);
var match1DigitMillisecs = regex1DigitMillisecs.Match(s);
if (s.Length > 31 && match.Success)
{
int hours = int.Parse(parts[0]);
int minutes = int.Parse(parts[1]);
int seconds = int.Parse(parts[2]);
int milliseconds = int.Parse(parts[3]) * 10;
var start = new TimeCode(hours, minutes, seconds, milliseconds);
s = s.Substring(5, match.Length - 5).TrimStart();
s = s.Replace(" ", ":");
s = s.Replace(" ", string.Empty);
string[] parts = s.Split(':');
if (parts.Length == 8)
{
int hours = int.Parse(parts[0]);
int minutes = int.Parse(parts[1]);
int seconds = int.Parse(parts[2]);
int milliseconds = int.Parse(parts[3]) * 10;
var start = new TimeCode(hours, minutes, seconds, milliseconds);
hours = int.Parse(parts[4]);
minutes = int.Parse(parts[5]);
seconds = int.Parse(parts[6]);
milliseconds = int.Parse(parts[7]) * 10;
var end = new TimeCode(hours, minutes, seconds, milliseconds);
hours = int.Parse(parts[4]);
minutes = int.Parse(parts[5]);
seconds = int.Parse(parts[6]);
milliseconds = int.Parse(parts[7]) * 10;
var end = new TimeCode(hours, minutes, seconds, milliseconds);
string text = line.Replace("\0", string.Empty).Substring(match.Length).TrimStart();
text = text.Replace("|", Environment.NewLine);
string text = line.Replace("\0", string.Empty).Substring(match.Length).TrimStart();
text = text.Replace("|", Environment.NewLine);
lastParagraph = new Paragraph(start, end, text);
subtitle.Paragraphs.Add(lastParagraph);
success = true;
lastParagraph = new Paragraph(start, end, text);
subtitle.Paragraphs.Add(lastParagraph);
success = true;
}
}
}
else if (s.Length > 29 && match1DigitMillisecs.Success)
{
s = s.Substring(5, match1DigitMillisecs.Length - 5).TrimStart();
s = s.Replace(" ", ":");
s = s.Replace(" ", string.Empty);
string[] parts = s.Split(':');
if (parts.Length == 8)
else if (s.Length > 29 && match1DigitMillisecs.Success)
{
int hours = int.Parse(parts[0]);
int minutes = int.Parse(parts[1]);
int seconds = int.Parse(parts[2]);
int milliseconds = int.Parse(parts[3]) * 10;
var start = new TimeCode(hours, minutes, seconds, milliseconds);
s = s.Substring(5, match1DigitMillisecs.Length - 5).TrimStart();
s = s.Replace(" ", ":");
s = s.Replace(" ", string.Empty);
string[] parts = s.Split(':');
if (parts.Length == 8)
{
int hours = int.Parse(parts[0]);
int minutes = int.Parse(parts[1]);
int seconds = int.Parse(parts[2]);
int milliseconds = int.Parse(parts[3]) * 10;
var start = new TimeCode(hours, minutes, seconds, milliseconds);
hours = int.Parse(parts[4]);
minutes = int.Parse(parts[5]);
seconds = int.Parse(parts[6]);
milliseconds = int.Parse(parts[7]) * 10;
var end = new TimeCode(hours, minutes, seconds, milliseconds);
hours = int.Parse(parts[4]);
minutes = int.Parse(parts[5]);
seconds = int.Parse(parts[6]);
milliseconds = int.Parse(parts[7]) * 10;
var end = new TimeCode(hours, minutes, seconds, milliseconds);
string text = line.Replace("\0", string.Empty).Substring(match1DigitMillisecs.Length).TrimStart();
text = text.Replace("|", Environment.NewLine);
string text = line.Replace("\0", string.Empty).Substring(match1DigitMillisecs.Length).TrimStart();
text = text.Replace("|", Environment.NewLine);
lastParagraph = new Paragraph(start, end, text);
subtitle.Paragraphs.Add(lastParagraph);
lastParagraph = new Paragraph(start, end, text);
subtitle.Paragraphs.Add(lastParagraph);
success = true;
}
}
else if (line.Trim().Length > 0 && lastParagraph != null && Utilities.CountTagInText(lastParagraph.Text, Environment.NewLine) < 4)
{
lastParagraph.Text += Environment.NewLine + line.Trim();
success = true;
}
}

View File

@ -7,6 +7,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class SpruceWithSpace : SubtitleFormat
{
private static Regex regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d, \d\d:\d\d:\d\d:\d\d,.+", RegexOptions.Compiled);
public override string Extension
{
get { return ".stl"; }
@ -89,10 +92,9 @@ $TapeOffset = FALSE
//00:01:54:19,00:01:56:17,We should be thankful|they accepted our offer.
_errorCount = 0;
subtitle.Paragraphs.Clear();
var regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d, \d\d:\d\d:\d\d:\d\d,.+", RegexOptions.Compiled);
foreach (string line in lines)
{
if (regexTimeCodes.IsMatch(line))
if (line.IndexOf(':') == 2 && regexTimeCodes.IsMatch(line))
{
string start = line.Substring(0, 11);
string end = line.Substring(13, 11);

View File

@ -7,6 +7,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class StructuredTitles : SubtitleFormat
{
private static Regex regexTimeCodes = new Regex(@"^\d\d\d\d : \d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,\d\d", RegexOptions.Compiled);
private static Regex regexSomeCodes = new Regex(@"^\d\d \d\d \d\d", RegexOptions.Compiled);
private static Regex regexText = new Regex(@"^[A-Z]\d[A-Z]\d\d ", RegexOptions.Compiled);
public override string Extension
{
get { return ".txt"; }
@ -73,12 +77,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
_errorCount = 0;
Paragraph p = null;
subtitle.Paragraphs.Clear();
var regexTimeCodes = new Regex(@"^\d\d\d\d : \d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,\d\d", RegexOptions.Compiled);
var regexSomeCodes = new Regex(@"^\d\d \d\d \d\d", RegexOptions.Compiled);
var regexText = new Regex(@"^[A-Z]\d[A-Z]\d\d ", RegexOptions.Compiled);
foreach (string line in lines)
{
if (regexTimeCodes.IsMatch(line))
if (line.IndexOf(':') == 5 && regexTimeCodes.IsMatch(line))
{
if (p != null)
subtitle.Paragraphs.Add(p);
@ -100,7 +101,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
else
p.Text += Environment.NewLine + line.Substring(5).Trim();
}
else if (regexSomeCodes.IsMatch(line))
else if (line.Length < 10 && regexSomeCodes.IsMatch(line))
{
}
else if (line.Trim().Length == 0)

View File

@ -7,6 +7,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class UnknownSubtitle4 : SubtitleFormat
{
private static Regex regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d.\d+, \d\d:\d\d:\d\d.\d+$", RegexOptions.Compiled);
private enum ExpectingLine
{
TimeCodes,
@ -74,8 +76,6 @@ namespace Nikse.SubtitleEdit.Logic.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\d.\d+$", RegexOptions.Compiled);
var paragraph = new Paragraph();
ExpectingLine expecting = ExpectingLine.TimeCodes;
_errorCount = 0;
@ -83,7 +83,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
subtitle.Paragraphs.Clear();
foreach (string line in lines)
{
if (regexTimeCodes.IsMatch(line))
if (line.IndexOf(':') == 2 && regexTimeCodes.IsMatch(line))
{
string[] parts = line.Split(new[] { ':', ',', '.', ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 8)

View File

@ -7,6 +7,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
public class UnknownSubtitle6 : SubtitleFormat
{
private static Regex regexBeforeText = new Regex(@"^\d\s+\d\s+\d\s+\d\s+\d\s+\d$", RegexOptions.Compiled);
private static Regex regexTimeCodes = new Regex(@"^\d+\s+\d+$", RegexOptions.Compiled);
private enum ExpectingLine
{
TimeCodes,
@ -73,9 +76,6 @@ SRPSKI
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
var regexBeforeText = new Regex(@"^\d\s+\d\s+\d\s+\d\s+\d\s+\d$", RegexOptions.Compiled);
var regexTimeCodes = new Regex(@"^\d+\s+\d+$", RegexOptions.Compiled);
var paragraph = new Paragraph();
ExpectingLine expecting = ExpectingLine.TimeCodes;
_errorCount = 0;
@ -83,7 +83,6 @@ SRPSKI
subtitle.Paragraphs.Clear();
foreach (string line in lines)
{
string s = line.Trim();
if (regexTimeCodes.IsMatch(s))
{