Refactor some netflix check + work on fix

This commit is contained in:
Nikolaj Olsson 2019-12-30 17:05:08 +01:00
parent 1e42b93b90
commit 894c043789
14 changed files with 810 additions and 33 deletions

View File

@ -251,7 +251,7 @@
<Compile Include="NetflixQualityCheck\NetflixCheckGlyph.cs" />
<Compile Include="NetflixQualityCheck\INetflixQualityChecker.cs" />
<Compile Include="NetflixQualityCheck\NetflixCheckTextForHiUseBrackets.cs" />
<Compile Include="NetflixQualityCheck\NetflixCheckDialogeHyphenSpace.cs" />
<Compile Include="NetflixQualityCheck\NetflixCheckDialogHyphenSpace.cs" />
<Compile Include="NetflixQualityCheck\NetflixCheckMaxCps.cs" />
<Compile Include="NetflixQualityCheck\NetflixCheckTwoFramesGap.cs" />
<Compile Include="NetflixQualityCheck\NetflixCheckNumberOfLines.cs" />

View File

@ -1,9 +1,8 @@
using Nikse.SubtitleEdit.Core.Forms.FixCommonErrors;
using System;
using System;
namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
{
public class NetflixCheckDialogeHyphenSpace : INetflixQualityChecker
public class NetflixCheckDialogHyphenSpace : INetflixQualityChecker
{
/// <summary>
@ -11,7 +10,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
/// </summary>
public void Check(Subtitle subtitle, NetflixQualityController controller)
{
if (controller.DualSpeakersHasHypenAndNoSplace)
if (controller.DualSpeakersHasHyphenAndNoSpace)
{
RemoveSpaceAfterHyphenInDialogues(subtitle, controller);
}

View File

@ -1,5 +1,4 @@
using System;
using System.Text.RegularExpressions;
namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
{

View File

@ -18,7 +18,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
return;
}
foreach (Paragraph p in subtitle.Paragraphs)
foreach (var p in subtitle.Paragraphs)
{
string newText = p.Text;
var m = NumberOneToNine.Match(newText);

View File

@ -64,14 +64,14 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
private static readonly List<double> ValidFrameRates = new List<double>
{
23.98,
24,
25,
29.97,
30,
59.94,
60,
25,
50,
24,
23.98
59.94,
60
};
private static void CheckFrameRate(double fr, NetflixQualityController controller)

View File

@ -11,11 +11,11 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
private static void AddWhiteSpaceWarning(Paragraph p, NetflixQualityController report, int pos)
{
string timecode = p.StartTime.ToHHMMSSFF();
string timeCode = p.StartTime.ToHHMMSSFF();
string context = NetflixQualityController.StringContext(p.Text, pos, 6);
string comment = string.Format(Configuration.Settings.Language.NetflixQualityCheck.WhiteSpaceCheckReport, pos);
report.AddRecord(p, timecode, context, comment);
report.AddRecord(p, timeCode, context, comment);
}
public void Check(Subtitle subtitle, NetflixQualityController controller)

View File

@ -81,7 +81,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
}
}
public bool DualSpeakersHasHypenAndNoSplace
public bool DualSpeakersHasHyphenAndNoSpace
{
get
{
@ -106,7 +106,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
public class Record
{
public string Timecode { get; set; }
public string TimeCode { get; set; }
public string Context { get; set; }
public string Comment { get; set; }
public Paragraph OriginalParagraph { get; set; }
@ -114,21 +114,21 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
public Record()
{
Timecode = string.Empty;
TimeCode = string.Empty;
Context = string.Empty;
Comment = string.Empty;
}
public Record(string timecode, string context, string comment)
public Record(string timeCode, string context, string comment)
{
Timecode = timecode;
TimeCode = timeCode;
Context = context;
Comment = comment;
}
public string ToCsvRow()
{
return $"{Timecode},{CsvTextEncode(Context)},{CsvTextEncode(Comment)}";
return $"{TimeCode},{CsvTextEncode(Context)},{CsvTextEncode(Comment)}";
}
private static string CsvTextEncode(string s)
@ -158,7 +158,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
{
Comment = comment,
OriginalParagraph = originalParagraph,
Timecode = originalParagraph.StartTime.ToDisplayString()
TimeCode = originalParagraph.StartTime.ToDisplayString()
});
}
public void AddRecord(Paragraph originalParagraph, Paragraph fixedParagraph, string comment, string context = "")
@ -169,7 +169,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
Context = context,
OriginalParagraph = originalParagraph,
FixedParagraph = fixedParagraph,
Timecode = originalParagraph?.StartTime.ToDisplayString()
TimeCode = originalParagraph?.StartTime.ToDisplayString()
});
}
@ -201,12 +201,12 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
return str.Substring(beginPos, length);
}
private List<INetflixQualityChecker> GetAllCheckers()
private static List<INetflixQualityChecker> GetAllCheckers()
{
return new List<INetflixQualityChecker>
{
new NetflixCheckTimedTextFrameRate(),
new NetflixCheckDialogeHyphenSpace(),
new NetflixCheckDialogHyphenSpace(),
new NetflixCheckGlyph(),
new NetflixCheckMaxCps(),
new NetflixCheckMaxLineLength(),
@ -222,15 +222,19 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
};
}
public void CheckAll(Subtitle subtitle)
public void RunChecks(Subtitle subtitle)
{
RunChecks(subtitle, GetAllCheckers());
}
public void RunChecks(Subtitle subtitle, List<INetflixQualityChecker> checks)
{
Records = new List<Record>();
foreach (var checker in GetAllCheckers())
foreach (var checker in checks)
{
checker.Check(subtitle, this);
}
Records = Records.OrderBy(p => p.OriginalParagraph?.Number ?? 0).ToList();
}
}
}

