mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Cleanup + Move DecodeTimeCode to SubtitleFormat part 2
This commit is contained in:
parent
cf6607a18a
commit
b230695b0c
@ -137,16 +137,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class Csv2 : SubtitleFormat
|
||||
{
|
||||
|
||||
private const string Separator = ",";
|
||||
|
||||
//1,01:00:10:03,01:00:15:25,I thought I should let my sister-in-law know.
|
||||
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class Csv3 : SubtitleFormat
|
||||
{
|
||||
|
||||
private const string Separator = ",";
|
||||
|
||||
//01:00:10:03,01:00:15:25,"I thought I should let my sister-in-law know.", ""
|
||||
@ -94,6 +93,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
char[] splitChars = { '.', ':' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
Match m = CsvLine.Match(line);
|
||||
@ -103,8 +103,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
if (parts.Length == 2)
|
||||
try
|
||||
{
|
||||
var start = DecodeTimeCode(parts[0]);
|
||||
var end = DecodeTimeCode(parts[1]);
|
||||
var start = DecodeTimeCode(parts[0], splitChars);
|
||||
var end = DecodeTimeCode(parts[1], splitChars);
|
||||
string text = ReadText(line.Remove(0, m.Length));
|
||||
var p = new Paragraph(start, end, text);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
@ -177,18 +177,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string part)
|
||||
{
|
||||
string[] parts = part.Split(new[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -84,15 +84,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return string.Format("{0:00} {1:00} {2:00} {3:00}", time.Hours, time.Minutes, time.Seconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -97,18 +97,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
TimeCode tc = new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
return tc;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -145,4 +145,4 @@ LICENSE=
|
||||
subtitle.Renumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -89,16 +89,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string msDiv10 = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(msDiv10)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -113,15 +113,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -51,4 +51,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -91,16 +91,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -129,6 +129,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var xml = new XmlDocument { XmlResolver = null };
|
||||
xml.LoadXml(sb.ToString().Trim());
|
||||
string lastKey = string.Empty;
|
||||
char[] splitChar = { ':' };
|
||||
foreach (XmlNode node in xml.DocumentElement.SelectNodes("subtitle"))
|
||||
{
|
||||
try
|
||||
@ -142,10 +143,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
p.Text = innerNode.InnerText.Replace("\\N", Environment.NewLine);
|
||||
break;
|
||||
case "in":
|
||||
p.StartTime = DecodeTime(innerNode.InnerText);
|
||||
p.StartTime = DecodeTimeCode(innerNode.InnerText, splitChar);
|
||||
break;
|
||||
case "out":
|
||||
p.EndTime = DecodeTime(innerNode.InnerText);
|
||||
p.EndTime = DecodeTimeCode(innerNode.InnerText, splitChar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -160,16 +161,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTime(string s)
|
||||
{
|
||||
var arr = s.Split(':');
|
||||
if (arr.Length == 4)
|
||||
{
|
||||
return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), FramesToMillisecondsMax999(int.Parse(arr[3])));
|
||||
}
|
||||
return new TimeCode(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -61,12 +61,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return sb.ToString().ToRtf();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timeCode)
|
||||
{
|
||||
string[] arr = timeCode.Split(new[] { ':', ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), FramesToMillisecondsMax999(int.Parse(arr[3])));
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
@ -81,6 +75,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
lines = rtf.FromRtf().SplitToLines().ToList();
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
char[] splitChars = { ':', ';', ',' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.TrimEnd();
|
||||
@ -92,9 +87,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Paragraphs.Add(p);
|
||||
string[] arr = s.Split('\t');
|
||||
if (arr.Length > 2)
|
||||
p = new Paragraph(DecodeTimeCode(arr[1]), new TimeCode(0, 0, 0, 0), arr[2].Trim());
|
||||
p = new Paragraph(DecodeTimeCode(arr[1], splitChars), new TimeCode(0, 0, 0, 0), arr[2].Trim());
|
||||
else
|
||||
p = new Paragraph(DecodeTimeCode(arr[1]), new TimeCode(0, 0, 0, 0), string.Empty);
|
||||
p = new Paragraph(DecodeTimeCode(arr[1], splitChars), new TimeCode(0, 0, 0, 0), string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class IssXml : SubtitleFormat
|
||||
{
|
||||
|
||||
private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); //00:02:56:02
|
||||
|
||||
public override string Extension
|
||||
|
@ -226,4 +226,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class MacCaption : SubtitleFormat
|
||||
{
|
||||
|
||||
private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d\t", RegexOptions.Compiled);
|
||||
|
||||
public override string Extension
|
||||
@ -105,13 +104,14 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
var header = new StringBuilder();
|
||||
char[] splitChars = { ':', ';', ',' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim();
|
||||
|
||||
if (s.StartsWith("//") || s.StartsWith("File Format=MacCaption_MCC") || s.StartsWith("UUID=") ||
|
||||
if (s.StartsWith("//", StringComparison.Ordinal) || s.StartsWith("File Format=MacCaption_MCC", StringComparison.Ordinal) || s.StartsWith("UUID=", StringComparison.Ordinal) ||
|
||||
s.StartsWith("Creation Program=") || s.StartsWith("Creation Date=") || s.StartsWith("Creation Time=") ||
|
||||
s.StartsWith("Code Rate=") || s.StartsWith("Time Code Rate=") || string.IsNullOrEmpty(s))
|
||||
s.StartsWith("Code Rate=", StringComparison.Ordinal) || s.StartsWith("Time Code Rate=", StringComparison.Ordinal) || string.IsNullOrEmpty(s))
|
||||
{
|
||||
header.AppendLine(line);
|
||||
}
|
||||
@ -120,7 +120,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var match = RegexTimeCodes.Match(s);
|
||||
if (match.Success)
|
||||
{
|
||||
TimeCode startTime = ParseTimeCode(s.Substring(0, match.Length - 1));
|
||||
TimeCode startTime = DecodeTimeCode(s.Substring(0, match.Length - 1), splitChars);
|
||||
string text = GetSccText(s.Substring(match.Index));
|
||||
|
||||
if (text == "942c 942c" || text == "942c")
|
||||
@ -213,16 +213,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return list;
|
||||
}
|
||||
|
||||
private static TimeCode ParseTimeCode(string start)
|
||||
{
|
||||
string[] arr = start.Split(new[] { ':', ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
int milliseconds = (int)((1000 / Configuration.Settings.General.CurrentFrameRate) * int.Parse(arr[3]));
|
||||
if (milliseconds > 999)
|
||||
milliseconds = 999;
|
||||
|
||||
return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), milliseconds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -99,20 +99,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
|
||||
int milliseconds = (int)((1000 / Configuration.Settings.General.CurrentFrameRate) * frames);
|
||||
if (milliseconds > 999)
|
||||
milliseconds = 999;
|
||||
|
||||
return new TimeCode(hour, minutes, seconds, milliseconds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -148,15 +148,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return time.ToHHMMSSFF();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -95,16 +95,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -228,16 +228,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -132,16 +132,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -358,9 +358,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
public static int FramesToMillisecondsMax999(double frames)
|
||||
{
|
||||
int ms = (int)Math.Round(frames * (TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate));
|
||||
if (ms > 999)
|
||||
ms = 999;
|
||||
return ms;
|
||||
return Math.Min(ms, 999);
|
||||
}
|
||||
|
||||
public virtual bool HasStyleSupport
|
||||
@ -398,16 +396,39 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
|
||||
protected static TimeCode DecodeTimeCode(string[] parts)
|
||||
protected static TimeCode DecodeTimeCode(string[] parts, bool msToMaxFrame = false)
|
||||
{
|
||||
if (parts == null || parts.Length < 4)
|
||||
return null;
|
||||
if (parts == null)
|
||||
return new TimeCode(0, 0, 0, 0);
|
||||
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
int hour = 0;
|
||||
int minutes = 0;
|
||||
int seconds = 0;
|
||||
int millisecondsFrames = 0;
|
||||
|
||||
if (parts.Length == 4)
|
||||
{
|
||||
hour = int.Parse(parts[0]);
|
||||
minutes = int.Parse(parts[1]);
|
||||
seconds = int.Parse(parts[2]);
|
||||
millisecondsFrames = int.Parse(parts[3]);
|
||||
}
|
||||
else if (parts.Length == 3)
|
||||
{
|
||||
minutes = int.Parse(parts[0]);
|
||||
seconds = int.Parse(parts[1]);
|
||||
millisecondsFrames = int.Parse(parts[2]);
|
||||
}
|
||||
else if (parts.Length == 2)
|
||||
{
|
||||
seconds = int.Parse(parts[0]);
|
||||
millisecondsFrames = int.Parse(parts[1]);
|
||||
}
|
||||
|
||||
if (!msToMaxFrame)
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(millisecondsFrames));
|
||||
|
||||
return new TimeCode(hour, minutes, seconds, MillisecondsToFramesMaxFrameRate(millisecondsFrames));
|
||||
}
|
||||
|
||||
protected static TimeCode DecodeTimeCode(string part, char[] splitChars)
|
||||
@ -415,4 +436,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return DecodeTimeCode(part.Split(splitChars, StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -156,4 +156,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
|
||||
public class TMPlayer : SubtitleFormat
|
||||
{
|
||||
private static readonly Regex regex = new Regex(@"^\d+:\d\d:\d\d[: ].*$", RegexOptions.Compiled); // accept a " " instead of the last ":" too
|
||||
|
@ -107,4 +107,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -117,9 +117,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
string seconds = parts[2];
|
||||
string ms = parts[3];
|
||||
|
||||
TimeCode tc = new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), (int.Parse(ms)));
|
||||
return tc;
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), (int.Parse(ms)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
{
|
||||
public class TimedText200604CData : TimedText200604
|
||||
{
|
||||
|
||||
public TimedText200604CData()
|
||||
{
|
||||
UseCDataForParagraphText = true;
|
||||
@ -14,4 +13,4 @@
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -190,15 +190,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return list;
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
int hours = int.Parse(parts[0]);
|
||||
int minutes = int.Parse(parts[1]);
|
||||
int seconds = int.Parse(parts[2]);
|
||||
int frames = int.Parse(parts[3]);
|
||||
return new TimeCode(hours, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
private Encoding GetEncodingFromLanguage(byte language)
|
||||
{
|
||||
if (language == 179) // Russian
|
||||
|
@ -123,17 +123,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
TimeCode tc = new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
return tc;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
//* 1 : 01:01:31:19 01:01:33:04 22c
|
||||
private static readonly Regex RegexTimeCodes = new Regex(@"^\* \d+ :\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t\d+c", RegexOptions.Compiled);
|
||||
private int _maxMsDiv10;
|
||||
|
||||
public override string Extension
|
||||
{
|
||||
@ -80,9 +79,9 @@ ATTENTION : Pas plus de 40 caractères PAR LIGNE
|
||||
//00:03:15:22 00:03:23:10 This is line one.
|
||||
//This is line two.
|
||||
Paragraph p = null;
|
||||
_maxMsDiv10 = 0;
|
||||
_errorCount = 0;
|
||||
subtitle.Paragraphs.Clear();
|
||||
char[] splitChar = { ':' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (RegexTimeCodes.IsMatch(line))
|
||||
@ -93,8 +92,8 @@ ATTENTION : Pas plus de 40 caractères PAR LIGNE
|
||||
string start = arr[1];
|
||||
string end = arr[2];
|
||||
|
||||
string[] startParts = start.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] endParts = end.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] startParts = start.Split(splitChar, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] endParts = end.Split(splitChar, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (startParts.Length == 4 && endParts.Length == 4)
|
||||
{
|
||||
p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), string.Empty);
|
||||
@ -126,19 +125,5 @@ ATTENTION : Pas plus de 40 caractères PAR LIGNE
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
|
||||
if (frames > _maxMsDiv10)
|
||||
_maxMsDiv10 = frames;
|
||||
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -104,4 +104,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -124,4 +124,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -113,4 +113,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -178,20 +178,5 @@ DIGITAL_CINEMA=YES
|
||||
{
|
||||
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
var milliseconds = (int)((TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate) * int.Parse(frames));
|
||||
if (milliseconds > 999)
|
||||
milliseconds = 999;
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), milliseconds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -80,16 +80,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timeCode)
|
||||
{
|
||||
string[] arr = timeCode.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), FramesToMillisecondsMax999(int.Parse(arr[3])));
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
char[] splitChar = { ':' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.TrimEnd();
|
||||
@ -99,7 +94,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
if (p != null)
|
||||
subtitle.Paragraphs.Add(p);
|
||||
p = new Paragraph(DecodeTimeCode(s.Substring(5, 11)), new TimeCode(0, 0, 0, 0), s.Remove(0, 37).Trim());
|
||||
p = new Paragraph(DecodeTimeCode(s.Substring(5, 11), splitChar), new TimeCode(0, 0, 0, 0), s.Remove(0, 37).Trim());
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -113,7 +108,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
if (p != null)
|
||||
subtitle.Paragraphs.Add(p);
|
||||
p = new Paragraph(DecodeTimeCode(s.Substring(5, 11)), new TimeCode(0, 0, 0, 0), string.Empty);
|
||||
p = new Paragraph(DecodeTimeCode(s.Substring(5, 11), splitChar), new TimeCode(0, 0, 0, 0), string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -127,7 +122,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
if (p != null)
|
||||
{
|
||||
p.EndTime = DecodeTimeCode(s.Substring(5, 11));
|
||||
p.EndTime = DecodeTimeCode(s.Substring(5, 11), splitChar);
|
||||
if (string.IsNullOrWhiteSpace(p.Text))
|
||||
p.Text = s.Remove(0, 37).Trim();
|
||||
else
|
||||
|
@ -61,12 +61,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return sb.ToString().ToRtf();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timeCode)
|
||||
{
|
||||
string[] arr = timeCode.Split(new[] { ':', ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), FramesToMillisecondsMax999(int.Parse(arr[3])));
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
@ -82,6 +76,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
lines = rtf.FromRtf().SplitToLines().ToList();
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
char[] splitChar = { ':', ';', ',' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.TrimEnd();
|
||||
@ -93,9 +88,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Paragraphs.Add(p);
|
||||
string[] arr = s.Split('\t');
|
||||
if (arr.Length > 2)
|
||||
p = new Paragraph(DecodeTimeCode(arr[1]), new TimeCode(0, 0, 0, 0), arr[2].Trim());
|
||||
p = new Paragraph(DecodeTimeCode(arr[1], splitChar), new TimeCode(0, 0, 0, 0), arr[2].Trim());
|
||||
else
|
||||
p = new Paragraph(DecodeTimeCode(arr[1]), new TimeCode(0, 0, 0, 0), string.Empty);
|
||||
p = new Paragraph(DecodeTimeCode(arr[1], splitChar), new TimeCode(0, 0, 0, 0), string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -103,7 +98,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
p = null;
|
||||
}
|
||||
}
|
||||
else if (s.StartsWith("\t\t"))
|
||||
else if (s.StartsWith("\t\t", StringComparison.Ordinal))
|
||||
{
|
||||
if (p != null)
|
||||
p.Text = p.Text + Environment.NewLine + s.Trim();
|
||||
@ -132,4 +127,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -70,17 +70,12 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timeCode)
|
||||
{
|
||||
string[] arr = timeCode.Split(new[] { ':', ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), FramesToMillisecondsMax999(int.Parse(arr[3])));
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
var sb = new StringBuilder();
|
||||
char[] splitChars = { ':', ';', ',' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.TrimEnd();
|
||||
@ -96,7 +91,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
sb = new StringBuilder();
|
||||
string[] arr = s.Split('\t');
|
||||
if (arr.Length == 4)
|
||||
p = new Paragraph(DecodeTimeCode(arr[1]), DecodeTimeCode(arr[3]), string.Empty);
|
||||
{
|
||||
p = new Paragraph(DecodeTimeCode(arr[1], splitChars), DecodeTimeCode(arr[3], splitChars), string.Empty);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
sb.AppendLine(line);
|
||||
|
||||
string rtf = sb.ToString().Trim();
|
||||
if (!rtf.StartsWith("{\\rtf"))
|
||||
if (!rtf.StartsWith("{\\rtf", StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
lines = rtf.FromRtf().SplitToLines().ToList();
|
||||
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle25 : SubtitleFormat
|
||||
{
|
||||
|
||||
//79.29 1.63
|
||||
private static readonly Regex RegexTimeCode1 = new Regex(@"^\d+.[0-9]{1,2} \d+.[0-9]{1,2}$", RegexOptions.Compiled);
|
||||
private static readonly Regex RegexTimeCode2 = new Regex(@"^\d+ \d+.[0-9]{1,2}$", RegexOptions.Compiled);
|
||||
@ -105,8 +104,8 @@ NOTE=
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
if (subtitle.Paragraphs.Count == 0 && (s.StartsWith("TITLE=") || s.StartsWith("TITLE=") || s.StartsWith("FILE=") || s.StartsWith("AUTHOR=") ||
|
||||
s.StartsWith("TYPE=VIDEO") || s.StartsWith("FORMAT=") || s.StartsWith("NOTE=")))
|
||||
if (subtitle.Paragraphs.Count == 0 && (s.StartsWith("TITLE=", StringComparison.Ordinal) || s.StartsWith("TITLE=", StringComparison.Ordinal) || s.StartsWith("FILE=", StringComparison.Ordinal) || s.StartsWith("AUTHOR=", StringComparison.Ordinal) ||
|
||||
s.StartsWith("TYPE=VIDEO") || s.StartsWith("FORMAT=", StringComparison.Ordinal) || s.StartsWith("NOTE=", StringComparison.Ordinal)))
|
||||
{
|
||||
}
|
||||
else
|
||||
@ -125,4 +124,4 @@ NOTE=
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -124,8 +124,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
|
||||
TimeCode tc = new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), 0);
|
||||
return tc;
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -123,8 +123,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
private static double ParseTimeCode(string start)
|
||||
{
|
||||
string[] arr = start.Split(new[] { ':', ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var ts = new TimeSpan(0, int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]));
|
||||
return ts.TotalMilliseconds;
|
||||
return new TimeSpan(0, int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3])).TotalMilliseconds;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,17 +56,12 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timeCode)
|
||||
{
|
||||
string[] arr = timeCode.Split(new[] { ':', ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), FramesToMillisecondsMax999(int.Parse(arr[3])));
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
var sb = new StringBuilder();
|
||||
char[] splitChars = { ':', ';', ',' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.TrimEnd();
|
||||
@ -82,7 +77,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
sb = new StringBuilder();
|
||||
string[] arr = s.Split('\t');
|
||||
if (arr.Length == 2)
|
||||
p = new Paragraph(DecodeTimeCode(arr[0]), DecodeTimeCode(arr[1]), string.Empty);
|
||||
p = new Paragraph(DecodeTimeCode(arr[0], splitChars), DecodeTimeCode(arr[1], splitChars), string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -87,4 +87,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -157,15 +157,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -149,13 +149,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return string.Format("{0:00}.{1:00}", (int)time.TotalSeconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
string seconds = parts[0];
|
||||
string frames = parts[1];
|
||||
|
||||
return new TimeCode(0, 0, int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -84,6 +84,7 @@ Sony,Sony DVD/UMD,1:85,16x9
|
||||
_errorCount = 0;
|
||||
|
||||
subtitle.Paragraphs.Clear();
|
||||
char[] splitChars = { ':', ';', ',', '.' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim();
|
||||
@ -97,8 +98,8 @@ Sony,Sony DVD/UMD,1:85,16x9
|
||||
paragraph = new Paragraph();
|
||||
try
|
||||
{
|
||||
paragraph.StartTime = DecodeTimeCode(parts[1]);
|
||||
paragraph.EndTime = DecodeTimeCode(parts[2]);
|
||||
paragraph.StartTime = DecodeTimeCode(parts[1], splitChars);
|
||||
paragraph.EndTime = DecodeTimeCode(parts[2], splitChars);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -151,11 +152,5 @@ Sony,Sony DVD/UMD,1:85,16x9
|
||||
return string.Format("{0:00}:{1:00}:{2:00}.{3:00}", time.Hours, time.Minutes, time.Seconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timeCode)
|
||||
{
|
||||
string[] arr = timeCode.Split(new[] { ':', ';', ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), FramesToMillisecondsMax999(int.Parse(arr[3])));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -56,17 +56,12 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timeCode)
|
||||
{
|
||||
string[] arr = timeCode.Split(new[] { ':', ';', ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new TimeCode(0, 0, int.Parse(arr[0]), FramesToMillisecondsMax999(int.Parse(arr[1])));
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
var sb = new StringBuilder();
|
||||
char[] splitChars = { ':', ';', ',', '.' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim();
|
||||
@ -82,7 +77,20 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
sb = new StringBuilder();
|
||||
string[] arr = s.Split('-');
|
||||
if (arr.Length == 2)
|
||||
p = new Paragraph(DecodeTimeCode(arr[0]), DecodeTimeCode(arr[1]), string.Empty);
|
||||
{
|
||||
var parts1 = arr[0].Split(splitChars);
|
||||
var parts2 = arr[1].Split(splitChars);
|
||||
|
||||
// parts1/2 most have length of 2
|
||||
if (parts1.Length + parts2.Length == 4)
|
||||
{
|
||||
p = new Paragraph(DecodeTimeCode(parts1), DecodeTimeCode(parts2), string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = new Paragraph(DecodeTimeCode(new[] { parts1[0], parts1[1] }), DecodeTimeCode(new[] { parts2[0], parts2[1] }), string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -53,4 +53,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -140,4 +140,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -101,4 +101,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -119,4 +119,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -125,4 +125,4 @@ ST 0 EB 3.10
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -98,4 +98,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -154,14 +154,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return string.Format("{0:00} {1:00} {2:00} {3:00} ", time.Hours, time.Minutes, time.Seconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
|
||||
public class UnknownSubtitle51 : SubtitleFormat
|
||||
{
|
||||
private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d+:\d+:\d+ , \d+:\d+:\d+:\d+ , .*$", RegexOptions.Compiled);
|
||||
@ -108,4 +107,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
|
||||
public class UnknownSubtitle52 : SubtitleFormat
|
||||
{
|
||||
//#00001 10:00:02.00 10:00:04.13 00:00:02.13 #F CC00000D0 #C
|
||||
@ -96,6 +95,7 @@ FILE_INFO_END";
|
||||
bool started = false;
|
||||
var header = new StringBuilder();
|
||||
var text = new StringBuilder();
|
||||
char[] splitChar = { ':', ',', '.' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
try
|
||||
@ -108,7 +108,7 @@ FILE_INFO_END";
|
||||
text = new StringBuilder();
|
||||
string start = line.Substring(7, 11);
|
||||
string end = line.Substring(19, 11);
|
||||
p = new Paragraph(GetTimeCode(start), GetTimeCode(end), string.Empty);
|
||||
p = new Paragraph(DecodeTimeCode(start, splitChar), DecodeTimeCode(end, splitChar), string.Empty);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
else if (!started)
|
||||
@ -136,13 +136,5 @@ FILE_INFO_END";
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode GetTimeCode(string timeString)
|
||||
{
|
||||
string[] timeParts = timeString.Split(new[] { ':', ',', '.' });
|
||||
int milliseconds = FramesToMillisecondsMax999(int.Parse(timeParts[3]));
|
||||
var timeCode = new TimeCode(int.Parse(timeParts[0]), int.Parse(timeParts[1]), int.Parse(timeParts[2]), milliseconds);
|
||||
return timeCode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -135,16 +135,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -74,6 +74,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
bool expectStartTime = true;
|
||||
var p = new Paragraph();
|
||||
subtitle.Paragraphs.Clear();
|
||||
char[] splitChars = { '.', ':' };
|
||||
foreach (string line in arr)
|
||||
{
|
||||
string s = line.Trim().Replace("*", string.Empty);
|
||||
@ -90,8 +91,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Paragraphs.Add(p);
|
||||
p = new Paragraph();
|
||||
}
|
||||
p.StartTime = DecodeTimeCode(parts[1]);
|
||||
p.EndTime = DecodeTimeCode(parts[2]);
|
||||
p.StartTime = DecodeTimeCode(parts[1], splitChars);
|
||||
p.EndTime = DecodeTimeCode(parts[2], splitChars);
|
||||
expectStartTime = false;
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -128,18 +129,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string part)
|
||||
{
|
||||
string[] parts = part.Split(new[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -134,4 +134,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -92,16 +92,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -68,6 +68,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
string[] arr = rtf.FromRtf().SplitToLines();
|
||||
var p = new Paragraph();
|
||||
subtitle.Paragraphs.Clear();
|
||||
char[] splitChar = { ':' };
|
||||
foreach (string line in arr)
|
||||
{
|
||||
string s = line.Trim();
|
||||
@ -84,13 +85,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
if (!string.IsNullOrEmpty(p.Text))
|
||||
{
|
||||
p.EndTime = DecodeTimeCode(parts[0]);
|
||||
p.EndTime = DecodeTimeCode(parts[0], splitChar);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
p = new Paragraph();
|
||||
}
|
||||
else
|
||||
{
|
||||
p.StartTime = DecodeTimeCode(parts[0]);
|
||||
p.StartTime = DecodeTimeCode(parts[0], splitChar);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -122,18 +123,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string part)
|
||||
{
|
||||
string[] parts = part.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle59 : SubtitleFormat
|
||||
{
|
||||
|
||||
public static readonly Regex RegexTimeCodes = new Regex(@"^\d\d\:\d\d\:\d\d\t.+\t\d\d\:\d\d\:\d\d$", RegexOptions.Compiled);
|
||||
public static readonly Regex RegexTimeCodes2 = new Regex(@"^\d\d\:\d\d\:\d\d.+\d\d\:\d\d\:\d\d$", RegexOptions.Compiled);
|
||||
private static readonly Regex RegexStartOnly = new Regex(@"^\d\d\:\d\d\:\d\d\t.+$", RegexOptions.Compiled);
|
||||
|
@ -147,16 +147,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -152,4 +152,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle62 : SubtitleFormat
|
||||
{
|
||||
|
||||
// 338: 00:24:34.00 00:24:37.10 [51]
|
||||
private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\s+\d\d:\d\d:\d\d\.\d\d\s+\d\d:\d\d:\d\d\.\d\d\s+\[\d+\]$", RegexOptions.Compiled);
|
||||
|
||||
@ -64,6 +63,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
bool expectStartTime = true;
|
||||
var p = new Paragraph();
|
||||
subtitle.Paragraphs.Clear();
|
||||
char[] splitChars = { '.', ':' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim().Replace("*", string.Empty);
|
||||
@ -80,8 +80,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Paragraphs.Add(p);
|
||||
p = new Paragraph();
|
||||
}
|
||||
p.StartTime = DecodeTimeCode(parts[1]);
|
||||
p.EndTime = DecodeTimeCode(parts[2]);
|
||||
p.StartTime = DecodeTimeCode(parts[1], splitChars);
|
||||
p.EndTime = DecodeTimeCode(parts[2], splitChars);
|
||||
expectStartTime = false;
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -118,18 +118,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string part)
|
||||
{
|
||||
string[] parts = part.Split(new[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
//00:00:07:12
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle63 : SubtitleFormat
|
||||
{
|
||||
|
||||
//3: 00:00:09:23 00:00:16:21 06:23
|
||||
//Alustame sellest...
|
||||
//Siin kajab kuidagi harjumatult.
|
||||
@ -74,6 +73,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
bool expectStartTime = true;
|
||||
var p = new Paragraph();
|
||||
subtitle.Paragraphs.Clear();
|
||||
char[] splitChar = { ':' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim().Replace("*", string.Empty);
|
||||
@ -90,8 +90,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Paragraphs.Add(p);
|
||||
p = new Paragraph();
|
||||
}
|
||||
p.StartTime = DecodeTimeCode(parts[1]);
|
||||
p.EndTime = DecodeTimeCode(parts[2]);
|
||||
p.StartTime = DecodeTimeCode(parts[1], splitChar);
|
||||
p.EndTime = DecodeTimeCode(parts[2], splitChar);
|
||||
expectStartTime = false;
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -128,17 +128,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string part)
|
||||
{
|
||||
string[] parts = part.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -153,15 +153,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return string.Format("{0}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -69,8 +69,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
private static int RoundSeconds(TimeCode tc)
|
||||
{
|
||||
int rounded = (int)Math.Round(tc.Seconds + tc.Milliseconds / TimeCode.BaseUnit);
|
||||
return rounded;
|
||||
return (int)Math.Round(tc.Seconds + tc.Milliseconds / TimeCode.BaseUnit);
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
@ -125,4 +124,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle66 : SubtitleFormat
|
||||
{
|
||||
|
||||
// 24 10:08:57:17 10:08:59:15 01:23
|
||||
//The question is,
|
||||
//
|
||||
@ -78,6 +77,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
bool expectStartTime = true;
|
||||
var p = new Paragraph();
|
||||
subtitle.Paragraphs.Clear();
|
||||
char[] splitChar = { ':' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim().Replace("*", string.Empty);
|
||||
@ -94,8 +94,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Paragraphs.Add(p);
|
||||
p = new Paragraph();
|
||||
}
|
||||
p.StartTime = DecodeTimeCode(parts[1]);
|
||||
p.EndTime = DecodeTimeCode(parts[2]);
|
||||
p.StartTime = DecodeTimeCode(parts[1], splitChar);
|
||||
p.EndTime = DecodeTimeCode(parts[2], splitChar);
|
||||
expectStartTime = false;
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -132,17 +132,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string part)
|
||||
{
|
||||
string[] parts = part.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -114,4 +114,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -103,6 +103,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
var text = new StringBuilder();
|
||||
var header = new StringBuilder();
|
||||
Paragraph p = null;
|
||||
char[] splitChars = { ':', 'F' };
|
||||
for (int i = 0; i < lines.Count; i++)
|
||||
{
|
||||
string line = lines[i].Trim();
|
||||
@ -117,7 +118,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
try
|
||||
{
|
||||
TimeCode start = DecodeTimeCode(timeParts[0]);
|
||||
TimeCode start = DecodeTimeCode(timeParts[0].Substring(0, 11), splitChars);
|
||||
if (p != null && p.EndTime.TotalMilliseconds == 0)
|
||||
p.EndTime.TotalMilliseconds = start.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
TimeCode end = new TimeCode(0, 0, 0, 0);
|
||||
@ -134,10 +135,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
try
|
||||
{
|
||||
TimeCode start = DecodeTimeCode(timeParts[0]);
|
||||
TimeCode start = DecodeTimeCode(timeParts[0].Substring(0, 11), splitChars);
|
||||
if (p != null && p.EndTime.TotalMilliseconds == 0)
|
||||
p.EndTime.TotalMilliseconds = start.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
TimeCode end = DecodeTimeCode(timeParts[1]);
|
||||
TimeCode end = DecodeTimeCode(timeParts[1].Substring(0, 11), splitChars);
|
||||
p = MakeTextParagraph(text, p, start, end);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
text = new StringBuilder();
|
||||
@ -180,12 +181,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return string.Format("{0:00}:{1:00}:{2:00}F{3:00}", time.Hours, time.Minutes, time.Seconds, MillisecondsToFramesMaxFrameRate(time.Milliseconds));
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timePart)
|
||||
{
|
||||
string s = timePart.Substring(0, 11);
|
||||
var parts = s.Split(new[] { ':', 'F' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), FramesToMillisecondsMax999(int.Parse(parts[3])));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -64,6 +64,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Paragraphs.Clear();
|
||||
var text = new StringBuilder();
|
||||
Paragraph p = null;
|
||||
char[] splitChars = { ':', 'F' };
|
||||
for (int i = 0; i < lines.Count; i++)
|
||||
{
|
||||
string line = lines[i].Trim();
|
||||
@ -82,8 +83,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
string start = timeParts[1];
|
||||
string end = timeParts[2];
|
||||
p = new Paragraph();
|
||||
p.StartTime = DecodeTimeCode(start);
|
||||
p.EndTime = DecodeTimeCode(end);
|
||||
p.StartTime = DecodeTimeCode(start.Substring(0, 11), splitChars);
|
||||
p.EndTime = DecodeTimeCode(end.Substring(0, 11), splitChars);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
text = new StringBuilder();
|
||||
}
|
||||
@ -105,12 +106,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timePart)
|
||||
{
|
||||
string s = timePart.Substring(0, 11);
|
||||
var parts = s.Split(new[] { ':', 'F' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), FramesToMillisecondsMax999(int.Parse(parts[3])));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -141,14 +141,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return time.ToHHMMSSFF();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -562,4 +562,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle71 : SubtitleFormat
|
||||
{
|
||||
|
||||
private static readonly Regex RegexTimeCode = new Regex(@"^ \d \d : \d \d : \d \d : \d \d $", RegexOptions.Compiled);
|
||||
private static readonly Regex RegexTimeCode2 = new Regex(@"^\d \d : \d \d : \d \d : \d \d$", RegexOptions.Compiled);
|
||||
|
||||
@ -204,14 +203,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return AddSpaces(s);
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -131,4 +131,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -118,16 +118,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -143,4 +143,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -143,4 +143,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -111,4 +111,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -85,15 +85,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
//00:00:07:12
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -185,13 +185,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
var xml = new XmlDocument { XmlResolver = null };
|
||||
xml.LoadXml(xmlAsText);
|
||||
|
||||
char[] splitChar = { ':' };
|
||||
foreach (XmlNode node in xml.DocumentElement.SelectNodes("TextSection/TextScreen"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var timeCodeIn = DecodeTimeCode(node.SelectSingleNode("TimeCodeIn").InnerText);
|
||||
var timeCodeOut = DecodeTimeCode(node.SelectSingleNode("TimeCodeOut").InnerText);
|
||||
var timeCodeIn = DecodeTimeCode(node.SelectSingleNode("TimeCodeIn").InnerText, splitChar);
|
||||
var timeCodeOut = DecodeTimeCode(node.SelectSingleNode("TimeCodeOut").InnerText, splitChar);
|
||||
sb.Clear();
|
||||
foreach (XmlNode textBlockNode in node.SelectNodes("TextBlock"))
|
||||
{
|
||||
@ -213,17 +213,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timeCode)
|
||||
{
|
||||
//00:00:07:12
|
||||
var parts = timeCode.Split(':');
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -81,12 +81,14 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
string verticalAglinment = "0";
|
||||
|
||||
subtitle.Paragraphs.Clear();
|
||||
char[] splitChar = { ':' };
|
||||
char[] splitChars = { ' ', '>' };
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim();
|
||||
if (s.Length == 33 && RegexTimeCode.IsMatch(s))
|
||||
{
|
||||
var parts = s.Split(new[] { ' ', '>' });
|
||||
var parts = s.Split(splitChars);
|
||||
if (parts.Length == 5)
|
||||
{
|
||||
AddParagraph(subtitle, paragraph, formatting, verticalAglinment);
|
||||
@ -95,7 +97,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
verticalAglinment = parts[1].TrimStart('[');
|
||||
formatting = parts[2];
|
||||
paragraph = new Paragraph { StartTime = DecodeTimeCode(parts[3]), EndTime = DecodeTimeCode(parts[4].TrimEnd(']')) };
|
||||
paragraph = new Paragraph { StartTime = DecodeTimeCode(parts[3], splitChar), EndTime = DecodeTimeCode(parts[4].TrimEnd(']'), splitChar) };
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -152,18 +154,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
return time.ToHHMMSSFF();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string part)
|
||||
{
|
||||
string[] parts = part.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -114,4 +114,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle80 : SubtitleFormat
|
||||
{
|
||||
|
||||
// 1<HT>01033902/01034028<HT>xxx
|
||||
private static readonly Regex RegexTimeCode = new Regex(@"^\d+\t\d+\/\d+\t", RegexOptions.Compiled);
|
||||
|
||||
@ -70,7 +69,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
try
|
||||
{
|
||||
paragraph = new Paragraph { StartTime = DecodeTimeCode(parts[0]), EndTime = DecodeTimeCode(parts[1]) };
|
||||
var startTime = parts[0].Trim();
|
||||
var endTime = parts[1].Trim();
|
||||
|
||||
string[] startTimeParts = { startTime.Substring(0, 2), startTime.Substring(2, 2), startTime.Substring(4, 2), startTime.Substring(6, 2) };
|
||||
string[] endTimeParts = { startTime.Substring(0, 2), startTime.Substring(2, 2), startTime.Substring(4, 2), startTime.Substring(6, 2) };
|
||||
|
||||
paragraph = new Paragraph { StartTime = DecodeTimeCode(startTimeParts), EndTime = DecodeTimeCode(endTimeParts) };
|
||||
subtitle.Paragraphs.Add(paragraph);
|
||||
text = new StringBuilder();
|
||||
s = s.Remove(0, 18 + lineParts[0].Length).Trim();
|
||||
@ -120,15 +125,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return time.ToHHMMSSFF().Replace(":", string.Empty);
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string part)
|
||||
{
|
||||
part = part.Trim();
|
||||
string hour = part.Substring(0,2);
|
||||
string minutes = part.Substring(2, 2);
|
||||
string seconds = part.Substring(4, 2);
|
||||
string frames = part.Substring(6, 2);
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class UtxFrames : SubtitleFormat
|
||||
{
|
||||
|
||||
public override string Extension
|
||||
{
|
||||
get { return ".utx"; }
|
||||
|
@ -137,8 +137,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
text = RemoveTag("rt", text);
|
||||
text = RemoveTag("ruby", text);
|
||||
text = RemoveTag("c", text);
|
||||
text = RemoveTag("span", text);
|
||||
p.Text = text;
|
||||
p.Text = RemoveTag("span", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
/// </summary>
|
||||
public class WebVTTFileWithLineNumber : SubtitleFormat
|
||||
{
|
||||
|
||||
private static readonly Regex RegexTimeCodes = new Regex(@"^-?\d+:-?\d+:-?\d+\.-?\d+\s*-->\s*-?\d+:-?\d+:-?\d+\.-?\d+", RegexOptions.Compiled);
|
||||
private static readonly Regex RegexTimeCodesMiddle = new Regex(@"^-?\d+:-?\d+\.-?\d+\s*-->\s*-?\d+:-?\d+:-?\d+\.-?\d+", RegexOptions.Compiled);
|
||||
private static readonly Regex RegexTimeCodesShort = new Regex(@"^-?\d+:-?\d+\.-?\d+\s*-->\s*-?\d+:-?\d+\.-?\d+", RegexOptions.Compiled);
|
||||
|
@ -77,7 +77,14 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
string text = line.Substring(0, indexOfTen).Trim();
|
||||
string time = line.Substring(indexOf7001 - 16, 16);
|
||||
p = new Paragraph(DecodeTimeCode(time.Substring(0, 8)), DecodeTimeCode(time.Substring(8)), text);
|
||||
|
||||
var starTime = time.Substring(0, 8);
|
||||
var endTime = time.Substring(8);
|
||||
|
||||
string[] startTimeParts = { starTime.Substring(0, 2), starTime.Substring(2, 2), starTime.Substring(4, 2), starTime.Substring(6, 2) };
|
||||
string[] endTimeParts = { starTime.Substring(0, 2), starTime.Substring(2, 2), starTime.Substring(4, 2), starTime.Substring(6, 2) };
|
||||
|
||||
p = new Paragraph(DecodeTimeCode(startTimeParts), DecodeTimeCode(endTimeParts), text);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -97,16 +104,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
subtitle.Renumber();
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string time)
|
||||
{
|
||||
//00:00:07:12
|
||||
string hour = time.Substring(0, 2);
|
||||
string minutes = time.Substring(2, 2);
|
||||
string seconds = time.Substring(4, 2);
|
||||
string frames = time.Substring(6, 2);
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -159,10 +159,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
var foregroundColorNode = xml.CreateElement("ForegroundColour");
|
||||
var attrColor = xml.CreateAttribute("Colour");
|
||||
attrColor.InnerText = "7";
|
||||
foregroundColorNode.Attributes.Append(attrColor);
|
||||
paragraphNode.AppendChild(foregroundColorNode);
|
||||
var attrColor = xml.CreateAttribute("Colour");
|
||||
attrColor.InnerText = "7";
|
||||
foregroundColorNode.Attributes.Append(attrColor);
|
||||
paragraphNode.AppendChild(foregroundColorNode);
|
||||
|
||||
var textNode = xml.CreateElement("Text");
|
||||
textNode.InnerText = line;
|
||||
@ -188,13 +188,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
var xml = new XmlDocument { XmlResolver = null };
|
||||
xml.LoadXml(xmlAsText);
|
||||
|
||||
char[] splitChar = { ':' };
|
||||
foreach (XmlNode node in xml.DocumentElement.SelectNodes("FileBody/ContentBlock"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var timeCodeIn = DecodeTimeCode(node.SelectSingleNode("ThreadedObject/TimingObject/TimeIn").Attributes["value"].InnerText);
|
||||
var timeCodeOut = DecodeTimeCode(node.SelectSingleNode("ThreadedObject/TimingObject/TimeOut").Attributes["value"].InnerText);
|
||||
var timeCodeIn = DecodeTimeCode(node.SelectSingleNode("ThreadedObject/TimingObject/TimeIn").Attributes["value"].InnerText, splitChar);
|
||||
var timeCodeOut = DecodeTimeCode(node.SelectSingleNode("ThreadedObject/TimingObject/TimeOut").Attributes["value"].InnerText, splitChar);
|
||||
sb.Clear();
|
||||
foreach (XmlNode paragraphNode in node.SelectSingleNode("ThreadedObject/Content/SubtitleText/Paragraph").ChildNodes)
|
||||
{
|
||||
@ -220,16 +220,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
|
||||
private static TimeCode DecodeTimeCode(string timeCode)
|
||||
{
|
||||
//00:00:07:12
|
||||
var parts = timeCode.Split(':');
|
||||
var hour = int.Parse(parts[0]);
|
||||
var minutes = int.Parse(parts[1]);
|
||||
var seconds = int.Parse(parts[2]);
|
||||
var frames = int.Parse(parts[3]);
|
||||
return new TimeCode(hour, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -181,4 +181,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -102,4 +102,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -93,4 +93,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
public class ZeroG : SubtitleFormat
|
||||
{
|
||||
|
||||
public override string Extension
|
||||
{
|
||||
get { return ".zeg"; }
|
||||
|
Loading…
Reference in New Issue
Block a user