mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 06:52:35 +01:00
Display errors in SubRip files after loading (if there were any)
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1232 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
1c6dd18c0f
commit
a244c8384b
@ -238,8 +238,11 @@ namespace Nikse.SubtitleEdit.Controls
|
|||||||
{
|
{
|
||||||
_subtitleText = value;
|
_subtitleText = value;
|
||||||
|
|
||||||
bool alignLeft = _subtitleText.StartsWith("{\\a1}") || _subtitleText.StartsWith("{\\a5}") || _subtitleText.StartsWith("{\\a9}");
|
bool alignLeft = _subtitleText.StartsWith("{\\a1}") || _subtitleText.StartsWith("{\\a5}") || _subtitleText.StartsWith("{\\a9}") || // sub station alpha
|
||||||
bool alignRight = _subtitleText.StartsWith("{\\a3}") || _subtitleText.StartsWith("{\\a7}") || _subtitleText.StartsWith("{\\a11}");
|
_subtitleText.StartsWith("{\\an1}") || _subtitleText.StartsWith("{\\an4}") || _subtitleText.StartsWith("{\\an7}"); // advanced sub station alpha
|
||||||
|
|
||||||
|
bool alignRight = _subtitleText.StartsWith("{\\a3}") || _subtitleText.StartsWith("{\\a7}") || _subtitleText.StartsWith("{\\a11}") || // sub station alpha
|
||||||
|
_subtitleText.StartsWith("{\\an3}") || _subtitleText.StartsWith("{\\an6}") || _subtitleText.StartsWith("{\\an9}"); // advanced sub station alpha
|
||||||
|
|
||||||
// remove styles for display text (except italic)
|
// remove styles for display text (except italic)
|
||||||
string text = RemoveSubStationAlphaFormatting(_subtitleText);
|
string text = RemoveSubStationAlphaFormatting(_subtitleText);
|
||||||
|
@ -2131,7 +2131,13 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header);
|
string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header);
|
||||||
if (!string.IsNullOrEmpty(errors))
|
if (!string.IsNullOrEmpty(errors))
|
||||||
MessageBox.Show(errors);
|
MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
else if (format.GetType() == typeof(SubRip))
|
||||||
|
{
|
||||||
|
string errors = (format as SubRip).Errors;
|
||||||
|
if (!string.IsNullOrEmpty(errors))
|
||||||
|
MessageBox.Show((format as SubRip).Errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3570,12 +3576,19 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format.FriendlyName == new AdvancedSubStationAlpha().FriendlyName || format.FriendlyName == new SubStationAlpha().FriendlyName)
|
if (format.GetType() == typeof(AdvancedSubStationAlpha) || format.GetType() == typeof(SubStationAlpha))
|
||||||
{
|
{
|
||||||
string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header);
|
string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header);
|
||||||
if (!string.IsNullOrEmpty(errors))
|
if (!string.IsNullOrEmpty(errors))
|
||||||
MessageBox.Show(errors);
|
MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
|
else if (format.GetType() == typeof(SubRip))
|
||||||
|
{
|
||||||
|
string errors = (format as SubRip).Errors;
|
||||||
|
if (!string.IsNullOrEmpty(errors))
|
||||||
|
MessageBox.Show((format as SubRip).Errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -781,6 +781,8 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
TextFiles = "Text files",
|
TextFiles = "Text files",
|
||||||
ExportPlainTextAs = "Export plain text as",
|
ExportPlainTextAs = "Export plain text as",
|
||||||
SubtitleExported = "Subtitle exported",
|
SubtitleExported = "Subtitle exported",
|
||||||
|
LineNumberXErrorReadingTimeCodeFromSourceLineY = "Line {0} - error reading time code: {1}",
|
||||||
|
LineNumberXExpectedNumberFromSourceLineY = "Line {0} - expected subtitle number: {1}",
|
||||||
|
|
||||||
Menu = new LanguageStructure.Main.MainMenu
|
Menu = new LanguageStructure.Main.MainMenu
|
||||||
{
|
{
|
||||||
|
@ -721,6 +721,9 @@
|
|||||||
public string ExportPlainTextAs { get; set; }
|
public string ExportPlainTextAs { get; set; }
|
||||||
public string TextFiles { get; set; }
|
public string TextFiles { get; set; }
|
||||||
public string SubtitleExported { get; set; }
|
public string SubtitleExported { get; set; }
|
||||||
|
public string LineNumberXErrorReadingTimeCodeFromSourceLineY { get; set; }
|
||||||
|
public string LineNumberXExpectedNumberFromSourceLineY { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public class MainMenu
|
public class MainMenu
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
{
|
{
|
||||||
public class SubRip : SubtitleFormat
|
public class SubRip : SubtitleFormat
|
||||||
{
|
{
|
||||||
|
public string Errors { get; private set; }
|
||||||
|
private StringBuilder _errors;
|
||||||
|
private int _lineNumber;
|
||||||
|
|
||||||
enum ExpectingLine
|
enum ExpectingLine
|
||||||
{
|
{
|
||||||
Number,
|
Number,
|
||||||
@ -63,6 +67,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||||
{
|
{
|
||||||
bool doRenum = false;
|
bool doRenum = false;
|
||||||
|
_errors = new StringBuilder();
|
||||||
|
_lineNumber = 0;
|
||||||
|
|
||||||
_paragraph = new Paragraph();
|
_paragraph = new Paragraph();
|
||||||
_expecting = ExpectingLine.Number;
|
_expecting = ExpectingLine.Number;
|
||||||
@ -71,6 +77,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
subtitle.Paragraphs.Clear();
|
subtitle.Paragraphs.Clear();
|
||||||
for (int i=0; i<lines.Count; i++)
|
for (int i=0; i<lines.Count; i++)
|
||||||
{
|
{
|
||||||
|
_lineNumber++;
|
||||||
string line = lines[i].TrimEnd();
|
string line = lines[i].TrimEnd();
|
||||||
line = line.Trim(Convert.ToChar(127)); // 127=delete acscii
|
line = line.Trim(Convert.ToChar(127)); // 127=delete acscii
|
||||||
|
|
||||||
@ -101,6 +108,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
|
|
||||||
if (doRenum)
|
if (doRenum)
|
||||||
subtitle.Renumber(1);
|
subtitle.Renumber(1);
|
||||||
|
|
||||||
|
Errors = _errors.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadLine(Subtitle subtitle, string line, string next)
|
private void ReadLine(Subtitle subtitle, string line, string next)
|
||||||
@ -115,6 +124,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
}
|
}
|
||||||
else if (line.Trim().Length > 0)
|
else if (line.Trim().Length > 0)
|
||||||
{
|
{
|
||||||
|
if (_errors.Length < 2000)
|
||||||
|
_errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXExpectedNumberFromSourceLineY, _lineNumber, line));
|
||||||
_errorCount++;
|
_errorCount++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -126,6 +137,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
}
|
}
|
||||||
else if (line.Trim().Length > 0)
|
else if (line.Trim().Length > 0)
|
||||||
{
|
{
|
||||||
|
if (_errors.Length < 2000)
|
||||||
|
_errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXErrorReadingTimeCodeFromSourceLineY, _lineNumber, line));
|
||||||
_errorCount++;
|
_errorCount++;
|
||||||
_expecting = ExpectingLine.Number ; // lets go to next paragraph
|
_expecting = ExpectingLine.Number ; // lets go to next paragraph
|
||||||
}
|
}
|
||||||
@ -180,7 +193,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
private string RemoveBadChars(string line)
|
private string RemoveBadChars(string line)
|
||||||
{
|
{
|
||||||
line = line.Replace("\0", " ");
|
line = line.Replace("\0", " ");
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,12 +200,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
{
|
{
|
||||||
line = line.Replace("،", ",");
|
line = line.Replace("،", ",");
|
||||||
|
|
||||||
line = line.Trim();
|
|
||||||
line = line.Replace(": ", ":"); // I've seen this
|
|
||||||
line = line.Replace(" :", ":");
|
|
||||||
line = line.Replace(" ,", ",");
|
|
||||||
line = line.Replace(", ", ",");
|
|
||||||
|
|
||||||
// Fix some badly formatted separator sequences - anything can happen if you manually edit ;)
|
// Fix some badly formatted separator sequences - anything can happen if you manually edit ;)
|
||||||
line = line.Replace(" -> ", " --> "); // I've seen this
|
line = line.Replace(" -> ", " --> "); // I've seen this
|
||||||
line = line.Replace(" - > ", " --> ");
|
line = line.Replace(" - > ", " --> ");
|
||||||
@ -201,12 +207,17 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
line = line.Replace(" -- > ", " --> ");
|
line = line.Replace(" -- > ", " --> ");
|
||||||
line = line.Replace(" - -> ", " --> ");
|
line = line.Replace(" - -> ", " --> ");
|
||||||
line = line.Replace(" -->> ", " --> ");
|
line = line.Replace(" -->> ", " --> ");
|
||||||
|
line = line.Replace(" ---> ", " --> ");
|
||||||
|
|
||||||
// Removed stuff after timecodes - like subtitle position
|
// Removed stuff after timecodes - like subtitle position
|
||||||
// - example of position info: 00:02:26,407 --> 00:02:31,356 X1:100 X2:100 Y1:100 Y2:100
|
// - example of position info: 00:02:26,407 --> 00:02:31,356 X1:100 X2:100 Y1:100 Y2:100
|
||||||
if (line.Length > 30 && line[30] == ' ')
|
if (line.Length > 30 && line[30] == ' ')
|
||||||
line = line.Substring(0, 29);
|
line = line.Substring(0, 29);
|
||||||
|
|
||||||
|
// removes all extra spaces
|
||||||
|
line = line.Replace(" ", string.Empty).Replace("-->", " --> ");
|
||||||
|
line = line.Trim();
|
||||||
|
|
||||||
// Fix a few more cases of wrong time codes, seen this: 00.00.02,000 --> 00.00.04,000
|
// Fix a few more cases of wrong time codes, seen this: 00.00.02,000 --> 00.00.04,000
|
||||||
line = line.Replace('.', ':');
|
line = line.Replace('.', ':');
|
||||||
if (line.Length >= 29 && ":;".Contains(line[8].ToString()))
|
if (line.Length >= 29 && ":;".Contains(line[8].ToString()))
|
||||||
|
Loading…
Reference in New Issue
Block a user