View File

@ -25461,7 +25461,7 @@ namespace Nikse.SubtitleEdit.Forms
netflixController.FrameRate = _videoInfo.FramesPerSecond;
}
netflixController.CheckAll(_subtitle);
netflixController.RunChecks(_subtitle);
if (netflixController.Records.Count > 0)
{
@ -25476,6 +25476,16 @@ namespace Nikse.SubtitleEdit.Forms
if (!isSaving)
{
dialog.ShowDialog(this);
if (Configuration.Settings.General.ShowBetaStuff)
{
using (var form = new NetflixFixErrors(_subtitle, GetCurrentSubtitleFormat()))
{
if (form.ShowDialog(this) == DialogResult.OK)
{
}
}
}
}
else
{

421
src/Forms/NetflixFixErrors.Designer.cs generated Normal file
View File

@ -0,0 +1,421 @@
namespace Nikse.SubtitleEdit.Forms
{
partial class NetflixFixErrors
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBoxRules = new System.Windows.Forms.GroupBox();
this.checkBoxWhiteSpace = new System.Windows.Forms.CheckBox();
this.checkBoxMaxLineLength = new System.Windows.Forms.CheckBox();
this.checkBoxTtmlFrameRate = new System.Windows.Forms.CheckBox();
this.checkBoxNoItalics = new System.Windows.Forms.CheckBox();
this.checkBoxGapMinTwoFrames = new System.Windows.Forms.CheckBox();
this.checkBoxCheckValidGlyphs = new System.Windows.Forms.CheckBox();
this.checkBox17CharsPerSecond = new System.Windows.Forms.CheckBox();
this.comboBoxLanguage = new System.Windows.Forms.ComboBox();
this.labelLanguage = new System.Windows.Forms.Label();
this.checkBoxWriteOutOneToTen = new System.Windows.Forms.CheckBox();
this.checkBoxSpellOutStartNumbers = new System.Windows.Forms.CheckBox();
this.checkBoxSquareBracketForHi = new System.Windows.Forms.CheckBox();
this.checkBoxDialogHypenNoSpace = new System.Windows.Forms.CheckBox();
this.checkBoxTwoLinesMax = new System.Windows.Forms.CheckBox();
this.checkBoxMinDuration = new System.Windows.Forms.CheckBox();
this.checkBoxMaxDuration = new System.Windows.Forms.CheckBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.labelTotal = new System.Windows.Forms.Label();
this.listViewFixes = new System.Windows.Forms.ListView();
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.groupBoxRules.SuspendLayout();
this.SuspendLayout();
//
// groupBoxRules
//
this.groupBoxRules.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxRules.Controls.Add(this.checkBoxWhiteSpace);
this.groupBoxRules.Controls.Add(this.checkBoxMaxLineLength);
this.groupBoxRules.Controls.Add(this.checkBoxTtmlFrameRate);
this.groupBoxRules.Controls.Add(this.checkBoxNoItalics);
this.groupBoxRules.Controls.Add(this.checkBoxGapMinTwoFrames);
this.groupBoxRules.Controls.Add(this.checkBoxCheckValidGlyphs);
this.groupBoxRules.Controls.Add(this.checkBox17CharsPerSecond);
this.groupBoxRules.Controls.Add(this.comboBoxLanguage);
this.groupBoxRules.Controls.Add(this.labelLanguage);
this.groupBoxRules.Controls.Add(this.checkBoxWriteOutOneToTen);
this.groupBoxRules.Controls.Add(this.checkBoxSpellOutStartNumbers);
this.groupBoxRules.Controls.Add(this.checkBoxSquareBracketForHi);
this.groupBoxRules.Controls.Add(this.checkBoxDialogHypenNoSpace);
this.groupBoxRules.Controls.Add(this.checkBoxTwoLinesMax);
this.groupBoxRules.Controls.Add(this.checkBoxMinDuration);
this.groupBoxRules.Controls.Add(this.checkBoxMaxDuration);
this.groupBoxRules.Location = new System.Drawing.Point(12, 12);
this.groupBoxRules.Name = "groupBoxRules";
this.groupBoxRules.Size = new System.Drawing.Size(1016, 248);
this.groupBoxRules.TabIndex = 106;
this.groupBoxRules.TabStop = false;
this.groupBoxRules.Text = "Rules";
//
// checkBoxWhiteSpace
//
this.checkBoxWhiteSpace.AutoSize = true;
this.checkBoxWhiteSpace.Checked = true;
this.checkBoxWhiteSpace.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxWhiteSpace.Location = new System.Drawing.Point(19, 193);
this.checkBoxWhiteSpace.Name = "checkBoxWhiteSpace";
this.checkBoxWhiteSpace.Size = new System.Drawing.Size(86, 17);
this.checkBoxWhiteSpace.TabIndex = 36;
this.checkBoxWhiteSpace.Text = "White space";
this.checkBoxWhiteSpace.UseVisualStyleBackColor = true;
this.checkBoxWhiteSpace.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxMaxLineLength
//
this.checkBoxMaxLineLength.AutoSize = true;
this.checkBoxMaxLineLength.Checked = true;
this.checkBoxMaxLineLength.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxMaxLineLength.Location = new System.Drawing.Point(19, 170);
this.checkBoxMaxLineLength.Name = "checkBoxMaxLineLength";
this.checkBoxMaxLineLength.Size = new System.Drawing.Size(130, 17);
this.checkBoxMaxLineLength.TabIndex = 35;
this.checkBoxMaxLineLength.Text = "Check max line length";
this.checkBoxMaxLineLength.UseVisualStyleBackColor = true;
this.checkBoxMaxLineLength.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxTtmlFrameRate
//
this.checkBoxTtmlFrameRate.AutoSize = true;
this.checkBoxTtmlFrameRate.Checked = true;
this.checkBoxTtmlFrameRate.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxTtmlFrameRate.Location = new System.Drawing.Point(409, 193);
this.checkBoxTtmlFrameRate.Name = "checkBoxTtmlFrameRate";
this.checkBoxTtmlFrameRate.Size = new System.Drawing.Size(154, 17);
this.checkBoxTtmlFrameRate.TabIndex = 34;
this.checkBoxTtmlFrameRate.Text = "Check frame rate for TTML";
this.checkBoxTtmlFrameRate.UseVisualStyleBackColor = true;
this.checkBoxTtmlFrameRate.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxNoItalics
//
this.checkBoxNoItalics.AutoSize = true;
this.checkBoxNoItalics.Checked = true;
this.checkBoxNoItalics.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxNoItalics.Location = new System.Drawing.Point(409, 170);
this.checkBoxNoItalics.Name = "checkBoxNoItalics";
this.checkBoxNoItalics.Size = new System.Drawing.Size(109, 17);
this.checkBoxNoItalics.TabIndex = 33;
this.checkBoxNoItalics.Text = "Do not allow italic";
this.checkBoxNoItalics.UseVisualStyleBackColor = true;
this.checkBoxNoItalics.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxGapMinTwoFrames
//
this.checkBoxGapMinTwoFrames.AutoSize = true;
this.checkBoxGapMinTwoFrames.Checked = true;
this.checkBoxGapMinTwoFrames.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxGapMinTwoFrames.Location = new System.Drawing.Point(19, 124);
this.checkBoxGapMinTwoFrames.Name = "checkBoxGapMinTwoFrames";
this.checkBoxGapMinTwoFrames.Size = new System.Drawing.Size(168, 17);
this.checkBoxGapMinTwoFrames.TabIndex = 6;
this.checkBoxGapMinTwoFrames.Text = "Frame gap: minimum 2 frames";
this.checkBoxGapMinTwoFrames.UseVisualStyleBackColor = true;
this.checkBoxGapMinTwoFrames.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxCheckValidGlyphs
//
this.checkBoxCheckValidGlyphs.AutoSize = true;
this.checkBoxCheckValidGlyphs.Checked = true;
this.checkBoxCheckValidGlyphs.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxCheckValidGlyphs.Location = new System.Drawing.Point(409, 147);
this.checkBoxCheckValidGlyphs.Name = "checkBoxCheckValidGlyphs";
this.checkBoxCheckValidGlyphs.Size = new System.Drawing.Size(330, 17);
this.checkBoxCheckValidGlyphs.TabIndex = 21;
this.checkBoxCheckValidGlyphs.Text = "Only text/characters included in the Netflix Glyph List (version 2) ";
this.checkBoxCheckValidGlyphs.UseVisualStyleBackColor = true;
this.checkBoxCheckValidGlyphs.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBox17CharsPerSecond
//
this.checkBox17CharsPerSecond.AutoSize = true;
this.checkBox17CharsPerSecond.Checked = true;
this.checkBox17CharsPerSecond.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox17CharsPerSecond.Location = new System.Drawing.Point(19, 101);
this.checkBox17CharsPerSecond.Name = "checkBox17CharsPerSecond";
this.checkBox17CharsPerSecond.Size = new System.Drawing.Size(290, 17);
this.checkBox17CharsPerSecond.TabIndex = 5;
this.checkBox17CharsPerSecond.Text = "Maximum 17 characters per second (excl. white spaces)";
this.checkBox17CharsPerSecond.UseVisualStyleBackColor = true;
this.checkBox17CharsPerSecond.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// comboBoxLanguage
//
this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxLanguage.FormattingEnabled = true;
this.comboBoxLanguage.Location = new System.Drawing.Point(77, 14);
this.comboBoxLanguage.Name = "comboBoxLanguage";
this.comboBoxLanguage.Size = new System.Drawing.Size(196, 21);
this.comboBoxLanguage.TabIndex = 30;
this.comboBoxLanguage.SelectedIndexChanged += new System.EventHandler(this.comboBoxLanguage_SelectedIndexChanged);
//
// labelLanguage
//
this.labelLanguage.AutoSize = true;
this.labelLanguage.Location = new System.Drawing.Point(16, 17);
this.labelLanguage.Name = "labelLanguage";
this.labelLanguage.Size = new System.Drawing.Size(55, 13);
this.labelLanguage.TabIndex = 8;
this.labelLanguage.Text = "Language";
//
// checkBoxWriteOutOneToTen
//
this.checkBoxWriteOutOneToTen.AutoSize = true;
this.checkBoxWriteOutOneToTen.Checked = true;
this.checkBoxWriteOutOneToTen.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxWriteOutOneToTen.Location = new System.Drawing.Point(409, 124);
this.checkBoxWriteOutOneToTen.Name = "checkBoxWriteOutOneToTen";
this.checkBoxWriteOutOneToTen.Size = new System.Drawing.Size(335, 17);
this.checkBoxWriteOutOneToTen.TabIndex = 17;
this.checkBoxWriteOutOneToTen.Text = "From 1 to 10, numbers should be written out: One, two, three, etc.";
this.checkBoxWriteOutOneToTen.UseVisualStyleBackColor = true;
this.checkBoxWriteOutOneToTen.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxSpellOutStartNumbers
//
this.checkBoxSpellOutStartNumbers.AutoSize = true;
this.checkBoxSpellOutStartNumbers.Checked = true;
this.checkBoxSpellOutStartNumbers.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxSpellOutStartNumbers.Location = new System.Drawing.Point(409, 101);
this.checkBoxSpellOutStartNumbers.Name = "checkBoxSpellOutStartNumbers";
this.checkBoxSpellOutStartNumbers.Size = new System.Drawing.Size(341, 17);
this.checkBoxSpellOutStartNumbers.TabIndex = 15;
this.checkBoxSpellOutStartNumbers.Text = "When a number begins a sentence, it should always be spelled out";
this.checkBoxSpellOutStartNumbers.UseVisualStyleBackColor = true;
this.checkBoxSpellOutStartNumbers.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxSquareBracketForHi
//
this.checkBoxSquareBracketForHi.AutoSize = true;
this.checkBoxSquareBracketForHi.Checked = true;
this.checkBoxSquareBracketForHi.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxSquareBracketForHi.Location = new System.Drawing.Point(409, 78);
this.checkBoxSquareBracketForHi.Name = "checkBoxSquareBracketForHi";
this.checkBoxSquareBracketForHi.Size = new System.Drawing.Size(286, 17);
this.checkBoxSquareBracketForHi.TabIndex = 11;
this.checkBoxSquareBracketForHi.Text = "Use brackets[] to enclose speaker IDs or sound effects";
this.checkBoxSquareBracketForHi.UseVisualStyleBackColor = true;
this.checkBoxSquareBracketForHi.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxDialogHypenNoSpace
//
this.checkBoxDialogHypenNoSpace.AutoSize = true;
this.checkBoxDialogHypenNoSpace.Checked = true;
this.checkBoxDialogHypenNoSpace.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxDialogHypenNoSpace.Location = new System.Drawing.Point(409, 54);
this.checkBoxDialogHypenNoSpace.Name = "checkBoxDialogHypenNoSpace";
this.checkBoxDialogHypenNoSpace.Size = new System.Drawing.Size(249, 17);
this.checkBoxDialogHypenNoSpace.TabIndex = 9;
this.checkBoxDialogHypenNoSpace.Text = " Dual Speakers: Use a hyphen without a space";
this.checkBoxDialogHypenNoSpace.UseVisualStyleBackColor = true;
this.checkBoxDialogHypenNoSpace.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxTwoLinesMax
//
this.checkBoxTwoLinesMax.AutoSize = true;
this.checkBoxTwoLinesMax.Checked = true;
this.checkBoxTwoLinesMax.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxTwoLinesMax.Location = new System.Drawing.Point(19, 147);
this.checkBoxTwoLinesMax.Name = "checkBoxTwoLinesMax";
this.checkBoxTwoLinesMax.Size = new System.Drawing.Size(117, 17);
this.checkBoxTwoLinesMax.TabIndex = 7;
this.checkBoxTwoLinesMax.Text = "Two lines maximum";
this.checkBoxTwoLinesMax.UseVisualStyleBackColor = true;
this.checkBoxTwoLinesMax.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxMinDuration
//
this.checkBoxMinDuration.AutoSize = true;
this.checkBoxMinDuration.Checked = true;
this.checkBoxMinDuration.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxMinDuration.Location = new System.Drawing.Point(19, 54);
this.checkBoxMinDuration.Name = "checkBoxMinDuration";
this.checkBoxMinDuration.Size = new System.Drawing.Size(212, 17);
this.checkBoxMinDuration.TabIndex = 1;
this.checkBoxMinDuration.Text = "Minimum duration: 5/6 second (833 ms)";
this.checkBoxMinDuration.UseVisualStyleBackColor = true;
this.checkBoxMinDuration.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// checkBoxMaxDuration
//
this.checkBoxMaxDuration.AutoSize = true;
this.checkBoxMaxDuration.Checked = true;
this.checkBoxMaxDuration.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxMaxDuration.Location = new System.Drawing.Point(19, 78);
this.checkBoxMaxDuration.Name = "checkBoxMaxDuration";
this.checkBoxMaxDuration.Size = new System.Drawing.Size(250, 17);
this.checkBoxMaxDuration.TabIndex = 3;
this.checkBoxMaxDuration.Text = "Maximum duration: 7 seconds per subtitle event";
this.checkBoxMaxDuration.UseVisualStyleBackColor = true;
this.checkBoxMaxDuration.CheckedChanged += new System.EventHandler(this.RuleCheckedChanged);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(953, 582);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 113;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(872, 582);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 112;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// labelTotal
//
this.labelTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelTotal.AutoSize = true;
this.labelTotal.Location = new System.Drawing.Point(12, 587);
this.labelTotal.Name = "labelTotal";
this.labelTotal.Size = new System.Drawing.Size(34, 13);
this.labelTotal.TabIndex = 115;
this.labelTotal.Text = "Total:";
//
// listViewFixes
//
this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewFixes.CheckBoxes = true;
this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader4,
this.columnHeader5,
this.columnHeader6,
this.columnHeader7,
this.columnHeader8});
this.listViewFixes.FullRowSelect = true;
this.listViewFixes.GridLines = true;
this.listViewFixes.HideSelection = false;
this.listViewFixes.Location = new System.Drawing.Point(12, 277);
this.listViewFixes.Name = "listViewFixes";
this.listViewFixes.Size = new System.Drawing.Size(1016, 291);
this.listViewFixes.TabIndex = 114;
this.listViewFixes.UseCompatibleStateImageBehavior = false;
this.listViewFixes.View = System.Windows.Forms.View.Details;
//
// columnHeader4
//
this.columnHeader4.Text = "Apply";
this.columnHeader4.Width = 38;
//
// columnHeader5
//
this.columnHeader5.Text = "Line#";
this.columnHeader5.Width = 50;
//
// columnHeader6
//
this.columnHeader6.Text = "Function";
this.columnHeader6.Width = 169;
//
// columnHeader7
//
this.columnHeader7.Text = "Before";
this.columnHeader7.Width = 340;
//
// columnHeader8
//
this.columnHeader8.Text = "After";
this.columnHeader8.Width = 318;
//
// NetflixFixErrors
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1040, 617);
this.Controls.Add(this.labelTotal);
this.Controls.Add(this.listViewFixes);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.groupBoxRules);
this.MinimumSize = new System.Drawing.Size(928, 505);
this.Name = "NetflixFixErrors";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "NetflixFixErrors";
this.groupBoxRules.ResumeLayout(false);
this.groupBoxRules.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.GroupBox groupBoxRules;
private System.Windows.Forms.CheckBox checkBoxGapMinTwoFrames;
private System.Windows.Forms.CheckBox checkBoxCheckValidGlyphs;
private System.Windows.Forms.CheckBox checkBox17CharsPerSecond;
private System.Windows.Forms.ComboBox comboBoxLanguage;
private System.Windows.Forms.Label labelLanguage;
private System.Windows.Forms.CheckBox checkBoxWriteOutOneToTen;
private System.Windows.Forms.CheckBox checkBoxSpellOutStartNumbers;
private System.Windows.Forms.CheckBox checkBoxSquareBracketForHi;
private System.Windows.Forms.CheckBox checkBoxDialogHypenNoSpace;
private System.Windows.Forms.CheckBox checkBoxTwoLinesMax;
private System.Windows.Forms.CheckBox checkBoxMinDuration;
private System.Windows.Forms.CheckBox checkBoxMaxDuration;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Label labelTotal;
private System.Windows.Forms.ListView listViewFixes;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.Windows.Forms.ColumnHeader columnHeader7;
private System.Windows.Forms.ColumnHeader columnHeader8;
private System.Windows.Forms.CheckBox checkBoxNoItalics;
private System.Windows.Forms.CheckBox checkBoxTtmlFrameRate;
private System.Windows.Forms.CheckBox checkBoxMaxLineLength;
private System.Windows.Forms.CheckBox checkBoxWhiteSpace;
}
}

