aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs61
1 files changed, 22 insertions, 39 deletions
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 2d3352f64..5099ccb2a 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -52,8 +52,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (!string.IsNullOrEmpty(data.format.bit_rate))
{
- int value;
- if (int.TryParse(data.format.bit_rate, NumberStyles.Any, _usCulture, out value))
+ if (int.TryParse(data.format.bit_rate, NumberStyles.Any, _usCulture, out var value))
{
info.Bitrate = value;
}
@@ -300,7 +299,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private void ReadFromDictNode(XmlReader reader, MediaInfo info)
{
string currentKey = null;
- List<NameValuePair> pairs = new List<NameValuePair>();
+ var pairs = new List<NameValuePair>();
reader.MoveToContent();
reader.Read();
@@ -360,7 +359,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private List<NameValuePair> ReadValueArray(XmlReader reader)
{
- List<NameValuePair> pairs = new List<NameValuePair>();
+ var pairs = new List<NameValuePair>();
reader.MoveToContent();
reader.Read();
@@ -579,8 +578,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (!string.IsNullOrEmpty(streamInfo.sample_rate))
{
- int value;
- if (int.TryParse(streamInfo.sample_rate, NumberStyles.Any, _usCulture, out value))
+ if (int.TryParse(streamInfo.sample_rate, NumberStyles.Any, _usCulture, out var value))
{
stream.SampleRate = value;
}
@@ -669,8 +667,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (!string.IsNullOrEmpty(streamInfo.bit_rate))
{
- int value;
- if (int.TryParse(streamInfo.bit_rate, NumberStyles.Any, _usCulture, out value))
+ if (int.TryParse(streamInfo.bit_rate, NumberStyles.Any, _usCulture, out var value))
{
bitrate = value;
}
@@ -679,8 +676,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (bitrate == 0 && formatInfo != null && !string.IsNullOrEmpty(formatInfo.bit_rate) && stream.Type == MediaStreamType.Video)
{
// If the stream info doesn't have a bitrate get the value from the media format info
- int value;
- if (int.TryParse(formatInfo.bit_rate, NumberStyles.Any, _usCulture, out value))
+ if (int.TryParse(formatInfo.bit_rate, NumberStyles.Any, _usCulture, out var value))
{
bitrate = value;
}
@@ -732,9 +728,7 @@ namespace MediaBrowser.MediaEncoding.Probing
return null;
}
- string val;
-
- tags.TryGetValue(key, out val);
+ tags.TryGetValue(key, out var val);
return val;
}
@@ -752,13 +746,10 @@ namespace MediaBrowser.MediaEncoding.Probing
{
var original = info.display_aspect_ratio;
- int height;
- int width;
-
var parts = (original ?? string.Empty).Split(':');
if (!(parts.Length == 2 &&
- int.TryParse(parts[0], NumberStyles.Any, _usCulture, out width) &&
- int.TryParse(parts[1], NumberStyles.Any, _usCulture, out height) &&
+ int.TryParse(parts[0], NumberStyles.Any, _usCulture, out var width) &&
+ int.TryParse(parts[1], NumberStyles.Any, _usCulture, out var height) &&
width > 0 &&
height > 0))
{
@@ -881,7 +872,7 @@ namespace MediaBrowser.MediaEncoding.Probing
}
}
- private void SetSize(InternalMediaInfoResult data, Model.MediaInfo.MediaInfo info)
+ private void SetSize(InternalMediaInfoResult data, MediaInfo info)
{
if (data.format != null)
{
@@ -901,7 +892,7 @@ namespace MediaBrowser.MediaEncoding.Probing
var composer = FFProbeHelpers.GetDictionaryValue(tags, "composer");
if (!string.IsNullOrWhiteSpace(composer))
{
- List<BaseItemPerson> peoples = new List<BaseItemPerson>();
+ var peoples = new List<BaseItemPerson>();
foreach (var person in Split(composer, false))
{
peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Composer });
@@ -932,7 +923,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (!string.IsNullOrWhiteSpace(writer))
{
- List<BaseItemPerson> peoples = new List<BaseItemPerson>();
+ var peoples = new List<BaseItemPerson>();
foreach (var person in Split(writer, false))
{
peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Writer });
@@ -955,7 +946,7 @@ namespace MediaBrowser.MediaEncoding.Probing
var artist = FFProbeHelpers.GetDictionaryValue(tags, "artist");
if (string.IsNullOrWhiteSpace(artist))
{
- audio.Artists = new string[] {};
+ audio.Artists = new string[] { };
}
else
{
@@ -977,7 +968,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (string.IsNullOrWhiteSpace(albumArtist))
{
- audio.AlbumArtists = new string[] {};
+ audio.AlbumArtists = new string[] { };
}
else
{
@@ -1125,7 +1116,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (!string.IsNullOrEmpty(val))
{
var studios = Split(val, true);
- List<string> studioList = new List<string>();
+ var studioList = new List<string>();
foreach (var studio in studios)
{
@@ -1160,7 +1151,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (!string.IsNullOrEmpty(val))
{
- List<string> genres = new List<string>(info.Genres);
+ var genres = new List<string>(info.Genres);
foreach (var genre in Split(val, true))
{
genres.Add(genre);
@@ -1187,9 +1178,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
disc = disc.Split('/')[0];
- int num;
-
- if (int.TryParse(disc, out num))
+ if (int.TryParse(disc, out var num))
{
return num;
}
@@ -1204,8 +1193,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (chapter.tags != null)
{
- string name;
- if (chapter.tags.TryGetValue("title", out name))
+ if (chapter.tags.TryGetValue("title", out string name))
{
info.Name = name;
}
@@ -1213,9 +1201,8 @@ namespace MediaBrowser.MediaEncoding.Probing
// Limit accuracy to milliseconds to match xml saving
var secondsString = chapter.start_time;
- double seconds;
- if (double.TryParse(secondsString, NumberStyles.Any, CultureInfo.InvariantCulture, out seconds))
+ if (double.TryParse(secondsString, NumberStyles.Any, CultureInfo.InvariantCulture, out var seconds))
{
var ms = Math.Round(TimeSpan.FromSeconds(seconds).TotalMilliseconds);
info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
@@ -1269,9 +1256,7 @@ namespace MediaBrowser.MediaEncoding.Probing
var year = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/OriginalReleaseTime");
if (!string.IsNullOrWhiteSpace(year))
{
- int val;
-
- if (int.TryParse(year, NumberStyles.Integer, _usCulture, out val))
+ if (int.TryParse(year, NumberStyles.Integer, _usCulture, out var val))
{
video.ProductionYear = val;
}
@@ -1280,11 +1265,9 @@ namespace MediaBrowser.MediaEncoding.Probing
var premiereDateString = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/MediaOriginalBroadcastDateTime");
if (!string.IsNullOrWhiteSpace(premiereDateString))
{
- DateTime val;
-
// Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
// DateTime is reported along with timezone info (typically Z i.e. UTC hence assume None)
- if (DateTime.TryParse(year, null, DateTimeStyles.None, out val))
+ if (DateTime.TryParse(year, null, DateTimeStyles.None, out var val))
{
video.PremiereDate = val.ToUniversalTime();
}