mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-10 20:26:17 +00:00
fix subtitle unit tests
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
<Compile Include="Subtitles\ISubtitleParser.cs" />
|
||||
<Compile Include="Subtitles\ISubtitleWriter.cs" />
|
||||
<Compile Include="Subtitles\JsonWriter.cs" />
|
||||
<Compile Include="Subtitles\ParserValues.cs" />
|
||||
<Compile Include="Subtitles\SrtParser.cs" />
|
||||
<Compile Include="Subtitles\SrtWriter.cs" />
|
||||
<Compile Include="Subtitles\AssParser.cs" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@@ -42,6 +43,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
subEvent.StartPositionTicks = GetTicks(sections[headers["Start"]]);
|
||||
subEvent.EndPositionTicks = GetTicks(sections[headers["End"]]);
|
||||
subEvent.Text = string.Join(",", sections.Skip(headers["Text"]));
|
||||
subEvent.Text = subEvent.Text.Replace(@"\N", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase);
|
||||
subEvent.Text = Regex.Replace(subEvent.Text, @"\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}", string.Empty, RegexOptions.IgnoreCase);
|
||||
|
||||
trackInfo.TrackEvents.Add(subEvent);
|
||||
|
||||
13
MediaBrowser.MediaEncoding/Subtitles/ParserValues.cs
Normal file
13
MediaBrowser.MediaEncoding/Subtitles/ParserValues.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
public class ParserValues
|
||||
{
|
||||
public const string NewLine = "\r\n";
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
@@ -48,7 +49,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
}
|
||||
multiline.Add(line);
|
||||
}
|
||||
subEvent.Text = string.Join(@"\n", multiline);
|
||||
subEvent.Text = string.Join(ParserValues.NewLine, multiline);
|
||||
subEvent.Text = subEvent.Text.Replace(@"\N", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase);
|
||||
subEvent.Text = Regex.Replace(subEvent.Text, @"\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}", string.Empty, RegexOptions.IgnoreCase);
|
||||
subEvent.Text = Regex.Replace(subEvent.Text, "<", "<", RegexOptions.IgnoreCase);
|
||||
subEvent.Text = Regex.Replace(subEvent.Text, ">", ">", RegexOptions.IgnoreCase);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -147,7 +148,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
|
||||
public static string GetFormattedText(string text)
|
||||
{
|
||||
text = text.Replace("\\n", Environment.NewLine).Replace("\\n", Environment.NewLine);
|
||||
text = text.Replace("\\n", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("\\n", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
bool italic = false;
|
||||
|
||||
for (int i = 0; i < 10; i++) // just look ten times...
|
||||
|
||||
Reference in New Issue
Block a user