View File

@ -0,0 +1,215 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.NetflixQualityCheck;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using static Nikse.SubtitleEdit.Forms.FixCommonErrors;
namespace Nikse.SubtitleEdit.Forms
{
public partial class NetflixFixErrors : Form
{
private readonly Subtitle _subtitle;
private readonly SubtitleFormat _subtitleFormat;
private readonly bool _loading;
private NetflixQualityController _netflixQualityController;
public NetflixFixErrors(Subtitle subtitle, SubtitleFormat subtitleFormat)
{
InitializeComponent();
_subtitle = subtitle;
_subtitleFormat = subtitleFormat;
_loading = true;
var language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle);
InitializeLanguages(language);
RefreshCheckBoxes(language);
_loading = false;
RuleCheckedChanged(null, null);
}
private void RefreshCheckBoxes(string language)
{
_netflixQualityController = new NetflixQualityController { Language = language };
checkBoxNoItalics.Checked = !_netflixQualityController.AllowItalics;
checkBoxNoItalics.Enabled = !_netflixQualityController.AllowItalics;
var checkFrameRate = _subtitleFormat.GetType() == new NetflixTimedText().GetType();
checkBoxTtmlFrameRate.Checked = checkFrameRate;
checkBoxTtmlFrameRate.Enabled = checkFrameRate;
checkBoxDialogHypenNoSpace.Checked = _netflixQualityController.DualSpeakersHasHyphenAndNoSpace;
checkBoxDialogHypenNoSpace.Enabled = _netflixQualityController.DualSpeakersHasHyphenAndNoSpace;
checkBox17CharsPerSecond.Text = string.Format("Maximum {0} characters per second (excl. white spaces)", _netflixQualityController.CharactersPerSecond);
checkBoxMaxLineLength.Text = string.Format("Maximum line length ({0})", _netflixQualityController.SingleLineMaxLength);
}
private void InitializeLanguages(string language)
{
comboBoxLanguage.BeginUpdate();
comboBoxLanguage.Items.Clear();
var ci = CultureInfo.GetCultureInfo(language);
foreach (var x in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
{
if (!string.IsNullOrWhiteSpace(x.ToString()) && !x.EnglishName.Contains("("))
{
comboBoxLanguage.Items.Add(new LanguageItem(x, x.EnglishName));
}
}
comboBoxLanguage.Sorted = true;
int languageIndex = 0;
int j = 0;
foreach (var x in comboBoxLanguage.Items)
{
var li = (LanguageItem)x;
if (li.Code.TwoLetterISOLanguageName == ci.TwoLetterISOLanguageName)
{
languageIndex = j;
break;
}
if (li.Code.TwoLetterISOLanguageName == "en")
{
languageIndex = j;
}
j++;
}
comboBoxLanguage.SelectedIndex = languageIndex;
comboBoxLanguage.SelectedIndexChanged += RuleCheckedChanged;
comboBoxLanguage.EndUpdate();
}
private void RuleCheckedChanged(object sender, EventArgs e)
{
if (_loading)
{
return;
}
_netflixQualityController.RunChecks(_subtitle, GetAllSelectedChecks());
listViewFixes.BeginUpdate();
listViewFixes.Items.Clear();
foreach (var record in _netflixQualityController.Records)
{
AddFixToListView(
record.OriginalParagraph,
record.Comment,
record.OriginalParagraph != null ? record.OriginalParagraph.ToString() : string.Empty,
record.FixedParagraph != null ? record.FixedParagraph.ToString() : string.Empty);
}
listViewFixes.EndUpdate();
}
private void AddFixToListView(Paragraph p, string action, string before, string after)
{
var item = new ListViewItem(string.Empty) { Checked = true, Tag = p };
item.SubItems.Add(p.Number.ToString());
item.SubItems.Add(action);
item.SubItems.Add(before.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString));
item.SubItems.Add(after.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString));
listViewFixes.Items.Add(item);
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void buttonOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private List<INetflixQualityChecker> GetAllSelectedChecks()
{
var list = new List<INetflixQualityChecker>();
if (checkBoxMinDuration.Checked)
{
list.Add(new NetflixCheckMinDuration());
}
if (checkBoxMaxDuration.Checked)
{
list.Add(new NetflixCheckMaxDuration());
}
if (checkBox17CharsPerSecond.Checked)
{
list.Add(new NetflixCheckMaxCps());
}
if (checkBoxGapMinTwoFrames.Checked)
{
list.Add(new NetflixCheckTwoFramesGap());
}
if (checkBoxTwoLinesMax.Checked)
{
list.Add(new NetflixCheckNumberOfLines());
}
if (checkBoxDialogHypenNoSpace.Checked)
{
list.Add(new NetflixCheckDialogHyphenSpace());
}
if (checkBoxSquareBracketForHi.Checked)
{
list.Add(new NetflixCheckTextForHiUseBrackets());
}
if (checkBoxSpellOutStartNumbers.Checked)
{
list.Add(new NetflixCheckStartNumberSpellOut());
}
if (checkBoxWriteOutOneToTen.Checked)
{
list.Add(new NetflixCheckNumbersOneToTenSpellOut());
}
if (checkBoxCheckValidGlyphs.Checked)
{
list.Add(new NetflixCheckGlyph());
}
if (checkBoxNoItalics.Checked)
{
list.Add(new NetflixCheckItalics());
}
if (checkBoxTtmlFrameRate.Checked)
{
list.Add(new NetflixCheckTimedTextFrameRate());
}
if (checkBoxMaxLineLength.Checked)
{
list.Add(new NetflixCheckMaxLineLength());
}
if (checkBoxWhiteSpace.Checked)
{
list.Add(new NetflixCheckWhiteSpace());
}
return list;
}
private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
if (_loading)
{
return;
}
var language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle);
InitializeLanguages(language);
RefreshCheckBoxes(language);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -57,7 +57,7 @@ namespace Nikse.SubtitleEdit.Forms
if (isAnyLinks)
{
buttonsPosMid = btnOpen.Left + ((btnOk.Left + btnOk.Width) - btnOpen.Left) / 2;
buttonsPosMid = btnOpen.Left + (btnOk.Left + btnOk.Width - btnOpen.Left) / 2;
}
else
{

View File

@ -218,6 +218,12 @@
<Compile Include="Forms\MultipleReplaceExportImport.Designer.cs">
<DependentUpon>MultipleReplaceExportImport.cs</DependentUpon>
</Compile>
<Compile Include="Forms\NetflixFixErrors.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\NetflixFixErrors.Designer.cs">
<DependentUpon>NetflixFixErrors.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Ocr\AddBeterMultiMatch.cs">
<SubType>Form</SubType>
</Compile>
@ -1145,6 +1151,9 @@
<EmbeddedResource Include="Forms\MultipleReplaceExportImport.resx">
<DependentUpon>MultipleReplaceExportImport.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\NetflixFixErrors.resx">
<DependentUpon>NetflixFixErrors.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Ocr\AddBeterMultiMatch.resx">
<DependentUpon>AddBeterMultiMatch.cs</DependentUpon>
</EmbeddedResource>

View File

@ -55,7 +55,7 @@ namespace Test.Logic
sub.Paragraphs.Add(p2);
var controller = new NetflixQualityController();
var checker = new NetflixCheckDialogeHyphenSpace();
var checker = new NetflixCheckDialogHyphenSpace();
checker.Check(sub, controller);
@ -73,7 +73,7 @@ namespace Test.Logic
sub.Paragraphs.Add(p2);
var controller = new NetflixQualityController();
var checker = new NetflixCheckDialogeHyphenSpace();
var checker = new NetflixCheckDialogHyphenSpace();
checker.Check(sub, controller);
@ -91,7 +91,7 @@ namespace Test.Logic
sub.Paragraphs.Add(p2);
var controller = new NetflixQualityController() { Language = "fr" };
var checker = new NetflixCheckDialogeHyphenSpace();
var checker = new NetflixCheckDialogHyphenSpace();
checker.Check(sub, controller);
@ -109,7 +109,7 @@ namespace Test.Logic
sub.Paragraphs.Add(p2);
var controller = new NetflixQualityController() { Language = "fr" };
var checker = new NetflixCheckDialogeHyphenSpace();
var checker = new NetflixCheckDialogHyphenSpace();
checker.Check(sub, controller);