using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
public class UnknownSubtitle19 : SubtitleFormat
{
public override string Extension => ".xml";
public override string Name => "Unknown 19";
private static string ToTimeCode(TimeCode time)
{
return $"{time.TotalSeconds:0.0}";
}
private static TimeCode DecodeTimeCode(string s)
{
return TimeCode.FromSeconds(double.Parse(s));
}
public override string ToText(Subtitle subtitle, string title)
{
//
//
//
string xmlStructure =
"" + Environment.NewLine +
"";
var xml = new XmlDocument();
xml.LoadXml(xmlStructure);
// int count = 1;
foreach (Paragraph p in subtitle.Paragraphs)
{
XmlNode paragraph = xml.CreateElement("Clip");
XmlAttribute attr = xml.CreateAttribute("start");
attr.InnerText = ToTimeCode(p.StartTime);
paragraph.Attributes.Append(attr);
attr = xml.CreateAttribute("end");
attr.InnerText = ToTimeCode(p.EndTime);
paragraph.Attributes.Append(attr);
//attr = xml.CreateAttribute("fileName");
//attr.InnerText = "ee_disc1_subtitle_1/Subtitle_" + count + ".png";
//paragraph.Attributes.Append(attr);
attr = xml.CreateAttribute("text");
attr.InnerText = HtmlUtil.RemoveHtmlTags(p.Text);
paragraph.Attributes.Append(attr);
xml.DocumentElement.AppendChild(paragraph);
// count++;
}
return ToUtf8XmlString(xml);
}
public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
string allText = sb.ToString();
if (!allText.Contains("") || !allText.Contains("