Improve err handling a little

This commit is contained in:
Nikolaj Olsson 2023-12-16 12:00:46 +01:00
parent 09770e74a9
commit 284592b1e9
3 changed files with 48 additions and 12 deletions

View File

@ -3,7 +3,7 @@
4.0.3 (xth December 2023) BETA 4.0.3 (xth December 2023) BETA
* NEW: * NEW:
* Add ".opus" audio file extension - thx vivadavid * Add ".opus" / ".adts" audio file extensions - thx vivadavid/Lyubomir71
* Add two TSV subtitle formats - thx Purfview * Add two TSV subtitle formats - thx Purfview
* Add Arabic translation - thx Yahya * Add Arabic translation - thx Yahya
* Add new json subtitle format - thx Lucretia * Add new json subtitle format - thx Lucretia
@ -27,6 +27,8 @@
* Re-add Whisper Const-me large model v2 * Re-add Whisper Const-me large model v2
* Audio-to-text: Improve error msg if no write access to video source folder * Audio-to-text: Improve error msg if no write access to video source folder
* Add delay in seconds to translate via ChatGPT * Add delay in seconds to translate via ChatGPT
* Toggle music symbols, now toggles via first text - thx Leon
* Use source video folder when saving hard-sub video - thx Leon
* FIXED: * FIXED:
* Fix for BDSUP cmd line convert - thx Jack1789 * Fix for BDSUP cmd line convert - thx Jack1789
* Do not count HTML tags in SCC in save/load - thx cs127 * Do not count HTML tags in SCC in save/load - thx cs127

View File

@ -0,0 +1,7 @@
<NoBreakAfterList>
<Item>Dr</Item>
<Item>Dr.</Item>
<Item>Mr.</Item>
<Item>Mrs.</Item>
<Item>Ms.</Item>
</NoBreakAfterList>

View File

@ -1,9 +1,9 @@
using Nikse.SubtitleEdit.Core.Common; using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.Forms;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic;
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using Nikse.SubtitleEdit.Core.Forms;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
{ {
@ -18,7 +18,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
UiUtil.PreInitialize(this); UiUtil.PreInitialize(this);
InitializeComponent(); InitializeComponent();
UiUtil.FixFonts(this); UiUtil.FixFonts(this);
var language = LanguageSettings.Current.BeautifyTimeCodesProfile; var language = LanguageSettings.Current.BeautifyTimeCodesProfile;
Text = language.CreateSimpleTitle; Text = language.CreateSimpleTitle;
labelInstructions.Text = language.CreateSimpleInstruction; labelInstructions.Text = language.CreateSimpleInstruction;
@ -84,9 +84,18 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
DialogResult = DialogResult.None; DialogResult = DialogResult.None;
return; return;
} }
// Save settings // Save settings
var gap = Convert.ToInt32(numericUpDownGap.Value); int gap;
try
{
gap = Convert.ToInt32(numericUpDownGap.Value);
}
catch (Exception exception)
{
throw new Exception($"Unable to set gap from numericUpDownGap.Value to Int32: numericUpDownGap.Value = '{numericUpDownGap.Value}'", exception);
}
var inCuesGap = comboBoxInCues.SelectedIndex; var inCuesGap = comboBoxInCues.SelectedIndex;
var outCuesGap = comboBoxOutCues.SelectedIndex; var outCuesGap = comboBoxOutCues.SelectedIndex;
if (comboBoxOutCues.SelectedIndex == comboBoxOutCues.Items.Count - 1) if (comboBoxOutCues.SelectedIndex == comboBoxOutCues.Items.Count - 1)
@ -94,10 +103,28 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
outCuesGap = gap; outCuesGap = gap;
} }
var redZone = Convert.ToInt32(numericUpDownOffset.Value); int redZone;
var greenZone = Convert.ToInt32(numericUpDownSafeZone.Value); try
{
redZone = Convert.ToInt32(numericUpDownOffset.Value);
}
catch (Exception exception)
{
throw new Exception($"Unable to set redZone from numericUpDownOffset.Value to Int32: numericUpDownOffset.Value = '{numericUpDownOffset.Value}'", exception);
}
Configuration.Settings.BeautifyTimeCodes.Profile.Gap = Convert.ToInt32(numericUpDownGap.Value); int greenZone;
try
{
greenZone = Convert.ToInt32(numericUpDownSafeZone.Value);
}
catch (Exception exception)
{
throw new Exception($"Unable to set greenZone from numericUpDownSafeZone.Value to Int32: numericUpDownSafeZone.Value = '{numericUpDownSafeZone.Value}'", exception);
}
Configuration.Settings.BeautifyTimeCodes.Profile.Gap = gap;
Configuration.Settings.BeautifyTimeCodes.Profile.InCuesGap = inCuesGap; Configuration.Settings.BeautifyTimeCodes.Profile.InCuesGap = inCuesGap;
Configuration.Settings.BeautifyTimeCodes.Profile.InCuesLeftGreenZone = greenZone; Configuration.Settings.BeautifyTimeCodes.Profile.InCuesLeftGreenZone = greenZone;
@ -132,7 +159,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: Gap is " + gap); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: Gap is " + gap);
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: FrameRate is " + _frameRate); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: FrameRate is " + _frameRate);
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: treadConnectedMs is " + treadConnectedMs); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: treadConnectedMs is " + treadConnectedMs);
throw; throw new Exception($"Unable to calculate treadConnectedMs from gap '{gap}' and frame rate {_frameRate}", exception);
} }
try try
@ -145,7 +172,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: Gap is " + gap); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: Gap is " + gap);
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: FrameRate is " + _frameRate); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: FrameRate is " + _frameRate);
SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: treadConnectedMs is " + treadConnectedMs); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: treadConnectedMs is " + treadConnectedMs);
throw; throw new Exception($"Unable to set ConnectedSubtitlesTreatConnected from treadConnectedMs '{treadConnectedMs}'", exception);
} }
Configuration.Settings.BeautifyTimeCodes.Profile.ChainingGeneralUseZones = false; Configuration.Settings.BeautifyTimeCodes.Profile.ChainingGeneralUseZones = false;
@ -175,7 +202,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
private void numericUpDownGap_ValueChanged(object sender, EventArgs e) private void numericUpDownGap_ValueChanged(object sender, EventArgs e)
{ {
int gapFrames = Convert.ToInt32(numericUpDownGap.Value); var gapFrames = Convert.ToInt32(numericUpDownGap.Value);
double gapMs = SubtitleFormat.FramesToMilliseconds(gapFrames, _frameRate); double gapMs = SubtitleFormat.FramesToMilliseconds(gapFrames, _frameRate);
labelGapHint.Text = string.Format(LanguageSettings.Current.BeautifyTimeCodesProfile.GapInMsFormat, Math.Round(gapMs), Math.Round(_frameRate, 3)); labelGapHint.Text = string.Format(LanguageSettings.Current.BeautifyTimeCodesProfile.GapInMsFormat, Math.Round(gapMs), Math.Round(_frameRate, 3));