aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2023-05-22 22:48:09 +0200
committerBond_009 <bond.009@outlook.com>2023-06-28 17:07:57 +0200
commitb5f0760db8dba96e9edd67d4b9c914cf25c3d26a (patch)
treea60f87f379ddbfe2436d03b3b1a8f48cbc3b7490 /MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs
parentf954dc5c969ef5654c31bec7a81b0b92b38637ae (diff)
Use RegexGenerator where possible
Diffstat (limited to 'MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs7
1 files changed, 5 insertions, 2 deletions
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs b/MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs
index 143c010b7..86f77aa06 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs
@@ -11,8 +11,11 @@ namespace MediaBrowser.MediaEncoding.Subtitles
/// <summary>
/// SRT subtitle writer.
/// </summary>
- public class SrtWriter : ISubtitleWriter
+ public partial class SrtWriter : ISubtitleWriter
{
+ [GeneratedRegex(@"\\n", RegexOptions.IgnoreCase)]
+ private static partial Regex NewLineEscapedRegex();
+
/// <inheritdoc />
public void Write(SubtitleTrackInfo info, Stream stream, CancellationToken cancellationToken)
{
@@ -35,7 +38,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
var text = trackEvent.Text;
// TODO: Not sure how to handle these
- text = Regex.Replace(text, @"\\n", " ", RegexOptions.IgnoreCase);
+ text = NewLineEscapedRegex().Replace(text, " ");
writer.WriteLine(text);
writer.WriteLine();