mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Added new subtitle format - thx Gary :)
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1822 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
de4505f2a5
commit
eefca9cfa0
@ -168,6 +168,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
new UnknownSubtitle50(),
|
new UnknownSubtitle50(),
|
||||||
new UnknownSubtitle51(),
|
new UnknownSubtitle51(),
|
||||||
new UnknownSubtitle52(),
|
new UnknownSubtitle52(),
|
||||||
|
new UnknownSubtitle53(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,11 +118,14 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
|||||||
{
|
{
|
||||||
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
|
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||||
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
subtitle.RemoveEmptyLines();
|
subtitle.RemoveEmptyLines();
|
||||||
subtitle.Renumber(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
117
src/Logic/SubtitleFormats/UnknownSubtitle53.cs
Normal file
117
src/Logic/SubtitleFormats/UnknownSubtitle53.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||||
|
{
|
||||||
|
public class UnknownSubtitle53 : SubtitleFormat
|
||||||
|
{
|
||||||
|
|
||||||
|
static Regex regexTimeCodes = new Regex(@"^\d\d\:\d\d\:\d\d\:\d\d [^ ]+", RegexOptions.Compiled);
|
||||||
|
public override string Extension
|
||||||
|
{
|
||||||
|
get { return ".txt"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Name
|
||||||
|
{
|
||||||
|
get { return "Unknown 53"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsTimeBased
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsMine(List<string> lines, string fileName)
|
||||||
|
{
|
||||||
|
Subtitle subtitle = new Subtitle();
|
||||||
|
LoadSubtitle(subtitle, lines, fileName);
|
||||||
|
return subtitle.Paragraphs.Count > _errorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToText(Subtitle subtitle, string title)
|
||||||
|
{
|
||||||
|
//10:56:54:12 FEATURING BRIAN LORENTE AND THE
|
||||||
|
//10:56:59:18 USUAL SUSPECTS.
|
||||||
|
//10:57:15:18 \M
|
||||||
|
//10:57:20:07 >> HOW WE DOING TONIGHT,
|
||||||
|
//10:57:27:17 MICHIGAN?
|
||||||
|
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
foreach (Paragraph p in subtitle.Paragraphs)
|
||||||
|
{
|
||||||
|
string text = Utilities.RemoveHtmlTags(p.Text).Replace("♪", "\\M");
|
||||||
|
sb.AppendLine(EncodeTimeCode(p.StartTime) + " " + text);
|
||||||
|
}
|
||||||
|
return sb.ToString().Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string EncodeTimeCode(TimeCode timeCode)
|
||||||
|
{
|
||||||
|
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", timeCode.Hours, timeCode.Minutes, timeCode.Seconds, MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||||
|
{
|
||||||
|
Paragraph p = null;
|
||||||
|
foreach (string line in lines)
|
||||||
|
{
|
||||||
|
string s = line.Trim();
|
||||||
|
if (regexTimeCodes.Match(s).Success)
|
||||||
|
{
|
||||||
|
if (p != null && !string.IsNullOrEmpty(p.Text))
|
||||||
|
subtitle.Paragraphs.Add(p);
|
||||||
|
p = new Paragraph();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string[] arr = s.Substring(0, 11).Split(':');
|
||||||
|
if (arr.Length == 4)
|
||||||
|
{
|
||||||
|
int hours = int.Parse(arr[0]);
|
||||||
|
int minutes = int.Parse(arr[1]);
|
||||||
|
int seconds = int.Parse(arr[2]);
|
||||||
|
int frames = int.Parse(arr[3]);
|
||||||
|
p.StartTime = new TimeCode(hours, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||||
|
string text = s.Remove(0, 11).Trim();
|
||||||
|
p.Text = text;
|
||||||
|
if (text.Length > 1 && Utilities.IsInteger(text.Substring(0, 2)))
|
||||||
|
_errorCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_errorCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (s.Length > 0)
|
||||||
|
{
|
||||||
|
_errorCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (p != null && !string.IsNullOrEmpty(p.Text))
|
||||||
|
subtitle.Paragraphs.Add(p);
|
||||||
|
|
||||||
|
int index = 1;
|
||||||
|
foreach (Paragraph paragraph in subtitle.Paragraphs)
|
||||||
|
{
|
||||||
|
paragraph.Text = paragraph.Text.Replace("\\M", "♪");
|
||||||
|
|
||||||
|
Paragraph next = subtitle.GetParagraphOrDefault(index);
|
||||||
|
if (next != null)
|
||||||
|
{
|
||||||
|
paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text);
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
subtitle.RemoveEmptyLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -903,6 +903,7 @@
|
|||||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle50.cs" />
|
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle50.cs" />
|
||||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle51.cs" />
|
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle51.cs" />
|
||||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle52.cs" />
|
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle52.cs" />
|
||||||
|
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle53.cs" />
|
||||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle6.cs" />
|
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle6.cs" />
|
||||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle7.cs" />
|
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle7.cs" />
|
||||||
<Compile Include="Logic\SubtitleFormats\DigiBeta.cs" />
|
<Compile Include="Logic\SubtitleFormats\DigiBeta.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user