mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Improve unknown json format parser- thx CB :)
This commit is contained in:
parent
f402c3c2dd
commit
9ee39eb029
@ -163,11 +163,19 @@ namespace Nikse.SubtitleEdit.Core.Common
|
|||||||
{
|
{
|
||||||
start = DecodeFormatToSeconds(start);
|
start = DecodeFormatToSeconds(start);
|
||||||
}
|
}
|
||||||
|
else if (start != null && start.Contains(":") && start.Length == 8 && start.Split(new[] { ':', ',', '.' }, StringSplitOptions.RemoveEmptyEntries).Length == 3)
|
||||||
|
{
|
||||||
|
start = DecodeFormatHourMinuteSecondsToSeconds(start);
|
||||||
|
}
|
||||||
|
|
||||||
if (end != null && end.Contains(":") && end.Length >= 11 && end.Length <= 12 && end.Split(new[] { ':', ',', '.' }, StringSplitOptions.RemoveEmptyEntries).Length == 4)
|
if (end != null && end.Contains(":") && end.Length >= 11 && end.Length <= 12 && end.Split(new[] { ':', ',', '.' }, StringSplitOptions.RemoveEmptyEntries).Length == 4)
|
||||||
{
|
{
|
||||||
end = DecodeFormatToSeconds(end);
|
end = DecodeFormatToSeconds(end);
|
||||||
}
|
}
|
||||||
|
else if (end != null && end.Contains(":") && end.Length == 8 && end.Split(new[] { ':', ',', '.' }, StringSplitOptions.RemoveEmptyEntries).Length == 3)
|
||||||
|
{
|
||||||
|
end = DecodeFormatHourMinuteSecondsToSeconds(end);
|
||||||
|
}
|
||||||
|
|
||||||
if (start != null && end != null && text != null)
|
if (start != null && end != null && text != null)
|
||||||
{
|
{
|
||||||
@ -199,11 +207,16 @@ namespace Nikse.SubtitleEdit.Core.Common
|
|||||||
return (ms / TimeCode.BaseUnit).ToString(CultureInfo.InvariantCulture);
|
return (ms / TimeCode.BaseUnit).ToString(CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string DecodeFormatHourMinuteSecondsToSeconds(string s)
|
||||||
|
{
|
||||||
|
return DecodeFormatToSeconds(s + ":00");
|
||||||
|
}
|
||||||
|
|
||||||
private static string ReadStartTag(string s)
|
private static string ReadStartTag(string s)
|
||||||
{
|
{
|
||||||
return ReadFirstMultiTag(s, new[]
|
return ReadFirstMultiTag(s, new[]
|
||||||
{
|
{
|
||||||
"start", "in",
|
"start", "in", "begin",
|
||||||
"startTime", "start_time", "starttime",
|
"startTime", "start_time", "starttime",
|
||||||
"startMillis", "start_Millis", "startmillis",
|
"startMillis", "start_Millis", "startmillis",
|
||||||
"startMs", "start_ms", "startms",
|
"startMs", "start_ms", "startms",
|
||||||
|
@ -140,19 +140,19 @@
|
|||||||
// deleteToolStripMenuItem
|
// deleteToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
|
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
|
||||||
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
|
||||||
this.deleteToolStripMenuItem.Text = "Delete";
|
this.deleteToolStripMenuItem.Text = "Delete";
|
||||||
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
|
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// toolStripSeparator2
|
// toolStripSeparator2
|
||||||
//
|
//
|
||||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||||
this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6);
|
this.toolStripSeparator2.Size = new System.Drawing.Size(168, 6);
|
||||||
//
|
//
|
||||||
// addFilesToolStripMenuItem
|
// addFilesToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.addFilesToolStripMenuItem.Name = "addFilesToolStripMenuItem";
|
this.addFilesToolStripMenuItem.Name = "addFilesToolStripMenuItem";
|
||||||
this.addFilesToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.addFilesToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
|
||||||
this.addFilesToolStripMenuItem.Text = "Add subtitle files...";
|
this.addFilesToolStripMenuItem.Text = "Add subtitle files...";
|
||||||
this.addFilesToolStripMenuItem.Click += new System.EventHandler(this.addFilesToolStripMenuItem_Click);
|
this.addFilesToolStripMenuItem.Click += new System.EventHandler(this.addFilesToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@ -168,31 +168,31 @@
|
|||||||
this.deleteToolStripMenuItem,
|
this.deleteToolStripMenuItem,
|
||||||
this.clearToolStripMenuItem});
|
this.clearToolStripMenuItem});
|
||||||
this.contextMenuStripBatch.Name = "contextMenuStripBatch";
|
this.contextMenuStripBatch.Name = "contextMenuStripBatch";
|
||||||
this.contextMenuStripBatch.Size = new System.Drawing.Size(181, 148);
|
this.contextMenuStripBatch.Size = new System.Drawing.Size(172, 126);
|
||||||
//
|
//
|
||||||
// toolStripSeparator1
|
// toolStripSeparator1
|
||||||
//
|
//
|
||||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
|
this.toolStripSeparator1.Size = new System.Drawing.Size(168, 6);
|
||||||
//
|
//
|
||||||
// pickVideoFileToolStripMenuItem
|
// pickVideoFileToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.pickVideoFileToolStripMenuItem.Name = "pickVideoFileToolStripMenuItem";
|
this.pickVideoFileToolStripMenuItem.Name = "pickVideoFileToolStripMenuItem";
|
||||||
this.pickVideoFileToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.pickVideoFileToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
|
||||||
this.pickVideoFileToolStripMenuItem.Text = "Pick video file...";
|
this.pickVideoFileToolStripMenuItem.Text = "Pick video file...";
|
||||||
this.pickVideoFileToolStripMenuItem.Click += new System.EventHandler(this.pickVideoFileToolStripMenuItem_Click);
|
this.pickVideoFileToolStripMenuItem.Click += new System.EventHandler(this.pickVideoFileToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// removeVideoFileToolStripMenuItem
|
// removeVideoFileToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.removeVideoFileToolStripMenuItem.Name = "removeVideoFileToolStripMenuItem";
|
this.removeVideoFileToolStripMenuItem.Name = "removeVideoFileToolStripMenuItem";
|
||||||
this.removeVideoFileToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.removeVideoFileToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
|
||||||
this.removeVideoFileToolStripMenuItem.Text = "Remove video file";
|
this.removeVideoFileToolStripMenuItem.Text = "Remove video file";
|
||||||
this.removeVideoFileToolStripMenuItem.Click += new System.EventHandler(this.removeVideoFileToolStripMenuItem_Click);
|
this.removeVideoFileToolStripMenuItem.Click += new System.EventHandler(this.removeVideoFileToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// clearToolStripMenuItem
|
// clearToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
|
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
|
||||||
this.clearToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.clearToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
|
||||||
this.clearToolStripMenuItem.Text = "Clear";
|
this.clearToolStripMenuItem.Text = "Clear";
|
||||||
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
|
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@ -1441,6 +1441,7 @@
|
|||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "GenerateTransparentVideoWithSubtitles";
|
this.Text = "GenerateTransparentVideoWithSubtitles";
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GenerateTransparentVideoWithSubtitles_FormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GenerateTransparentVideoWithSubtitles_FormClosing);
|
||||||
|
this.Shown += new System.EventHandler(this.GenerateTransparentVideoWithSubtitles_Shown);
|
||||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GenerateTransparentVideoWithSubtitles_KeyDown);
|
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GenerateTransparentVideoWithSubtitles_KeyDown);
|
||||||
this.contextMenuStripBatch.ResumeLayout(false);
|
this.contextMenuStripBatch.ResumeLayout(false);
|
||||||
this.contextMenuStripRes.ResumeLayout(false);
|
this.contextMenuStripRes.ResumeLayout(false);
|
||||||
|
@ -3,7 +3,6 @@ using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
|||||||
using Nikse.SubtitleEdit.Logic;
|
using Nikse.SubtitleEdit.Logic;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@ -116,12 +115,6 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
checkBoxAlignRight.Checked = Configuration.Settings.Tools.GenVideoNonAssaAlignRight;
|
checkBoxAlignRight.Checked = Configuration.Settings.Tools.GenVideoNonAssaAlignRight;
|
||||||
checkBoxRightToLeft.Checked = Configuration.Settings.Tools.GenVideoNonAssaAlignRight;
|
checkBoxRightToLeft.Checked = Configuration.Settings.Tools.GenVideoNonAssaAlignRight;
|
||||||
|
|
||||||
if (_videoInfo != null)
|
|
||||||
{
|
|
||||||
numericUpDownWidth.Value = _videoInfo.Width;
|
|
||||||
numericUpDownHeight.Value = _videoInfo.Height;
|
|
||||||
}
|
|
||||||
|
|
||||||
var left = Math.Max(Math.Max(labelResolution.Left + labelResolution.Width, labelFontSize.Left + labelFontSize.Width), labelSubtitleFont.Left + labelSubtitleFont.Width) + 5;
|
var left = Math.Max(Math.Max(labelResolution.Left + labelResolution.Width, labelFontSize.Left + labelFontSize.Width), labelSubtitleFont.Left + labelSubtitleFont.Width) + 5;
|
||||||
numericUpDownFontSize.Left = left;
|
numericUpDownFontSize.Left = left;
|
||||||
comboBoxSubtitleFont.Left = left;
|
comboBoxSubtitleFont.Left = left;
|
||||||
@ -1720,6 +1713,19 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
_batchItems[i].Height = 0;
|
_batchItems[i].Height = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GenerateTransparentVideoWithSubtitles_Shown(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(_inputVideoFileName))
|
||||||
|
{
|
||||||
|
var mediaInfo = FfmpegMediaInfo.Parse(_inputVideoFileName);
|
||||||
|
if (mediaInfo.Dimension.IsValid())
|
||||||
|
{
|
||||||
|
numericUpDownWidth.Value = mediaInfo.Dimension.Width;
|
||||||
|
numericUpDownHeight.Value = mediaInfo.Dimension.Height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user