aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs
diff options
context:
space:
mode:
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")},