aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs
diff options
context:
space:
mode:
authorAndrew Rabert <6550543+nvllsvm@users.noreply.github.com>2019-01-22 18:13:47 -0500
committerGitHub <noreply@github.com>2019-01-22 18:13:47 -0500
commit28483bdb54be96ae83e0fded097f534d7e26ba1e (patch)
treee7f4b92326417ebf55eecdf68a01d2c3b9e660d7 /MediaBrowser.MediaEncoding/Subtitles/AssParser.cs
parent920c39454c05e979eabe81877269cd4517a03ccf (diff)
parent8106c8393b711a7e1d40487e3caf2b014decbe28 (diff)
Merge pull request #651 from jellyfin/release-10.1.0
Release 10.1.0
Diffstat (limited to 'MediaBrowser.MediaEncoding/Subtitles/AssParser.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/AssParser.cs24
1 files changed, 12 insertions, 12 deletions
diff --git a/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs b/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs
index 71fefba44..605504418 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs
@@ -1,4 +1,3 @@
-using MediaBrowser.Model.Extensions;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -6,6 +5,7 @@ using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
+using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.MediaInfo;
namespace MediaBrowser.MediaEncoding.Subtitles
@@ -17,26 +17,26 @@ namespace MediaBrowser.MediaEncoding.Subtitles
public SubtitleTrackInfo Parse(Stream stream, CancellationToken cancellationToken)
{
var trackInfo = new SubtitleTrackInfo();
- List<SubtitleTrackEvent> trackEvents = new List<SubtitleTrackEvent>();
+ var trackEvents = new List<SubtitleTrackEvent>();
var eventIndex = 1;
using (var reader = new StreamReader(stream))
{
string line;
while (reader.ReadLine() != "[Events]")
- {}
+ { }
var headers = ParseFieldHeaders(reader.ReadLine());
while ((line = reader.ReadLine()) != null)
{
cancellationToken.ThrowIfCancellationRequested();
-
+
if (string.IsNullOrWhiteSpace(line))
{
continue;
}
- if(line.StartsWith("["))
+ if (line.StartsWith("["))
break;
- if(string.IsNullOrEmpty(line))
+ if (string.IsNullOrEmpty(line))
continue;
var subEvent = new SubtitleTrackEvent { Id = eventIndex.ToString(_usCulture) };
eventIndex++;
@@ -49,7 +49,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
RemoteNativeFormatting(subEvent);
subEvent.Text = subEvent.Text.Replace("\\n", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase);
-
+
subEvent.Text = Regex.Replace(subEvent.Text, @"\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}", string.Empty, RegexOptions.IgnoreCase);
trackEvents.Add(subEvent);
@@ -61,13 +61,13 @@ namespace MediaBrowser.MediaEncoding.Subtitles
long GetTicks(string time)
{
- TimeSpan span;
- return TimeSpan.TryParseExact(time, @"h\:mm\:ss\.ff", _usCulture, out span)
- ? span.Ticks: 0;
+ return TimeSpan.TryParseExact(time, @"h\:mm\:ss\.ff", _usCulture, out var span)
+ ? span.Ticks : 0;
}
- private Dictionary<string,int> ParseFieldHeaders(string line) {
- var fields = line.Substring(8).Split(',').Select(x=>x.Trim()).ToList();
+ private Dictionary<string, int> ParseFieldHeaders(string line)
+ {
+ var fields = line.Substring(8).Split(',').Select(x => x.Trim()).ToList();
var result = new Dictionary<string, int> {
{"Start", fields.IndexOf("Start")},