mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
ReSharper format: conform inline 'out' parameters.
This commit is contained in:
parent
65bd052f3e
commit
e867446437
@ -31,10 +31,9 @@ namespace DvdLib.Ifo
|
|||||||
foreach (var ifo in allIfos)
|
foreach (var ifo in allIfos)
|
||||||
{
|
{
|
||||||
var num = ifo.Name.Split('_').ElementAtOrDefault(1);
|
var num = ifo.Name.Split('_').ElementAtOrDefault(1);
|
||||||
ushort ifoNumber;
|
|
||||||
var numbersRead = new List<ushort>();
|
var numbersRead = new List<ushort>();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(num) && ushort.TryParse(num, out ifoNumber) && !numbersRead.Contains(ifoNumber))
|
if (!string.IsNullOrEmpty(num) && ushort.TryParse(num, out var ifoNumber) && !numbersRead.Contains(ifoNumber))
|
||||||
{
|
{
|
||||||
ReadVTS(ifoNumber, ifo.FullName);
|
ReadVTS(ifoNumber, ifo.FullName);
|
||||||
numbersRead.Add(ifoNumber);
|
numbersRead.Add(ifoNumber);
|
||||||
|
@ -192,9 +192,7 @@ namespace Emby.Dlna.ContentDirectory
|
|||||||
|
|
||||||
public string GetValueOrDefault(IDictionary<string, string> sparams, string key, string defaultValue)
|
public string GetValueOrDefault(IDictionary<string, string> sparams, string key, string defaultValue)
|
||||||
{
|
{
|
||||||
string val;
|
if (sparams.TryGetValue(key, out var val))
|
||||||
|
|
||||||
if (sparams.TryGetValue(key, out val))
|
|
||||||
{
|
{
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -216,14 +214,12 @@ namespace Emby.Dlna.ContentDirectory
|
|||||||
int? requestedCount = null;
|
int? requestedCount = null;
|
||||||
int? start = 0;
|
int? start = 0;
|
||||||
|
|
||||||
int requestedVal;
|
if (sparams.ContainsKey("RequestedCount") && int.TryParse(sparams["RequestedCount"], out var requestedVal) && requestedVal > 0)
|
||||||
if (sparams.ContainsKey("RequestedCount") && int.TryParse(sparams["RequestedCount"], out requestedVal) && requestedVal > 0)
|
|
||||||
{
|
{
|
||||||
requestedCount = requestedVal;
|
requestedCount = requestedVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int startVal;
|
if (sparams.ContainsKey("StartingIndex") && int.TryParse(sparams["StartingIndex"], out var startVal) && startVal > 0)
|
||||||
if (sparams.ContainsKey("StartingIndex") && int.TryParse(sparams["StartingIndex"], out startVal) && startVal > 0)
|
|
||||||
{
|
{
|
||||||
start = startVal;
|
start = startVal;
|
||||||
}
|
}
|
||||||
@ -334,14 +330,12 @@ namespace Emby.Dlna.ContentDirectory
|
|||||||
int? requestedCount = null;
|
int? requestedCount = null;
|
||||||
int? start = 0;
|
int? start = 0;
|
||||||
|
|
||||||
int requestedVal;
|
if (sparams.ContainsKey("RequestedCount") && int.TryParse(sparams["RequestedCount"], out var requestedVal) && requestedVal > 0)
|
||||||
if (sparams.ContainsKey("RequestedCount") && int.TryParse(sparams["RequestedCount"], out requestedVal) && requestedVal > 0)
|
|
||||||
{
|
{
|
||||||
requestedCount = requestedVal;
|
requestedCount = requestedVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int startVal;
|
if (sparams.ContainsKey("StartingIndex") && int.TryParse(sparams["StartingIndex"], out var startVal) && startVal > 0)
|
||||||
if (sparams.ContainsKey("StartingIndex") && int.TryParse(sparams["StartingIndex"], out startVal) && startVal > 0)
|
|
||||||
{
|
{
|
||||||
start = startVal;
|
start = startVal;
|
||||||
}
|
}
|
||||||
@ -1293,7 +1287,6 @@ namespace Emby.Dlna.ContentDirectory
|
|||||||
|
|
||||||
private ServerItem ParseItemId(string id, User user)
|
private ServerItem ParseItemId(string id, User user)
|
||||||
{
|
{
|
||||||
Guid itemId;
|
|
||||||
StubType? stubType = null;
|
StubType? stubType = null;
|
||||||
|
|
||||||
// After using PlayTo, MediaMonkey sends a request to the server trying to get item info
|
// After using PlayTo, MediaMonkey sends a request to the server trying to get item info
|
||||||
@ -1319,7 +1312,7 @@ namespace Emby.Dlna.ContentDirectory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Guid.TryParse(id, out itemId))
|
if (Guid.TryParse(id, out var itemId))
|
||||||
{
|
{
|
||||||
var item = _libraryManager.GetItemById(itemId);
|
var item = _libraryManager.GetItemById(itemId);
|
||||||
|
|
||||||
|
@ -239,9 +239,7 @@ namespace Emby.Dlna
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string value;
|
if (headers.TryGetValue(header.Name, out var value))
|
||||||
|
|
||||||
if (headers.TryGetValue(header.Name, out value))
|
|
||||||
{
|
{
|
||||||
switch (header.Match)
|
switch (header.Match)
|
||||||
{
|
{
|
||||||
@ -288,8 +286,7 @@ namespace Emby.Dlna
|
|||||||
{
|
{
|
||||||
lock (_profiles)
|
lock (_profiles)
|
||||||
{
|
{
|
||||||
Tuple<InternalProfileInfo, DeviceProfile> profileTuple;
|
if (_profiles.TryGetValue(path, out var profileTuple))
|
||||||
if (_profiles.TryGetValue(path, out profileTuple))
|
|
||||||
{
|
{
|
||||||
return profileTuple.Item2;
|
return profileTuple.Item2;
|
||||||
}
|
}
|
||||||
|
@ -82,9 +82,7 @@ namespace Emby.Dlna.Eventing
|
|||||||
// Starts with SECOND-
|
// Starts with SECOND-
|
||||||
header = header.Split('-').Last();
|
header = header.Split('-').Last();
|
||||||
|
|
||||||
int val;
|
if (int.TryParse(header, NumberStyles.Integer, _usCulture, out var val))
|
||||||
|
|
||||||
if (int.TryParse(header, NumberStyles.Integer, _usCulture, out val))
|
|
||||||
{
|
{
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -97,8 +95,7 @@ namespace Emby.Dlna.Eventing
|
|||||||
{
|
{
|
||||||
_logger.LogDebug("Cancelling event subscription {0}", subscriptionId);
|
_logger.LogDebug("Cancelling event subscription {0}", subscriptionId);
|
||||||
|
|
||||||
EventSubscription sub;
|
_subscriptions.TryRemove(subscriptionId, out var sub);
|
||||||
_subscriptions.TryRemove(subscriptionId, out sub);
|
|
||||||
|
|
||||||
return new EventSubscriptionResponse
|
return new EventSubscriptionResponse
|
||||||
{
|
{
|
||||||
@ -129,9 +126,7 @@ namespace Emby.Dlna.Eventing
|
|||||||
|
|
||||||
private EventSubscription GetSubscription(string id, bool throwOnMissing)
|
private EventSubscription GetSubscription(string id, bool throwOnMissing)
|
||||||
{
|
{
|
||||||
EventSubscription e;
|
if (!_subscriptions.TryGetValue(id, out var e) && throwOnMissing)
|
||||||
|
|
||||||
if (!_subscriptions.TryGetValue(id, out e) && throwOnMissing)
|
|
||||||
{
|
{
|
||||||
throw new ResourceNotFoundException("Event with Id " + id + " not found.");
|
throw new ResourceNotFoundException("Event with Id " + id + " not found.");
|
||||||
}
|
}
|
||||||
|
@ -308,8 +308,7 @@ namespace Emby.Dlna.Main
|
|||||||
|
|
||||||
private string CreateUuid(string text)
|
private string CreateUuid(string text)
|
||||||
{
|
{
|
||||||
Guid guid;
|
if (!Guid.TryParse(text, out var guid))
|
||||||
if (!Guid.TryParse(text, out guid))
|
|
||||||
{
|
{
|
||||||
guid = text.GetMD5();
|
guid = text.GetMD5();
|
||||||
}
|
}
|
||||||
|
@ -589,9 +589,7 @@ namespace Emby.Dlna.PlayTo
|
|||||||
|
|
||||||
if (transportStateValue != null)
|
if (transportStateValue != null)
|
||||||
{
|
{
|
||||||
TRANSPORTSTATE state;
|
if (Enum.TryParse(transportStateValue, true, out TRANSPORTSTATE state))
|
||||||
|
|
||||||
if (Enum.TryParse(transportStateValue, true, out state))
|
|
||||||
{
|
{
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -98,14 +98,11 @@ namespace Emby.Dlna.PlayTo
|
|||||||
{
|
{
|
||||||
var info = e.Argument;
|
var info = e.Argument;
|
||||||
|
|
||||||
string nts;
|
info.Headers.TryGetValue("NTS", out var nts);
|
||||||
info.Headers.TryGetValue("NTS", out nts);
|
|
||||||
|
|
||||||
string usn;
|
if (!info.Headers.TryGetValue("USN", out var usn)) usn = string.Empty;
|
||||||
if (!info.Headers.TryGetValue("USN", out usn)) usn = string.Empty;
|
|
||||||
|
|
||||||
string nt;
|
if (!info.Headers.TryGetValue("NT", out var nt)) nt = string.Empty;
|
||||||
if (!info.Headers.TryGetValue("NT", out nt)) nt = string.Empty;
|
|
||||||
|
|
||||||
if (usn.IndexOf(_device.Properties.UUID, StringComparison.OrdinalIgnoreCase) != -1 &&
|
if (usn.IndexOf(_device.Properties.UUID, StringComparison.OrdinalIgnoreCase) != -1 &&
|
||||||
!_disposed)
|
!_disposed)
|
||||||
@ -623,9 +620,7 @@ namespace Emby.Dlna.PlayTo
|
|||||||
|
|
||||||
private Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken)
|
private Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
GeneralCommandType commandType;
|
if (Enum.TryParse(command.Name, true, out GeneralCommandType commandType))
|
||||||
|
|
||||||
if (Enum.TryParse(command.Name, true, out commandType))
|
|
||||||
{
|
{
|
||||||
switch (commandType)
|
switch (commandType)
|
||||||
{
|
{
|
||||||
@ -641,13 +636,9 @@ namespace Emby.Dlna.PlayTo
|
|||||||
return _device.ToggleMute(cancellationToken);
|
return _device.ToggleMute(cancellationToken);
|
||||||
case GeneralCommandType.SetAudioStreamIndex:
|
case GeneralCommandType.SetAudioStreamIndex:
|
||||||
{
|
{
|
||||||
string arg;
|
if (command.Arguments.TryGetValue("Index", out var arg))
|
||||||
|
|
||||||
if (command.Arguments.TryGetValue("Index", out arg))
|
|
||||||
{
|
{
|
||||||
int val;
|
if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out var val))
|
||||||
|
|
||||||
if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out val))
|
|
||||||
{
|
{
|
||||||
return SetAudioStreamIndex(val);
|
return SetAudioStreamIndex(val);
|
||||||
}
|
}
|
||||||
@ -659,13 +650,9 @@ namespace Emby.Dlna.PlayTo
|
|||||||
}
|
}
|
||||||
case GeneralCommandType.SetSubtitleStreamIndex:
|
case GeneralCommandType.SetSubtitleStreamIndex:
|
||||||
{
|
{
|
||||||
string arg;
|
if (command.Arguments.TryGetValue("Index", out var arg))
|
||||||
|
|
||||||
if (command.Arguments.TryGetValue("Index", out arg))
|
|
||||||
{
|
{
|
||||||
int val;
|
if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out var val))
|
||||||
|
|
||||||
if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out val))
|
|
||||||
{
|
{
|
||||||
return SetSubtitleStreamIndex(val);
|
return SetSubtitleStreamIndex(val);
|
||||||
}
|
}
|
||||||
@ -677,13 +664,9 @@ namespace Emby.Dlna.PlayTo
|
|||||||
}
|
}
|
||||||
case GeneralCommandType.SetVolume:
|
case GeneralCommandType.SetVolume:
|
||||||
{
|
{
|
||||||
string arg;
|
if (command.Arguments.TryGetValue("Volume", out var arg))
|
||||||
|
|
||||||
if (command.Arguments.TryGetValue("Volume", out arg))
|
|
||||||
{
|
{
|
||||||
int volume;
|
if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out var volume))
|
||||||
|
|
||||||
if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out volume))
|
|
||||||
{
|
{
|
||||||
return _device.SetVolume(volume, cancellationToken);
|
return _device.SetVolume(volume, cancellationToken);
|
||||||
}
|
}
|
||||||
@ -878,8 +861,7 @@ namespace Emby.Dlna.PlayTo
|
|||||||
{
|
{
|
||||||
var value = values.Get(name);
|
var value = values.Get(name);
|
||||||
|
|
||||||
int result;
|
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
|
||||||
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -891,8 +873,7 @@ namespace Emby.Dlna.PlayTo
|
|||||||
{
|
{
|
||||||
var value = values.Get(name);
|
var value = values.Get(name);
|
||||||
|
|
||||||
long result;
|
if (long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
|
||||||
if (long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,9 @@ namespace Emby.Dlna.PlayTo
|
|||||||
|
|
||||||
var info = e.Argument;
|
var info = e.Argument;
|
||||||
|
|
||||||
string usn;
|
if (!info.Headers.TryGetValue("USN", out var usn)) usn = string.Empty;
|
||||||
if (!info.Headers.TryGetValue("USN", out usn)) usn = string.Empty;
|
|
||||||
|
|
||||||
string nt;
|
if (!info.Headers.TryGetValue("NT", out var nt)) nt = string.Empty;
|
||||||
if (!info.Headers.TryGetValue("NT", out nt)) nt = string.Empty;
|
|
||||||
|
|
||||||
string location = info.Location.ToString();
|
string location = info.Location.ToString();
|
||||||
|
|
||||||
@ -155,8 +153,7 @@ namespace Emby.Dlna.PlayTo
|
|||||||
_logger.LogDebug("Attempting to create PlayToController from location {0}", location);
|
_logger.LogDebug("Attempting to create PlayToController from location {0}", location);
|
||||||
|
|
||||||
_logger.LogDebug("Logging session activity from location {0}", location);
|
_logger.LogDebug("Logging session activity from location {0}", location);
|
||||||
string uuid;
|
if (info.Headers.TryGetValue("USN", out var uuid))
|
||||||
if (info.Headers.TryGetValue("USN", out uuid))
|
|
||||||
{
|
{
|
||||||
uuid = GetUuid(uuid);
|
uuid = GetUuid(uuid);
|
||||||
}
|
}
|
||||||
|
@ -846,8 +846,7 @@ namespace Emby.Drawing
|
|||||||
{
|
{
|
||||||
lock (_locks)
|
lock (_locks)
|
||||||
{
|
{
|
||||||
LockInfo info;
|
if (_locks.TryGetValue(key, out var info))
|
||||||
if (_locks.TryGetValue(key, out info))
|
|
||||||
{
|
{
|
||||||
info.Count++;
|
info.Count++;
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,7 @@ namespace Emby.Naming.Audio
|
|||||||
|
|
||||||
tmp = tmp.Trim().Split(' ').FirstOrDefault() ?? string.Empty;
|
tmp = tmp.Trim().Split(' ').FirstOrDefault() ?? string.Empty;
|
||||||
|
|
||||||
int val;
|
if (int.TryParse(tmp, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val))
|
||||||
if (int.TryParse(tmp, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
|
|
||||||
{
|
{
|
||||||
result.IsMultiPart = true;
|
result.IsMultiPart = true;
|
||||||
break;
|
break;
|
||||||
|
@ -34,8 +34,7 @@ namespace Emby.Naming.AudioBook
|
|||||||
var value = match.Groups["chapter"];
|
var value = match.Groups["chapter"];
|
||||||
if (value.Success)
|
if (value.Success)
|
||||||
{
|
{
|
||||||
int intValue;
|
if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intValue))
|
||||||
if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out intValue))
|
|
||||||
{
|
{
|
||||||
result.ChapterNumber = intValue;
|
result.ChapterNumber = intValue;
|
||||||
}
|
}
|
||||||
@ -46,8 +45,7 @@ namespace Emby.Naming.AudioBook
|
|||||||
var value = match.Groups["part"];
|
var value = match.Groups["part"];
|
||||||
if (value.Success)
|
if (value.Success)
|
||||||
{
|
{
|
||||||
int intValue;
|
if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intValue))
|
||||||
if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out intValue))
|
|
||||||
{
|
{
|
||||||
result.ChapterNumber = intValue;
|
result.ChapterNumber = intValue;
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,7 @@ namespace Emby.Naming.TV
|
|||||||
}
|
}
|
||||||
else if (expression.IsNamed)
|
else if (expression.IsNamed)
|
||||||
{
|
{
|
||||||
int num;
|
if (int.TryParse(match.Groups["seasonnumber"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(match.Groups["seasonnumber"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
result.SeasonNumber = num;
|
result.SeasonNumber = num;
|
||||||
}
|
}
|
||||||
@ -154,8 +153,7 @@ namespace Emby.Naming.TV
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int num;
|
if (int.TryParse(match.Groups[1].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(match.Groups[1].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
result.SeasonNumber = num;
|
result.SeasonNumber = num;
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,7 @@ namespace Emby.Naming.TV
|
|||||||
|
|
||||||
if (supportNumericSeasonFolders)
|
if (supportNumericSeasonFolders)
|
||||||
{
|
{
|
||||||
int val;
|
if (int.TryParse(filename, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val))
|
||||||
if (int.TryParse(filename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
|
|
||||||
{
|
{
|
||||||
return new Tuple<int?, bool>(val, true);
|
return new Tuple<int?, bool>(val, true);
|
||||||
}
|
}
|
||||||
@ -83,8 +82,7 @@ namespace Emby.Naming.TV
|
|||||||
{
|
{
|
||||||
var testFilename = filename.Substring(1);
|
var testFilename = filename.Substring(1);
|
||||||
|
|
||||||
int val;
|
if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val))
|
||||||
if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
|
|
||||||
{
|
{
|
||||||
return new Tuple<int?, bool>(val, true);
|
return new Tuple<int?, bool>(val, true);
|
||||||
}
|
}
|
||||||
@ -121,8 +119,7 @@ namespace Emby.Naming.TV
|
|||||||
|
|
||||||
part = part.Substring(1);
|
part = part.Substring(1);
|
||||||
|
|
||||||
int value;
|
if (int.TryParse(part, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
|
||||||
if (int.TryParse(part, NumberStyles.Integer, CultureInfo.InvariantCulture, out value))
|
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -71,8 +71,7 @@ namespace Emby.Naming.Video
|
|||||||
|
|
||||||
if (match.Success && match.Groups.Count == 4)
|
if (match.Success && match.Groups.Count == 4)
|
||||||
{
|
{
|
||||||
int year;
|
if (match.Groups[1].Success && match.Groups[2].Success && int.TryParse(match.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
|
||||||
if (match.Groups[1].Success && match.Groups[2].Success && int.TryParse(match.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out year))
|
|
||||||
{
|
{
|
||||||
name = match.Groups[1].Value;
|
name = match.Groups[1].Value;
|
||||||
result.Year = year;
|
result.Year = year;
|
||||||
|
@ -7,6 +7,7 @@ using MediaBrowser.Controller.Drawing;
|
|||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
|
using MediaBrowser.Model.Drawing;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -144,8 +145,7 @@ namespace Emby.Photos
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MediaBrowser.Model.Drawing.ImageOrientation orientation;
|
if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out ImageOrientation orientation))
|
||||||
if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out orientation))
|
|
||||||
{
|
{
|
||||||
item.Orientation = orientation;
|
item.Orientation = orientation;
|
||||||
}
|
}
|
||||||
|
@ -387,9 +387,7 @@ namespace Emby.Server.Implementations.Channels
|
|||||||
|
|
||||||
private async Task<IEnumerable<MediaSourceInfo>> GetChannelItemMediaSourcesInternal(IRequiresMediaInfoCallback channel, string id, CancellationToken cancellationToken)
|
private async Task<IEnumerable<MediaSourceInfo>> GetChannelItemMediaSourcesInternal(IRequiresMediaInfoCallback channel, string id, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
Tuple<DateTime, List<MediaSourceInfo>> cachedInfo;
|
if (_channelItemMediaInfo.TryGetValue(id, out var cachedInfo))
|
||||||
|
|
||||||
if (_channelItemMediaInfo.TryGetValue(id, out cachedInfo))
|
|
||||||
{
|
{
|
||||||
if ((DateTime.UtcNow - cachedInfo.Item1).TotalMinutes < 5)
|
if ((DateTime.UtcNow - cachedInfo.Item1).TotalMinutes < 5)
|
||||||
{
|
{
|
||||||
|
@ -114,9 +114,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
{
|
{
|
||||||
var dateText = result.ToString();
|
var dateText = result.ToString();
|
||||||
|
|
||||||
DateTime dateTimeResult;
|
if (DateTime.TryParseExact(dateText, _datetimeFormats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out var dateTimeResult))
|
||||||
|
|
||||||
if (DateTime.TryParseExact(dateText, _datetimeFormats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out dateTimeResult))
|
|
||||||
{
|
{
|
||||||
return dateTimeResult.ToUniversalTime();
|
return dateTimeResult.ToUniversalTime();
|
||||||
}
|
}
|
||||||
@ -201,8 +199,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBind(this IStatement statement, string name, double value)
|
public static void TryBind(this IStatement statement, string name, double value)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
bindParam.Bind(value);
|
bindParam.Bind(value);
|
||||||
}
|
}
|
||||||
@ -214,8 +211,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBind(this IStatement statement, string name, string value)
|
public static void TryBind(this IStatement statement, string name, string value)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
@ -234,8 +230,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBind(this IStatement statement, string name, bool value)
|
public static void TryBind(this IStatement statement, string name, bool value)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
bindParam.Bind(value);
|
bindParam.Bind(value);
|
||||||
}
|
}
|
||||||
@ -247,8 +242,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBind(this IStatement statement, string name, float value)
|
public static void TryBind(this IStatement statement, string name, float value)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
bindParam.Bind(value);
|
bindParam.Bind(value);
|
||||||
}
|
}
|
||||||
@ -260,8 +254,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBind(this IStatement statement, string name, int value)
|
public static void TryBind(this IStatement statement, string name, int value)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
bindParam.Bind(value);
|
bindParam.Bind(value);
|
||||||
}
|
}
|
||||||
@ -273,8 +266,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBind(this IStatement statement, string name, Guid value)
|
public static void TryBind(this IStatement statement, string name, Guid value)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
bindParam.Bind(value.ToGuidBlob());
|
bindParam.Bind(value.ToGuidBlob());
|
||||||
}
|
}
|
||||||
@ -286,8 +278,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBind(this IStatement statement, string name, DateTime value)
|
public static void TryBind(this IStatement statement, string name, DateTime value)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
bindParam.Bind(value.ToDateTimeParamValue());
|
bindParam.Bind(value.ToDateTimeParamValue());
|
||||||
}
|
}
|
||||||
@ -299,8 +290,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBind(this IStatement statement, string name, long value)
|
public static void TryBind(this IStatement statement, string name, long value)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
bindParam.Bind(value);
|
bindParam.Bind(value);
|
||||||
}
|
}
|
||||||
@ -312,8 +302,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBind(this IStatement statement, string name, byte[] value)
|
public static void TryBind(this IStatement statement, string name, byte[] value)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
bindParam.Bind(value);
|
bindParam.Bind(value);
|
||||||
}
|
}
|
||||||
@ -325,8 +314,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
public static void TryBindNull(this IStatement statement, string name)
|
public static void TryBindNull(this IStatement statement, string name)
|
||||||
{
|
{
|
||||||
IBindParameter bindParam;
|
if (statement.BindParameters.TryGetValue(name, out var bindParam))
|
||||||
if (statement.BindParameters.TryGetValue(name, out bindParam))
|
|
||||||
{
|
{
|
||||||
bindParam.BindNull();
|
bindParam.BindNull();
|
||||||
}
|
}
|
||||||
|
@ -1164,25 +1164,21 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
image.Path = RestorePath(parts[0]);
|
image.Path = RestorePath(parts[0]);
|
||||||
|
|
||||||
long ticks;
|
if (long.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out var ticks))
|
||||||
if (long.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out ticks))
|
|
||||||
{
|
{
|
||||||
image.DateModified = new DateTime(ticks, DateTimeKind.Utc);
|
image.DateModified = new DateTime(ticks, DateTimeKind.Utc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageType type;
|
if (Enum.TryParse(parts[2], true, out ImageType type))
|
||||||
if (Enum.TryParse(parts[2], true, out type))
|
|
||||||
{
|
{
|
||||||
image.Type = type;
|
image.Type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parts.Length >= 5)
|
if (parts.Length >= 5)
|
||||||
{
|
{
|
||||||
int width;
|
if (int.TryParse(parts[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out var width))
|
||||||
int height;
|
|
||||||
if (int.TryParse(parts[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out width))
|
|
||||||
{
|
{
|
||||||
if (int.TryParse(parts[4], NumberStyles.Integer, CultureInfo.InvariantCulture, out height))
|
if (int.TryParse(parts[4], NumberStyles.Integer, CultureInfo.InvariantCulture, out var height))
|
||||||
{
|
{
|
||||||
image.Width = width;
|
image.Width = width;
|
||||||
image.Height = height;
|
image.Height = height;
|
||||||
@ -1589,8 +1585,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
ProgramAudio audio;
|
if (Enum.TryParse(reader.GetString(index), true, out ProgramAudio audio))
|
||||||
if (Enum.TryParse(reader.GetString(index), true, out audio))
|
|
||||||
{
|
{
|
||||||
item.Audio = audio;
|
item.Audio = audio;
|
||||||
}
|
}
|
||||||
@ -1634,9 +1629,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
item.LockedFields = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(
|
item.LockedFields = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(
|
||||||
i =>
|
i =>
|
||||||
{
|
{
|
||||||
MetadataFields parsedValue;
|
if (Enum.TryParse(i, true, out MetadataFields parsedValue))
|
||||||
|
|
||||||
if (Enum.TryParse(i, true, out parsedValue))
|
|
||||||
{
|
{
|
||||||
return parsedValue;
|
return parsedValue;
|
||||||
}
|
}
|
||||||
@ -1674,9 +1667,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
trailer.TrailerTypes = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(
|
trailer.TrailerTypes = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(
|
||||||
i =>
|
i =>
|
||||||
{
|
{
|
||||||
TrailerType parsedValue;
|
if (Enum.TryParse(i, true, out TrailerType parsedValue))
|
||||||
|
|
||||||
if (Enum.TryParse(i, true, out parsedValue))
|
|
||||||
{
|
{
|
||||||
return parsedValue;
|
return parsedValue;
|
||||||
}
|
}
|
||||||
@ -1857,8 +1848,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
ExtraType extraType;
|
if (Enum.TryParse(reader.GetString(index), true, out ExtraType extraType))
|
||||||
if (Enum.TryParse(reader.GetString(index), true, out extraType))
|
|
||||||
{
|
{
|
||||||
item.ExtraType = extraType;
|
item.ExtraType = extraType;
|
||||||
}
|
}
|
||||||
@ -5149,8 +5139,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
|
|||||||
|
|
||||||
private IEnumerable<string> MapIncludeItemTypes(string value)
|
private IEnumerable<string> MapIncludeItemTypes(string value)
|
||||||
{
|
{
|
||||||
string[] result;
|
if (_types.TryGetValue(value, out var result))
|
||||||
if (_types.TryGetValue(value, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,7 @@ namespace Emby.Server.Implementations.Devices
|
|||||||
{
|
{
|
||||||
var value = File.ReadAllText(CachePath, Encoding.UTF8);
|
var value = File.ReadAllText(CachePath, Encoding.UTF8);
|
||||||
|
|
||||||
Guid guid;
|
if (Guid.TryParse(value, out var guid))
|
||||||
if (Guid.TryParse(value, out guid))
|
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,7 @@ namespace Emby.Server.Implementations.Devices
|
|||||||
{
|
{
|
||||||
lock (_capabilitiesSyncLock)
|
lock (_capabilitiesSyncLock)
|
||||||
{
|
{
|
||||||
ClientCapabilities result;
|
if (_capabilitiesCache.TryGetValue(id, out var result))
|
||||||
if (_capabilitiesCache.TryGetValue(id, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -637,9 +637,7 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
Type = person.Type
|
Type = person.Type
|
||||||
};
|
};
|
||||||
|
|
||||||
Person entity;
|
if (dictionary.TryGetValue(person.Name, out var entity))
|
||||||
|
|
||||||
if (dictionary.TryGetValue(person.Name, out entity))
|
|
||||||
{
|
{
|
||||||
baseItemPerson.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary);
|
baseItemPerson.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary);
|
||||||
baseItemPerson.Id = entity.Id.ToString("N");
|
baseItemPerson.Id = entity.Id.ToString("N");
|
||||||
|
@ -108,11 +108,9 @@ namespace Emby.Server.Implementations.EntryPoints
|
|||||||
|
|
||||||
var info = e.Argument;
|
var info = e.Argument;
|
||||||
|
|
||||||
string usn;
|
if (!info.Headers.TryGetValue("USN", out var usn)) usn = string.Empty;
|
||||||
if (!info.Headers.TryGetValue("USN", out usn)) usn = string.Empty;
|
|
||||||
|
|
||||||
string nt;
|
if (!info.Headers.TryGetValue("NT", out var nt)) nt = string.Empty;
|
||||||
if (!info.Headers.TryGetValue("NT", out nt)) nt = string.Empty;
|
|
||||||
|
|
||||||
// Filter device type
|
// Filter device type
|
||||||
if (usn.IndexOf("WANIPConnection:", StringComparison.OrdinalIgnoreCase) == -1 &&
|
if (usn.IndexOf("WANIPConnection:", StringComparison.OrdinalIgnoreCase) == -1 &&
|
||||||
@ -141,8 +139,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
|||||||
|
|
||||||
_logger.LogDebug("Found NAT device: " + identifier);
|
_logger.LogDebug("Found NAT device: " + identifier);
|
||||||
|
|
||||||
IPAddress address;
|
if (IPAddress.TryParse(info.Location.Host, out var address))
|
||||||
if (IPAddress.TryParse(info.Location.Host, out address))
|
|
||||||
{
|
{
|
||||||
// The Handle method doesn't need the port
|
// The Handle method doesn't need the port
|
||||||
var endpoint = new IPEndPoint(address, info.Location.Port);
|
var endpoint = new IPEndPoint(address, info.Location.Port);
|
||||||
@ -153,8 +150,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
|||||||
{
|
{
|
||||||
var localAddressString = await _appHost.GetLocalApiUrl(CancellationToken.None).ConfigureAwait(false);
|
var localAddressString = await _appHost.GetLocalApiUrl(CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
Uri uri;
|
if (Uri.TryCreate(localAddressString, UriKind.Absolute, out var uri))
|
||||||
if (Uri.TryCreate(localAddressString, UriKind.Absolute, out uri))
|
|
||||||
{
|
{
|
||||||
localAddressString = uri.Host;
|
localAddressString = uri.Host;
|
||||||
|
|
||||||
|
@ -89,8 +89,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
|||||||
|
|
||||||
var progress = e.Argument.Item2;
|
var progress = e.Argument.Item2;
|
||||||
|
|
||||||
DateTime lastMessageSendTime;
|
if (_lastProgressMessageTimes.TryGetValue(item.Id, out var lastMessageSendTime))
|
||||||
if (_lastProgressMessageTimes.TryGetValue(item.Id, out lastMessageSendTime))
|
|
||||||
{
|
{
|
||||||
if (progress > 0 && progress < 100 && (DateTime.UtcNow - lastMessageSendTime).TotalMilliseconds < 1000)
|
if (progress > 0 && progress < 100 && (DateTime.UtcNow - lastMessageSendTime).TotalMilliseconds < 1000)
|
||||||
{
|
{
|
||||||
|
@ -62,9 +62,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
|||||||
UpdateTimer.Change(UpdateDuration, Timeout.Infinite);
|
UpdateTimer.Change(UpdateDuration, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BaseItem> keys;
|
if (!_changedItems.TryGetValue(e.UserId, out var keys))
|
||||||
|
|
||||||
if (!_changedItems.TryGetValue(e.UserId, out keys))
|
|
||||||
{
|
{
|
||||||
keys = new List<BaseItem>();
|
keys = new List<BaseItem>();
|
||||||
_changedItems[e.UserId] = keys;
|
_changedItems[e.UserId] = keys;
|
||||||
|
@ -90,11 +90,9 @@ namespace Emby.Server.Implementations.HttpClientManager
|
|||||||
throw new ArgumentNullException(nameof(host));
|
throw new ArgumentNullException(nameof(host));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpClientInfo client;
|
|
||||||
|
|
||||||
var key = host + enableHttpCompression;
|
var key = host + enableHttpCompression;
|
||||||
|
|
||||||
if (!_httpClients.TryGetValue(key, out client))
|
if (!_httpClients.TryGetValue(key, out var client))
|
||||||
{
|
{
|
||||||
client = new HttpClientInfo();
|
client = new HttpClientInfo();
|
||||||
|
|
||||||
|
@ -124,8 +124,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
|
|
||||||
public Type GetServiceTypeByRequest(Type requestType)
|
public Type GetServiceTypeByRequest(Type requestType)
|
||||||
{
|
{
|
||||||
Type serviceType;
|
ServiceOperationsMap.TryGetValue(requestType, out var serviceType);
|
||||||
ServiceOperationsMap.TryGetValue(requestType, out serviceType);
|
|
||||||
return serviceType;
|
return serviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,8 +214,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
|
|
||||||
var exceptionType = ex.GetType();
|
var exceptionType = ex.GetType();
|
||||||
|
|
||||||
int statusCode;
|
if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out var statusCode))
|
||||||
if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out statusCode))
|
|
||||||
{
|
{
|
||||||
if (ex is DirectoryNotFoundException)
|
if (ex is DirectoryNotFoundException)
|
||||||
{
|
{
|
||||||
@ -704,8 +702,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string contentType;
|
var restPath = ServiceHandler.FindMatchingRestPath(httpReq.HttpMethod, pathInfo, out var contentType);
|
||||||
var restPath = ServiceHandler.FindMatchingRestPath(httpReq.HttpMethod, pathInfo, out contentType);
|
|
||||||
|
|
||||||
if (restPath != null)
|
if (restPath != null)
|
||||||
{
|
{
|
||||||
@ -731,8 +728,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
private void RedirectToSecureUrl(IHttpRequest httpReq, IResponse httpRes, string url)
|
private void RedirectToSecureUrl(IHttpRequest httpReq, IResponse httpRes, string url)
|
||||||
{
|
{
|
||||||
int currentPort;
|
int currentPort;
|
||||||
Uri uri;
|
if (Uri.TryCreate(url, UriKind.Absolute, out var uri))
|
||||||
if (Uri.TryCreate(url, UriKind.Absolute, out uri))
|
|
||||||
{
|
{
|
||||||
currentPort = uri.Port;
|
currentPort = uri.Port;
|
||||||
var builder = new UriBuilder(uri);
|
var builder = new UriBuilder(uri);
|
||||||
|
@ -96,8 +96,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
responseHeaders = new Dictionary<string, string>();
|
responseHeaders = new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
string expires;
|
if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out var expires))
|
||||||
if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires))
|
|
||||||
{
|
{
|
||||||
responseHeaders["Expires"] = "-1";
|
responseHeaders["Expires"] = "-1";
|
||||||
}
|
}
|
||||||
@ -143,8 +142,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
responseHeaders = new Dictionary<string, string>();
|
responseHeaders = new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
string expires;
|
if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out var expires))
|
||||||
if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires))
|
|
||||||
{
|
{
|
||||||
responseHeaders["Expires"] = "-1";
|
responseHeaders["Expires"] = "-1";
|
||||||
}
|
}
|
||||||
@ -188,8 +186,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
responseHeaders = new Dictionary<string, string>();
|
responseHeaders = new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
string expires;
|
if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out var expires))
|
||||||
if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires))
|
|
||||||
{
|
{
|
||||||
responseHeaders["Expires"] = "-1";
|
responseHeaders["Expires"] = "-1";
|
||||||
}
|
}
|
||||||
@ -702,9 +699,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(ifModifiedSinceHeader))
|
if (!string.IsNullOrEmpty(ifModifiedSinceHeader))
|
||||||
{
|
{
|
||||||
DateTime ifModifiedSince;
|
if (DateTime.TryParse(ifModifiedSinceHeader, out var ifModifiedSince))
|
||||||
|
|
||||||
if (DateTime.TryParse(ifModifiedSinceHeader, out ifModifiedSince))
|
|
||||||
{
|
{
|
||||||
if (IsNotModified(ifModifiedSince.ToUniversalTime(), cacheDuration, lastDateModified))
|
if (IsNotModified(ifModifiedSince.ToUniversalTime(), cacheDuration, lastDateModified))
|
||||||
{
|
{
|
||||||
@ -720,11 +715,9 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
// Validate If-None-Match
|
// Validate If-None-Match
|
||||||
if ((hasCacheKey || !string.IsNullOrEmpty(ifNoneMatchHeader)))
|
if ((hasCacheKey || !string.IsNullOrEmpty(ifNoneMatchHeader)))
|
||||||
{
|
{
|
||||||
Guid ifNoneMatch;
|
|
||||||
|
|
||||||
ifNoneMatchHeader = (ifNoneMatchHeader ?? string.Empty).Trim('\"');
|
ifNoneMatchHeader = (ifNoneMatchHeader ?? string.Empty).Trim('\"');
|
||||||
|
|
||||||
if (Guid.TryParse(ifNoneMatchHeader, out ifNoneMatch))
|
if (Guid.TryParse(ifNoneMatchHeader, out var ifNoneMatch))
|
||||||
{
|
{
|
||||||
if (hasCacheKey && cacheKey.Equals(ifNoneMatch))
|
if (hasCacheKey && cacheKey.Equals(ifNoneMatch))
|
||||||
{
|
{
|
||||||
|
@ -56,9 +56,8 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Content length has to be explicitly set on on HttpListenerResponse or it won't be happy
|
// Content length has to be explicitly set on on HttpListenerResponse or it won't be happy
|
||||||
string contentLength;
|
|
||||||
|
|
||||||
if (hasHeaders.Headers.TryGetValue("Content-Length", out contentLength) && !string.IsNullOrEmpty(contentLength))
|
if (hasHeaders.Headers.TryGetValue("Content-Length", out var contentLength) && !string.IsNullOrEmpty(contentLength))
|
||||||
{
|
{
|
||||||
var length = long.Parse(contentLength, UsCulture);
|
var length = long.Parse(contentLength, UsCulture);
|
||||||
|
|
||||||
|
@ -207,8 +207,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|||||||
|
|
||||||
private static AuthenticationInfo GetTokenInfo(IRequest request)
|
private static AuthenticationInfo GetTokenInfo(IRequest request)
|
||||||
{
|
{
|
||||||
object info;
|
request.Items.TryGetValue("OriginalAuthenticationInfo", out var info);
|
||||||
request.Items.TryGetValue("OriginalAuthenticationInfo", out info);
|
|
||||||
return info as AuthenticationInfo;
|
return info as AuthenticationInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|||||||
|
|
||||||
public AuthorizationInfo GetAuthorizationInfo(IRequest requestContext)
|
public AuthorizationInfo GetAuthorizationInfo(IRequest requestContext)
|
||||||
{
|
{
|
||||||
object cached;
|
if (requestContext.Items.TryGetValue("AuthorizationInfo", out var cached))
|
||||||
if (requestContext.Items.TryGetValue("AuthorizationInfo", out cached))
|
|
||||||
{
|
{
|
||||||
return (AuthorizationInfo)cached;
|
return (AuthorizationInfo)cached;
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|||||||
|
|
||||||
private AuthenticationInfo GetTokenInfo(IRequest request)
|
private AuthenticationInfo GetTokenInfo(IRequest request)
|
||||||
{
|
{
|
||||||
object info;
|
request.Items.TryGetValue("OriginalAuthenticationInfo", out var info);
|
||||||
request.Items.TryGetValue("OriginalAuthenticationInfo", out info);
|
|
||||||
return info as AuthenticationInfo;
|
return info as AuthenticationInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,7 @@ namespace Emby.Server.Implementations.IO
|
|||||||
// But if we make this delay too high, we risk missing legitimate changes, such as user adding a new file, or hand-editing metadata
|
// But if we make this delay too high, we risk missing legitimate changes, such as user adding a new file, or hand-editing metadata
|
||||||
await Task.Delay(45000).ConfigureAwait(false);
|
await Task.Delay(45000).ConfigureAwait(false);
|
||||||
|
|
||||||
string val;
|
_tempIgnoredPaths.TryRemove(path, out var val);
|
||||||
_tempIgnoredPaths.TryRemove(path, out val);
|
|
||||||
|
|
||||||
if (refreshPath)
|
if (refreshPath)
|
||||||
{
|
{
|
||||||
@ -365,9 +364,7 @@ namespace Emby.Server.Implementations.IO
|
|||||||
/// <param name="path">The path.</param>
|
/// <param name="path">The path.</param>
|
||||||
private void StopWatchingPath(string path)
|
private void StopWatchingPath(string path)
|
||||||
{
|
{
|
||||||
FileSystemWatcher watcher;
|
if (_fileSystemWatchers.TryGetValue(path, out var watcher))
|
||||||
|
|
||||||
if (_fileSystemWatchers.TryGetValue(path, out watcher))
|
|
||||||
{
|
{
|
||||||
DisposeWatcher(watcher, true);
|
DisposeWatcher(watcher, true);
|
||||||
}
|
}
|
||||||
@ -424,9 +421,7 @@ namespace Emby.Server.Implementations.IO
|
|||||||
/// <param name="watcher">The watcher.</param>
|
/// <param name="watcher">The watcher.</param>
|
||||||
private void RemoveWatcherFromList(FileSystemWatcher watcher)
|
private void RemoveWatcherFromList(FileSystemWatcher watcher)
|
||||||
{
|
{
|
||||||
FileSystemWatcher removed;
|
_fileSystemWatchers.TryRemove(watcher.Path, out var removed);
|
||||||
|
|
||||||
_fileSystemWatchers.TryRemove(watcher.Path, out removed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -432,8 +432,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
ItemRepository.DeleteItem(child.Id, CancellationToken.None);
|
ItemRepository.DeleteItem(child.Id, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseItem removed;
|
_libraryItemsCache.TryRemove(item.Id, out var removed);
|
||||||
_libraryItemsCache.TryRemove(item.Id, out removed);
|
|
||||||
|
|
||||||
ReportItemRemoved(item, parent);
|
ReportItemRemoved(item, parent);
|
||||||
}
|
}
|
||||||
@ -1241,9 +1240,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
throw new ArgumentNullException(nameof(id));
|
throw new ArgumentNullException(nameof(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseItem item;
|
if (LibraryItemsCache.TryGetValue(id, out var item))
|
||||||
|
|
||||||
if (LibraryItemsCache.TryGetValue(id, out item))
|
|
||||||
{
|
{
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -777,8 +777,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ILiveStream info;
|
if (_openStreams.TryGetValue(id, out var info))
|
||||||
if (_openStreams.TryGetValue(id, out info))
|
|
||||||
{
|
{
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -810,9 +809,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ILiveStream liveStream;
|
if (_openStreams.TryGetValue(id, out var liveStream))
|
||||||
|
|
||||||
if (_openStreams.TryGetValue(id, out liveStream))
|
|
||||||
{
|
{
|
||||||
liveStream.ConsumerCount--;
|
liveStream.ConsumerCount--;
|
||||||
|
|
||||||
|
@ -395,8 +395,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
private async Task<EpgChannelData> GetEpgChannels(IListingsProvider provider, ListingsProviderInfo info, bool enableCache, CancellationToken cancellationToken)
|
private async Task<EpgChannelData> GetEpgChannels(IListingsProvider provider, ListingsProviderInfo info, bool enableCache, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
EpgChannelData result;
|
if (!enableCache || !_epgChannels.TryGetValue(info.Id, out var result))
|
||||||
if (!enableCache || !_epgChannels.TryGetValue(info.Id, out result))
|
|
||||||
{
|
{
|
||||||
var channels = await provider.GetChannels(info, cancellationToken).ConfigureAwait(false);
|
var channels = await provider.GetChannels(info, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
@ -652,9 +651,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
TimerCancelled(this, new GenericEventArgs<string>(timerId));
|
TimerCancelled(this, new GenericEventArgs<string>(timerId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActiveRecordingInfo activeRecordingInfo;
|
|
||||||
|
|
||||||
if (_activeRecordings.TryGetValue(timerId, out activeRecordingInfo))
|
if (_activeRecordings.TryGetValue(timerId, out var activeRecordingInfo))
|
||||||
{
|
{
|
||||||
activeRecordingInfo.Timer = timer;
|
activeRecordingInfo.Timer = timer;
|
||||||
activeRecordingInfo.CancellationTokenSource.Cancel();
|
activeRecordingInfo.CancellationTokenSource.Cancel();
|
||||||
@ -821,8 +819,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only update if not currently active
|
// Only update if not currently active
|
||||||
ActiveRecordingInfo activeRecordingInfo;
|
if (!_activeRecordings.TryGetValue(updatedTimer.Id, out var activeRecordingInfo))
|
||||||
if (!_activeRecordings.TryGetValue(updatedTimer.Id, out activeRecordingInfo))
|
|
||||||
{
|
{
|
||||||
existingTimer.PrePaddingSeconds = updatedTimer.PrePaddingSeconds;
|
existingTimer.PrePaddingSeconds = updatedTimer.PrePaddingSeconds;
|
||||||
existingTimer.PostPaddingSeconds = updatedTimer.PostPaddingSeconds;
|
existingTimer.PostPaddingSeconds = updatedTimer.PostPaddingSeconds;
|
||||||
@ -864,9 +861,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
public string GetActiveRecordingPath(string id)
|
public string GetActiveRecordingPath(string id)
|
||||||
{
|
{
|
||||||
ActiveRecordingInfo info;
|
if (_activeRecordings.TryGetValue(id, out var info))
|
||||||
|
|
||||||
if (_activeRecordings.TryGetValue(id, out info))
|
|
||||||
{
|
{
|
||||||
return info.Path;
|
return info.Path;
|
||||||
}
|
}
|
||||||
@ -1440,8 +1435,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
TriggerRefresh(recordPath);
|
TriggerRefresh(recordPath);
|
||||||
_libraryMonitor.ReportFileSystemChangeComplete(recordPath, false);
|
_libraryMonitor.ReportFileSystemChangeComplete(recordPath, false);
|
||||||
|
|
||||||
ActiveRecordingInfo removed;
|
_activeRecordings.TryRemove(timer.Id, out var removed);
|
||||||
_activeRecordings.TryRemove(timer.Id, out removed);
|
|
||||||
|
|
||||||
if (recordingStatus != RecordingStatus.Completed && DateTime.UtcNow < timer.EndDate && timer.RetryCount < 10)
|
if (recordingStatus != RecordingStatus.Completed && DateTime.UtcNow < timer.EndDate && timer.RetryCount < 10)
|
||||||
{
|
{
|
||||||
@ -2007,8 +2001,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
writer.WriteStartDocument(true);
|
writer.WriteStartDocument(true);
|
||||||
writer.WriteStartElement("tvshow");
|
writer.WriteStartElement("tvshow");
|
||||||
|
|
||||||
string id;
|
if (timer.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out var id))
|
||||||
if (timer.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id))
|
|
||||||
{
|
{
|
||||||
writer.WriteElementString("id", id);
|
writer.WriteElementString("id", id);
|
||||||
}
|
}
|
||||||
@ -2417,8 +2410,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
{
|
{
|
||||||
// Only update if not currently active - test both new timer and existing in case Id's are different
|
// Only update if not currently active - test both new timer and existing in case Id's are different
|
||||||
// Id's could be different if the timer was created manually prior to series timer creation
|
// Id's could be different if the timer was created manually prior to series timer creation
|
||||||
ActiveRecordingInfo activeRecordingInfo;
|
if (!_activeRecordings.TryGetValue(timer.Id, out var activeRecordingInfo) && !_activeRecordings.TryGetValue(existingTimer.Id, out activeRecordingInfo))
|
||||||
if (!_activeRecordings.TryGetValue(timer.Id, out activeRecordingInfo) && !_activeRecordings.TryGetValue(existingTimer.Id, out activeRecordingInfo))
|
|
||||||
{
|
{
|
||||||
UpdateExistingTimerWithNewMetadata(existingTimer, timer);
|
UpdateExistingTimerWithNewMetadata(existingTimer, timer);
|
||||||
|
|
||||||
@ -2521,9 +2513,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(Guid.Empty))
|
if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(Guid.Empty))
|
||||||
{
|
{
|
||||||
LiveTvChannel channel;
|
if (!tempChannelCache.TryGetValue(parent.ChannelId, out var channel))
|
||||||
|
|
||||||
if (!tempChannelCache.TryGetValue(parent.ChannelId, out channel))
|
|
||||||
{
|
{
|
||||||
channel = _libraryManager.GetItemList(new InternalItemsQuery
|
channel = _libraryManager.GetItemList(new InternalItemsQuery
|
||||||
{
|
{
|
||||||
@ -2582,9 +2572,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
if (!programInfo.ChannelId.Equals(Guid.Empty))
|
if (!programInfo.ChannelId.Equals(Guid.Empty))
|
||||||
{
|
{
|
||||||
LiveTvChannel channel;
|
if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out var channel))
|
||||||
|
|
||||||
if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out channel))
|
|
||||||
{
|
{
|
||||||
channel = _libraryManager.GetItemList(new InternalItemsQuery
|
channel = _libraryManager.GetItemList(new InternalItemsQuery
|
||||||
{
|
{
|
||||||
|
@ -140,8 +140,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
private void StopTimer(TimerInfo item)
|
private void StopTimer(TimerInfo item)
|
||||||
{
|
{
|
||||||
ITimer timer;
|
if (_timers.TryRemove(item.Id, out var timer))
|
||||||
if (_timers.TryRemove(item.Id, out timer))
|
|
||||||
{
|
{
|
||||||
timer.Dispose();
|
timer.Dispose();
|
||||||
}
|
}
|
||||||
|
@ -528,8 +528,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
var isNew = false;
|
var isNew = false;
|
||||||
var forceUpdate = false;
|
var forceUpdate = false;
|
||||||
|
|
||||||
LiveTvProgram item;
|
if (!allExistingPrograms.TryGetValue(id, out var item))
|
||||||
if (!allExistingPrograms.TryGetValue(id, out item))
|
|
||||||
{
|
{
|
||||||
isNew = true;
|
isNew = true;
|
||||||
item = new LiveTvProgram
|
item = new LiveTvProgram
|
||||||
@ -1940,8 +1939,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
|
|
||||||
foreach (var programDto in currentProgramDtos)
|
foreach (var programDto in currentProgramDtos)
|
||||||
{
|
{
|
||||||
BaseItemDto channelDto;
|
if (currentChannelsDict.TryGetValue(programDto.ChannelId, out var channelDto))
|
||||||
if (currentChannelsDict.TryGetValue(programDto.ChannelId, out channelDto))
|
|
||||||
{
|
{
|
||||||
channelDto.CurrentProgram = programDto;
|
channelDto.CurrentProgram = programDto;
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(cacheKey))
|
if (!string.IsNullOrEmpty(cacheKey))
|
||||||
{
|
{
|
||||||
DiscoverResponse response;
|
if (_modelCache.TryGetValue(cacheKey, out var response))
|
||||||
if (_modelCache.TryGetValue(cacheKey, out response))
|
|
||||||
{
|
{
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -132,8 +132,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||||||
var receiveBuffer = new byte[8192];
|
var receiveBuffer = new byte[8192];
|
||||||
var response = await socket.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
|
var response = await socket.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
string returnVal;
|
ParseReturnMessage(response.Buffer, response.ReceivedBytes, out var returnVal);
|
||||||
ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal);
|
|
||||||
|
|
||||||
return string.Equals(returnVal, "none", StringComparison.OrdinalIgnoreCase);
|
return string.Equals(returnVal, "none", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
@ -167,9 +166,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||||||
var lockkeyMsg = CreateSetMessage(i, "lockkey", lockKeyString, null);
|
var lockkeyMsg = CreateSetMessage(i, "lockkey", lockKeyString, null);
|
||||||
await tcpClient.SendToAsync(lockkeyMsg, 0, lockkeyMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false);
|
await tcpClient.SendToAsync(lockkeyMsg, 0, lockkeyMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false);
|
||||||
var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
|
var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
|
||||||
string returnVal;
|
|
||||||
// parse response to make sure it worked
|
// parse response to make sure it worked
|
||||||
if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal))
|
if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out var returnVal))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var commandList = commands.GetCommands();
|
var commandList = commands.GetCommands();
|
||||||
@ -222,8 +220,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||||||
await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, new IpEndPointInfo(_remoteIp, HdHomeRunPort), cancellationToken).ConfigureAwait(false);
|
await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, new IpEndPointInfo(_remoteIp, HdHomeRunPort), cancellationToken).ConfigureAwait(false);
|
||||||
var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
|
var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
|
||||||
// parse response to make sure it worked
|
// parse response to make sure it worked
|
||||||
string returnVal;
|
if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out var returnVal))
|
||||||
if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -135,9 +135,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
|
|
||||||
var protocol = _mediaSourceManager.GetPathProtocol(path);
|
var protocol = _mediaSourceManager.GetPathProtocol(path);
|
||||||
|
|
||||||
Uri uri;
|
|
||||||
var isRemote = true;
|
var isRemote = true;
|
||||||
if (Uri.TryCreate(path, UriKind.Absolute, out uri))
|
if (Uri.TryCreate(path, UriKind.Absolute, out var uri))
|
||||||
{
|
{
|
||||||
isRemote = !_networkManager.IsInLocalNetwork(uri.Host);
|
isRemote = !_networkManager.IsInLocalNetwork(uri.Host);
|
||||||
}
|
}
|
||||||
|
@ -117,12 +117,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
|
|
||||||
extInf = extInf.Trim();
|
extInf = extInf.Trim();
|
||||||
|
|
||||||
string remaining;
|
var attributes = ParseExtInf(extInf, out var remaining);
|
||||||
var attributes = ParseExtInf(extInf, out remaining);
|
|
||||||
extInf = remaining;
|
extInf = remaining;
|
||||||
|
|
||||||
string value;
|
if (attributes.TryGetValue("tvg-logo", out var value))
|
||||||
if (attributes.TryGetValue("tvg-logo", out value))
|
|
||||||
{
|
{
|
||||||
channel.ImageUrl = value;
|
channel.ImageUrl = value;
|
||||||
}
|
}
|
||||||
@ -130,11 +128,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
channel.Name = GetChannelName(extInf, attributes);
|
channel.Name = GetChannelName(extInf, attributes);
|
||||||
channel.Number = GetChannelNumber(extInf, attributes, mediaUrl);
|
channel.Number = GetChannelNumber(extInf, attributes, mediaUrl);
|
||||||
|
|
||||||
string tvgId;
|
attributes.TryGetValue("tvg-id", out var tvgId);
|
||||||
attributes.TryGetValue("tvg-id", out tvgId);
|
|
||||||
|
|
||||||
string channelId;
|
attributes.TryGetValue("channel-id", out var channelId);
|
||||||
attributes.TryGetValue("channel-id", out channelId);
|
|
||||||
|
|
||||||
channel.TunerChannelId = string.IsNullOrWhiteSpace(tvgId) ? channelId : tvgId;
|
channel.TunerChannelId = string.IsNullOrWhiteSpace(tvgId) ? channelId : tvgId;
|
||||||
|
|
||||||
@ -172,8 +168,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
{
|
{
|
||||||
var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
|
var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
|
||||||
|
|
||||||
double number;
|
if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number))
|
||||||
if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
|
|
||||||
{
|
{
|
||||||
numberString = numberPart;
|
numberString = numberPart;
|
||||||
}
|
}
|
||||||
@ -187,11 +182,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
|
|
||||||
if (!IsValidChannelNumber(numberString))
|
if (!IsValidChannelNumber(numberString))
|
||||||
{
|
{
|
||||||
string value;
|
if (attributes.TryGetValue("tvg-id", out var value))
|
||||||
if (attributes.TryGetValue("tvg-id", out value))
|
|
||||||
{
|
{
|
||||||
double doubleValue;
|
if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var doubleValue))
|
||||||
if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue))
|
|
||||||
{
|
{
|
||||||
numberString = value;
|
numberString = value;
|
||||||
}
|
}
|
||||||
@ -205,8 +198,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
|
|
||||||
if (!IsValidChannelNumber(numberString))
|
if (!IsValidChannelNumber(numberString))
|
||||||
{
|
{
|
||||||
string value;
|
if (attributes.TryGetValue("channel-id", out var value))
|
||||||
if (attributes.TryGetValue("channel-id", out value))
|
|
||||||
{
|
{
|
||||||
numberString = value;
|
numberString = value;
|
||||||
}
|
}
|
||||||
@ -259,8 +251,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double value;
|
if (!double.TryParse(numberString, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
|
||||||
if (!double.TryParse(numberString, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -283,8 +274,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
{
|
{
|
||||||
var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
|
var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
|
||||||
|
|
||||||
double number;
|
if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number))
|
||||||
if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
|
|
||||||
{
|
{
|
||||||
//channel.Number = number.ToString();
|
//channel.Number = number.ToString();
|
||||||
nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(new[] { ' ', '-' });
|
nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(new[] { ' ', '-' });
|
||||||
@ -292,8 +282,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string name;
|
attributes.TryGetValue("tvg-name", out var name);
|
||||||
attributes.TryGetValue("tvg-name", out name);
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
{
|
{
|
||||||
|
@ -298,9 +298,7 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
/// <param name="countryCode">The country code.</param>
|
/// <param name="countryCode">The country code.</param>
|
||||||
private Dictionary<string, ParentalRating> GetRatings(string countryCode)
|
private Dictionary<string, ParentalRating> GetRatings(string countryCode)
|
||||||
{
|
{
|
||||||
Dictionary<string, ParentalRating> value;
|
_allParentalRatings.TryGetValue(countryCode, out var value);
|
||||||
|
|
||||||
_allParentalRatings.TryGetValue(countryCode, out value);
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -320,9 +318,7 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
|
|
||||||
if (parts.Length == 2)
|
if (parts.Length == 2)
|
||||||
{
|
{
|
||||||
int value;
|
if (int.TryParse(parts[1], NumberStyles.Integer, UsCulture, out var value))
|
||||||
|
|
||||||
if (int.TryParse(parts[1], NumberStyles.Integer, UsCulture, out value))
|
|
||||||
{
|
{
|
||||||
return new ParentalRating { Name = parts[0], Value = value };
|
return new ParentalRating { Name = parts[0], Value = value };
|
||||||
}
|
}
|
||||||
@ -364,9 +360,7 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
|
|
||||||
var ratingsDictionary = GetParentalRatingsDictionary();
|
var ratingsDictionary = GetParentalRatingsDictionary();
|
||||||
|
|
||||||
ParentalRating value;
|
if (ratingsDictionary.TryGetValue(rating, out var value))
|
||||||
|
|
||||||
if (ratingsDictionary.TryGetValue(rating, out value))
|
|
||||||
{
|
{
|
||||||
return value.Value;
|
return value.Value;
|
||||||
}
|
}
|
||||||
@ -427,9 +421,7 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
|
|
||||||
var dictionary = GetLocalizationDictionary(culture);
|
var dictionary = GetLocalizationDictionary(culture);
|
||||||
|
|
||||||
string value;
|
if (dictionary.TryGetValue(phrase, out var value))
|
||||||
|
|
||||||
if (dictionary.TryGetValue(phrase, out value))
|
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -524,8 +524,7 @@ namespace System.Net
|
|||||||
}
|
}
|
||||||
|
|
||||||
var uintIpAddress = IPNetwork.ToBigInteger(ipaddress);
|
var uintIpAddress = IPNetwork.ToBigInteger(ipaddress);
|
||||||
byte? cidr2 = null;
|
bool parsed = IPNetwork.TryToCidr(netmask, out var cidr2);
|
||||||
bool parsed = IPNetwork.TryToCidr(netmask, out cidr2);
|
|
||||||
if (parsed == false)
|
if (parsed == false)
|
||||||
{
|
{
|
||||||
if (tryParse == false)
|
if (tryParse == false)
|
||||||
@ -615,8 +614,7 @@ namespace System.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static BigInteger ToBigInteger(IPAddress ipaddress)
|
public static BigInteger ToBigInteger(IPAddress ipaddress)
|
||||||
{
|
{
|
||||||
BigInteger? uintIpAddress = null;
|
IPNetwork.InternalToBigInteger(false, ipaddress, out var uintIpAddress);
|
||||||
IPNetwork.InternalToBigInteger(false, ipaddress, out uintIpAddress);
|
|
||||||
return (BigInteger)uintIpAddress;
|
return (BigInteger)uintIpAddress;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -630,8 +628,7 @@ namespace System.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool TryToBigInteger(IPAddress ipaddress, out BigInteger? uintIpAddress)
|
public static bool TryToBigInteger(IPAddress ipaddress, out BigInteger? uintIpAddress)
|
||||||
{
|
{
|
||||||
BigInteger? uintIpAddress2 = null;
|
IPNetwork.InternalToBigInteger(true, ipaddress, out var uintIpAddress2);
|
||||||
IPNetwork.InternalToBigInteger(true, ipaddress, out uintIpAddress2);
|
|
||||||
bool parsed = (uintIpAddress2 != null);
|
bool parsed = (uintIpAddress2 != null);
|
||||||
uintIpAddress = uintIpAddress2;
|
uintIpAddress = uintIpAddress2;
|
||||||
return parsed;
|
return parsed;
|
||||||
@ -681,9 +678,7 @@ namespace System.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static BigInteger ToUint(byte cidr, AddressFamily family)
|
public static BigInteger ToUint(byte cidr, AddressFamily family)
|
||||||
{
|
{
|
||||||
|
IPNetwork.InternalToBigInteger(false, cidr, family, out var uintNetmask);
|
||||||
BigInteger? uintNetmask = null;
|
|
||||||
IPNetwork.InternalToBigInteger(false, cidr, family, out uintNetmask);
|
|
||||||
return (BigInteger)uintNetmask;
|
return (BigInteger)uintNetmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,9 +690,7 @@ namespace System.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool TryToUint(byte cidr, AddressFamily family, out BigInteger? uintNetmask)
|
public static bool TryToUint(byte cidr, AddressFamily family, out BigInteger? uintNetmask)
|
||||||
{
|
{
|
||||||
|
IPNetwork.InternalToBigInteger(true, cidr, family, out var uintNetmask2);
|
||||||
BigInteger? uintNetmask2 = null;
|
|
||||||
IPNetwork.InternalToBigInteger(true, cidr, family, out uintNetmask2);
|
|
||||||
bool parsed = (uintNetmask2 != null);
|
bool parsed = (uintNetmask2 != null);
|
||||||
uintNetmask = uintNetmask2;
|
uintNetmask = uintNetmask2;
|
||||||
return parsed;
|
return parsed;
|
||||||
@ -812,8 +805,7 @@ namespace System.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static byte ToCidr(IPAddress netmask)
|
public static byte ToCidr(IPAddress netmask)
|
||||||
{
|
{
|
||||||
byte? cidr = null;
|
IPNetwork.InternalToCidr(false, netmask, out var cidr);
|
||||||
IPNetwork.InternalToCidr(false, netmask, out cidr);
|
|
||||||
return (byte)cidr;
|
return (byte)cidr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,8 +819,7 @@ namespace System.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool TryToCidr(IPAddress netmask, out byte? cidr)
|
public static bool TryToCidr(IPAddress netmask, out byte? cidr)
|
||||||
{
|
{
|
||||||
byte? cidr2 = null;
|
IPNetwork.InternalToCidr(true, netmask, out var cidr2);
|
||||||
IPNetwork.InternalToCidr(true, netmask, out cidr2);
|
|
||||||
bool parsed = (cidr2 != null);
|
bool parsed = (cidr2 != null);
|
||||||
cidr = cidr2;
|
cidr = cidr2;
|
||||||
return parsed;
|
return parsed;
|
||||||
@ -846,8 +837,8 @@ namespace System.Net
|
|||||||
cidr = null;
|
cidr = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BigInteger? uintNetmask2 = null;
|
|
||||||
bool parsed = IPNetwork.TryToBigInteger(netmask, out uintNetmask2);
|
bool parsed = IPNetwork.TryToBigInteger(netmask, out var uintNetmask2);
|
||||||
|
|
||||||
/// 20180217 lduchosal
|
/// 20180217 lduchosal
|
||||||
/// impossible to reach code.
|
/// impossible to reach code.
|
||||||
@ -860,8 +851,7 @@ namespace System.Net
|
|||||||
/// }
|
/// }
|
||||||
var uintNetmask = (BigInteger)uintNetmask2;
|
var uintNetmask = (BigInteger)uintNetmask2;
|
||||||
|
|
||||||
byte? cidr2 = null;
|
IPNetwork.InternalToCidr(tryParse, uintNetmask, netmask.AddressFamily, out var cidr2);
|
||||||
IPNetwork.InternalToCidr(tryParse, uintNetmask, netmask.AddressFamily, out cidr2);
|
|
||||||
cidr = cidr2;
|
cidr = cidr2;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1491,8 +1481,7 @@ namespace System.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IPNetwork[] Supernet(IPNetwork[] ipnetworks)
|
public static IPNetwork[] Supernet(IPNetwork[] ipnetworks)
|
||||||
{
|
{
|
||||||
IPNetwork[] supernet;
|
InternalSupernet(false, ipnetworks, out var supernet);
|
||||||
InternalSupernet(false, ipnetworks, out supernet);
|
|
||||||
return supernet;
|
return supernet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1642,14 +1631,12 @@ namespace System.Net
|
|||||||
throw new ArgumentNullException(nameof(end));
|
throw new ArgumentNullException(nameof(end));
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress startIP;
|
if (!IPAddress.TryParse(start, out var startIP))
|
||||||
if (!IPAddress.TryParse(start, out startIP))
|
|
||||||
{
|
{
|
||||||
throw new ArgumentException("start");
|
throw new ArgumentException("start");
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress endIP;
|
if (!IPAddress.TryParse(end, out var endIP))
|
||||||
if (!IPAddress.TryParse(end, out endIP))
|
|
||||||
{
|
{
|
||||||
throw new ArgumentException("end");
|
throw new ArgumentException("end");
|
||||||
}
|
}
|
||||||
|
@ -203,11 +203,9 @@ namespace Emby.Server.Implementations.Networking
|
|||||||
private Dictionary<string, List<string>> _subnetLookup = new Dictionary<string, List<string>>(StringComparer.Ordinal);
|
private Dictionary<string, List<string>> _subnetLookup = new Dictionary<string, List<string>>(StringComparer.Ordinal);
|
||||||
private List<string> GetSubnets(string endpointFirstPart)
|
private List<string> GetSubnets(string endpointFirstPart)
|
||||||
{
|
{
|
||||||
List<string> subnets;
|
|
||||||
|
|
||||||
lock (_subnetLookup)
|
lock (_subnetLookup)
|
||||||
{
|
{
|
||||||
if (_subnetLookup.TryGetValue(endpointFirstPart, out subnets))
|
if (_subnetLookup.TryGetValue(endpointFirstPart, out var subnets))
|
||||||
{
|
{
|
||||||
return subnets;
|
return subnets;
|
||||||
}
|
}
|
||||||
@ -298,8 +296,7 @@ namespace Emby.Server.Implementations.Networking
|
|||||||
throw new ArgumentNullException(nameof(endpoint));
|
throw new ArgumentNullException(nameof(endpoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress address;
|
if (IPAddress.TryParse(endpoint, out var address))
|
||||||
if (IPAddress.TryParse(endpoint, out address))
|
|
||||||
{
|
{
|
||||||
var addressString = address.ToString();
|
var addressString = address.ToString();
|
||||||
|
|
||||||
@ -348,8 +345,7 @@ namespace Emby.Server.Implementations.Networking
|
|||||||
}
|
}
|
||||||
else if (resolveHost)
|
else if (resolveHost)
|
||||||
{
|
{
|
||||||
Uri uri;
|
if (Uri.TryCreate(endpoint, UriKind.RelativeOrAbsolute, out var uri))
|
||||||
if (Uri.TryCreate(endpoint, UriKind.RelativeOrAbsolute, out uri))
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -588,9 +584,7 @@ namespace Emby.Server.Implementations.Networking
|
|||||||
/// <exception cref="FormatException"></exception>
|
/// <exception cref="FormatException"></exception>
|
||||||
private static int GetPort(string p)
|
private static int GetPort(string p)
|
||||||
{
|
{
|
||||||
int port;
|
if (!int.TryParse(p, out var port)
|
||||||
|
|
||||||
if (!int.TryParse(p, out port)
|
|
||||||
|| port < IPEndPoint.MinPort
|
|| port < IPEndPoint.MinPort
|
||||||
|| port > IPEndPoint.MaxPort)
|
|| port > IPEndPoint.MaxPort)
|
||||||
{
|
{
|
||||||
@ -618,8 +612,7 @@ namespace Emby.Server.Implementations.Networking
|
|||||||
|
|
||||||
public IpAddressInfo ParseIpAddress(string ipAddress)
|
public IpAddressInfo ParseIpAddress(string ipAddress)
|
||||||
{
|
{
|
||||||
IpAddressInfo info;
|
if (TryParseIpAddress(ipAddress, out var info))
|
||||||
if (TryParseIpAddress(ipAddress, out info))
|
|
||||||
{
|
{
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -629,8 +622,7 @@ namespace Emby.Server.Implementations.Networking
|
|||||||
|
|
||||||
public bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo)
|
public bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo)
|
||||||
{
|
{
|
||||||
IPAddress address;
|
if (IPAddress.TryParse(ipAddress, out var address))
|
||||||
if (IPAddress.TryParse(ipAddress, out address))
|
|
||||||
{
|
{
|
||||||
ipAddressInfo = ToIpAddressInfo(address);
|
ipAddressInfo = ToIpAddressInfo(address);
|
||||||
return true;
|
return true;
|
||||||
|
@ -364,8 +364,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||||||
{
|
{
|
||||||
var list = new List<Tuple<Type, TaskOptions>>();
|
var list = new List<Tuple<Type, TaskOptions>>();
|
||||||
|
|
||||||
Tuple<Type, TaskOptions> item;
|
while (_taskQueue.TryDequeue(out var item))
|
||||||
while (_taskQueue.TryDequeue(out item))
|
|
||||||
{
|
{
|
||||||
if (list.All(i => i.Item1 != item.Item1))
|
if (list.All(i => i.Item1 != item.Item1))
|
||||||
{
|
{
|
||||||
|
@ -68,9 +68,8 @@ namespace Emby.Server.Implementations.Security
|
|||||||
public void RemoveRegCheck(string featureId)
|
public void RemoveRegCheck(string featureId)
|
||||||
{
|
{
|
||||||
var key = GetKey(featureId);
|
var key = GetKey(featureId);
|
||||||
FeatureRegInfo val;
|
|
||||||
|
|
||||||
_updateRecords.TryRemove(key, out val);
|
_updateRecords.TryRemove(key, out var val);
|
||||||
|
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
@ -135,13 +134,11 @@ namespace Emby.Server.Implementations.Security
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Guid feat;
|
if (Guid.TryParse(line, out var feat))
|
||||||
if (Guid.TryParse(line, out feat))
|
|
||||||
{
|
{
|
||||||
var lineParts = contents[i + 1].Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
var lineParts = contents[i + 1].Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
long ticks;
|
if (long.TryParse(lineParts[0], out var ticks))
|
||||||
if (long.TryParse(lineParts[0], out ticks))
|
|
||||||
{
|
{
|
||||||
var info = new FeatureRegInfo
|
var info = new FeatureRegInfo
|
||||||
{
|
{
|
||||||
|
@ -33,8 +33,7 @@ namespace Emby.Server.Implementations.Serialization
|
|||||||
var key = type.FullName;
|
var key = type.FullName;
|
||||||
lock (_serializers)
|
lock (_serializers)
|
||||||
{
|
{
|
||||||
XmlSerializer serializer;
|
if (!_serializers.TryGetValue(key, out var serializer))
|
||||||
if (!_serializers.TryGetValue(key, out serializer))
|
|
||||||
{
|
{
|
||||||
serializer = new XmlSerializer(type);
|
serializer = new XmlSerializer(type);
|
||||||
_serializers[key] = serializer;
|
_serializers[key] = serializer;
|
||||||
|
@ -89,8 +89,7 @@ namespace Emby.Server.Implementations.Services
|
|||||||
if (restPath.Path.IndexOfAny(InvalidRouteChars) != -1)
|
if (restPath.Path.IndexOfAny(InvalidRouteChars) != -1)
|
||||||
throw new ArgumentException(string.Format("Route '{0}' on '{1}' contains invalid chars. ", restPath.Path, restPath.RequestType.GetMethodName()));
|
throw new ArgumentException(string.Format("Route '{0}' on '{1}' contains invalid chars. ", restPath.Path, restPath.RequestType.GetMethodName()));
|
||||||
|
|
||||||
List<RestPath> pathsAtFirstMatch;
|
if (!RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out var pathsAtFirstMatch))
|
||||||
if (!RestPathMap.TryGetValue(restPath.FirstMatchHashKey, out pathsAtFirstMatch))
|
|
||||||
{
|
{
|
||||||
pathsAtFirstMatch = new List<RestPath>();
|
pathsAtFirstMatch = new List<RestPath>();
|
||||||
RestPathMap[restPath.FirstMatchHashKey] = pathsAtFirstMatch;
|
RestPathMap[restPath.FirstMatchHashKey] = pathsAtFirstMatch;
|
||||||
|
@ -73,8 +73,7 @@ namespace Emby.Server.Implementations.Services
|
|||||||
{
|
{
|
||||||
var actionName = request.Verb ?? "POST";
|
var actionName = request.Verb ?? "POST";
|
||||||
|
|
||||||
ServiceMethod actionContext;
|
if (ServiceExecGeneral.execMap.TryGetValue(ServiceMethod.Key(serviceType, actionName, requestName), out var actionContext))
|
||||||
if (ServiceExecGeneral.execMap.TryGetValue(ServiceMethod.Key(serviceType, actionName, requestName), out actionContext))
|
|
||||||
{
|
{
|
||||||
if (actionContext.RequestFilters != null)
|
if (actionContext.RequestFilters != null)
|
||||||
{
|
{
|
||||||
|
@ -62,8 +62,7 @@ namespace Emby.Server.Implementations.Services
|
|||||||
{
|
{
|
||||||
if (this.RestPath == null)
|
if (this.RestPath == null)
|
||||||
{
|
{
|
||||||
string contentType;
|
this.RestPath = FindMatchingRestPath(httpMethod, pathInfo, out var contentType);
|
||||||
this.RestPath = FindMatchingRestPath(httpMethod, pathInfo, out contentType);
|
|
||||||
|
|
||||||
if (contentType != null)
|
if (contentType != null)
|
||||||
ResponseContentType = contentType;
|
ResponseContentType = contentType;
|
||||||
@ -137,9 +136,8 @@ namespace Emby.Server.Implementations.Services
|
|||||||
|
|
||||||
public static object CreateRequest(IRequest httpReq, RestPath restPath, Dictionary<string, string> requestParams, object requestDto)
|
public static object CreateRequest(IRequest httpReq, RestPath restPath, Dictionary<string, string> requestParams, object requestDto)
|
||||||
{
|
{
|
||||||
string contentType;
|
|
||||||
var pathInfo = !restPath.IsWildCardPath
|
var pathInfo = !restPath.IsWildCardPath
|
||||||
? GetSanitizedPathInfo(httpReq.PathInfo, out contentType)
|
? GetSanitizedPathInfo(httpReq.PathInfo, out var contentType)
|
||||||
: httpReq.PathInfo;
|
: httpReq.PathInfo;
|
||||||
|
|
||||||
return restPath.CreateRequest(pathInfo, requestParams, requestDto);
|
return restPath.CreateRequest(pathInfo, requestParams, requestDto);
|
||||||
@ -239,8 +237,7 @@ namespace Emby.Server.Implementations.Services
|
|||||||
|
|
||||||
private static RestPath GetRoute(IRequest req)
|
private static RestPath GetRoute(IRequest req)
|
||||||
{
|
{
|
||||||
object route;
|
req.Items.TryGetValue("__route", out var route);
|
||||||
req.Items.TryGetValue("__route", out route);
|
|
||||||
return route as RestPath;
|
return route as RestPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,8 +306,7 @@ namespace Emby.Server.Implementations.Services
|
|||||||
|
|
||||||
public int MatchScore(string httpMethod, string[] withPathInfoParts)
|
public int MatchScore(string httpMethod, string[] withPathInfoParts)
|
||||||
{
|
{
|
||||||
int wildcardMatchCount;
|
var isMatch = IsMatch(httpMethod, withPathInfoParts, out var wildcardMatchCount);
|
||||||
var isMatch = IsMatch(httpMethod, withPathInfoParts, out wildcardMatchCount);
|
|
||||||
if (!isMatch)
|
if (!isMatch)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -484,8 +483,7 @@ namespace Emby.Server.Implementations.Services
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string propertyNameOnRequest;
|
if (!this.propertyNamesMap.TryGetValue(variableName.ToLower(), out var propertyNameOnRequest))
|
||||||
if (!this.propertyNamesMap.TryGetValue(variableName.ToLower(), out propertyNameOnRequest))
|
|
||||||
{
|
{
|
||||||
if (string.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals("ignore", variableName, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -265,8 +265,7 @@ namespace Emby.Server.Implementations.Session
|
|||||||
{
|
{
|
||||||
var key = GetSessionKey(session.Client, session.DeviceId);
|
var key = GetSessionKey(session.Client, session.DeviceId);
|
||||||
|
|
||||||
SessionInfo removed;
|
_activeConnections.TryRemove(key, out var removed);
|
||||||
_activeConnections.TryRemove(key, out removed);
|
|
||||||
|
|
||||||
OnSessionEnded(session);
|
OnSessionEnded(session);
|
||||||
}
|
}
|
||||||
@ -281,8 +280,7 @@ namespace Emby.Server.Implementations.Session
|
|||||||
{
|
{
|
||||||
var key = GetSessionKey(session.Client, session.DeviceId);
|
var key = GetSessionKey(session.Client, session.DeviceId);
|
||||||
|
|
||||||
SessionInfo removed;
|
_activeConnections.TryRemove(key, out var removed);
|
||||||
_activeConnections.TryRemove(key, out removed);
|
|
||||||
|
|
||||||
OnSessionEnded(session);
|
OnSessionEnded(session);
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,7 @@ namespace NLangDetect.Core
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
double value;
|
return _dict.TryGetValue(key, out var value) ? value : 0.0;
|
||||||
|
|
||||||
return _dict.TryGetValue(key, out value) ? value : 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
|
@ -18,10 +18,8 @@ namespace NLangDetect.Core.Utils
|
|||||||
|
|
||||||
public static string getString(string key)
|
public static string getString(string key)
|
||||||
{
|
{
|
||||||
string value;
|
|
||||||
|
|
||||||
return
|
return
|
||||||
_messages.TryGetValue(key, out value)
|
_messages.TryGetValue(key, out var value)
|
||||||
? value
|
? value
|
||||||
: string.Format("!{0}!", key);
|
: string.Format("!{0}!", key);
|
||||||
}
|
}
|
||||||
|
@ -317,9 +317,7 @@ namespace Emby.Server.Implementations.Updates
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Version requiredVersion;
|
return Version.TryParse(packageVersionInfo.requiredVersionStr, out var requiredVersion) && currentServerVersion >= requiredVersion;
|
||||||
|
|
||||||
return Version.TryParse(packageVersionInfo.requiredVersionStr, out requiredVersion) && currentServerVersion >= requiredVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -140,8 +140,7 @@ namespace Emby.XmlTv.Classes
|
|||||||
private void SetChannelNumber(XmlTvChannel channel, string value)
|
private void SetChannelNumber(XmlTvChannel channel, string value)
|
||||||
{
|
{
|
||||||
value = value.Replace("-", ".");
|
value = value.Replace("-", ".");
|
||||||
double number;
|
if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var number))
|
||||||
if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
|
|
||||||
{
|
{
|
||||||
channel.Number = value;
|
channel.Number = value;
|
||||||
}
|
}
|
||||||
@ -426,8 +425,7 @@ namespace Emby.XmlTv.Classes
|
|||||||
if (textValue.Contains("/"))
|
if (textValue.Contains("/"))
|
||||||
{
|
{
|
||||||
var components = textValue.Split('/');
|
var components = textValue.Split('/');
|
||||||
float value;
|
if (float.TryParse(components[0], out var value))
|
||||||
if (float.TryParse(components[0], out value))
|
|
||||||
{
|
{
|
||||||
result.StarRating = value;
|
result.StarRating = value;
|
||||||
}
|
}
|
||||||
@ -1053,8 +1051,7 @@ namespace Emby.XmlTv.Classes
|
|||||||
}
|
}
|
||||||
|
|
||||||
var standardDate = string.Format("{0} {1}", dateComponent, dateOffset);
|
var standardDate = string.Format("{0} {1}", dateComponent, dateOffset);
|
||||||
DateTimeOffset parsedDateTime;
|
if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out var parsedDateTime))
|
||||||
if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out parsedDateTime))
|
|
||||||
{
|
{
|
||||||
return parsedDateTime.ToUniversalTime();
|
return parsedDateTime.ToUniversalTime();
|
||||||
}
|
}
|
||||||
|
@ -148,9 +148,7 @@ namespace Jellyfin.SocketSharp
|
|||||||
|
|
||||||
internal static bool IsInvalidString(string val)
|
internal static bool IsInvalidString(string val)
|
||||||
{
|
{
|
||||||
int validationFailureIndex;
|
return IsInvalidString(val, out var validationFailureIndex);
|
||||||
|
|
||||||
return IsInvalidString(val, out validationFailureIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsInvalidString(string val, out int validationFailureIndex)
|
internal static bool IsInvalidString(string val, out int validationFailureIndex)
|
||||||
|
@ -101,8 +101,7 @@ namespace MediaBrowser.Api
|
|||||||
{
|
{
|
||||||
lock (_transcodingLocks)
|
lock (_transcodingLocks)
|
||||||
{
|
{
|
||||||
SemaphoreSlim result;
|
if (!_transcodingLocks.TryGetValue(outputPath, out var result))
|
||||||
if (!_transcodingLocks.TryGetValue(outputPath, out result))
|
|
||||||
{
|
{
|
||||||
result = new SemaphoreSlim(1, 1);
|
result = new SemaphoreSlim(1, 1);
|
||||||
_transcodingLocks[outputPath] = result;
|
_transcodingLocks[outputPath] = result;
|
||||||
|
@ -37,9 +37,7 @@ namespace MediaBrowser.Api
|
|||||||
|
|
||||||
return val.Split(',').Select(v =>
|
return val.Split(',').Select(v =>
|
||||||
{
|
{
|
||||||
ItemFields value;
|
if (Enum.TryParse(v, true, out ItemFields value))
|
||||||
|
|
||||||
if (Enum.TryParse(v, true, out value))
|
|
||||||
{
|
{
|
||||||
return (ItemFields?)value;
|
return (ItemFields?)value;
|
||||||
}
|
}
|
||||||
|
@ -659,8 +659,7 @@ namespace MediaBrowser.Api.Images
|
|||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(request.Format))
|
if (!string.IsNullOrWhiteSpace(request.Format))
|
||||||
{
|
{
|
||||||
ImageFormat format;
|
if (Enum.TryParse(request.Format, true, out ImageFormat format))
|
||||||
if (Enum.TryParse(request.Format, true, out format))
|
|
||||||
{
|
{
|
||||||
return new ImageFormat[] { format };
|
return new ImageFormat[] { format };
|
||||||
}
|
}
|
||||||
|
@ -531,8 +531,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(val) && videoRequest != null)
|
if (!string.IsNullOrWhiteSpace(val) && videoRequest != null)
|
||||||
{
|
{
|
||||||
SubtitleDeliveryMethod method;
|
if (Enum.TryParse(val, out SubtitleDeliveryMethod method))
|
||||||
if (Enum.TryParse(val, out method))
|
|
||||||
{
|
{
|
||||||
videoRequest.SubtitleMethod = method;
|
videoRequest.SubtitleMethod = method;
|
||||||
}
|
}
|
||||||
@ -636,8 +635,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
if (value.IndexOf(':') == -1)
|
if (value.IndexOf(':') == -1)
|
||||||
{
|
{
|
||||||
// Parses npt times in the format of '417.33'
|
// Parses npt times in the format of '417.33'
|
||||||
double seconds;
|
if (double.TryParse(value, NumberStyles.Any, UsCulture, out var seconds))
|
||||||
if (double.TryParse(value, NumberStyles.Any, UsCulture, out seconds))
|
|
||||||
{
|
{
|
||||||
return TimeSpan.FromSeconds(seconds).Ticks;
|
return TimeSpan.FromSeconds(seconds).Ticks;
|
||||||
}
|
}
|
||||||
@ -652,8 +650,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
|
|
||||||
foreach (var time in tokens)
|
foreach (var time in tokens)
|
||||||
{
|
{
|
||||||
double digit;
|
if (double.TryParse(time, NumberStyles.Any, UsCulture, out var digit))
|
||||||
if (double.TryParse(time, NumberStyles.Any, UsCulture, out digit))
|
|
||||||
{
|
{
|
||||||
secondsSum += digit * timeFactor;
|
secondsSum += digit * timeFactor;
|
||||||
}
|
}
|
||||||
|
@ -413,10 +413,9 @@ namespace MediaBrowser.Api.Session
|
|||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
public Task Post(SendSystemCommand request)
|
public Task Post(SendSystemCommand request)
|
||||||
{
|
{
|
||||||
GeneralCommandType commandType;
|
|
||||||
var name = request.Command;
|
var name = request.Command;
|
||||||
|
|
||||||
if (Enum.TryParse(name, true, out commandType))
|
if (Enum.TryParse(name, true, out GeneralCommandType commandType))
|
||||||
{
|
{
|
||||||
name = commandType.ToString();
|
name = commandType.ToString();
|
||||||
}
|
}
|
||||||
|
@ -102,9 +102,7 @@ namespace MediaBrowser.Common.Net
|
|||||||
|
|
||||||
private string GetHeaderValue(string name)
|
private string GetHeaderValue(string name)
|
||||||
{
|
{
|
||||||
string value;
|
RequestHeaders.TryGetValue(name, out var value);
|
||||||
|
|
||||||
RequestHeaders.TryGetValue(name, out value);
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
{
|
{
|
||||||
lock (LibraryOptions)
|
lock (LibraryOptions)
|
||||||
{
|
{
|
||||||
LibraryOptions options;
|
if (!LibraryOptions.TryGetValue(path, out var options))
|
||||||
if (!LibraryOptions.TryGetValue(path, out options))
|
|
||||||
{
|
{
|
||||||
options = LoadLibraryOptions(path);
|
options = LoadLibraryOptions(path);
|
||||||
LibraryOptions[path] = options;
|
LibraryOptions[path] = options;
|
||||||
|
@ -331,9 +331,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
foreach (var child in nonCachedChildren)
|
foreach (var child in nonCachedChildren)
|
||||||
{
|
{
|
||||||
BaseItem currentChild;
|
if (currentChildren.TryGetValue(child.Id, out var currentChild))
|
||||||
|
|
||||||
if (currentChildren.TryGetValue(child.Id, out currentChild))
|
|
||||||
{
|
{
|
||||||
validChildren.Add(currentChild);
|
validChildren.Add(currentChild);
|
||||||
|
|
||||||
|
@ -50,11 +50,9 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
public IList<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
public IList<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
int year;
|
|
||||||
|
|
||||||
var usCulture = new CultureInfo("en-US");
|
var usCulture = new CultureInfo("en-US");
|
||||||
|
|
||||||
if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out year))
|
if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out var year))
|
||||||
{
|
{
|
||||||
return new List<BaseItem>();
|
return new List<BaseItem>();
|
||||||
}
|
}
|
||||||
@ -66,9 +64,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
public int? GetYearValue()
|
public int? GetYearValue()
|
||||||
{
|
{
|
||||||
int i;
|
if (int.TryParse(Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out var i))
|
||||||
|
|
||||||
if (int.TryParse(Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out i))
|
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,7 @@ namespace MediaBrowser.Controller.Library
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
DayOfWeek value;
|
if (Enum.TryParse(day, true, out DayOfWeek value))
|
||||||
|
|
||||||
if (Enum.TryParse(day, true, out value))
|
|
||||||
{
|
{
|
||||||
return new DayOfWeek[]
|
return new DayOfWeek[]
|
||||||
{
|
{
|
||||||
|
@ -943,9 +943,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
var level = state.GetRequestedLevel(videoStream.Codec);
|
var level = state.GetRequestedLevel(videoStream.Codec);
|
||||||
if (!string.IsNullOrEmpty(level))
|
if (!string.IsNullOrEmpty(level))
|
||||||
{
|
{
|
||||||
double requestLevel;
|
if (double.TryParse(level, NumberStyles.Any, _usCulture, out var requestLevel))
|
||||||
|
|
||||||
if (double.TryParse(level, NumberStyles.Any, _usCulture, out requestLevel))
|
|
||||||
{
|
{
|
||||||
if (!videoStream.Level.HasValue)
|
if (!videoStream.Level.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -193,8 +193,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
if (!string.IsNullOrEmpty(codec))
|
if (!string.IsNullOrEmpty(codec))
|
||||||
{
|
{
|
||||||
var value = BaseRequest.GetOption(codec, "maxrefframes");
|
var value = BaseRequest.GetOption(codec, "maxrefframes");
|
||||||
int result;
|
if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
|
||||||
if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -213,8 +212,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
if (!string.IsNullOrEmpty(codec))
|
if (!string.IsNullOrEmpty(codec))
|
||||||
{
|
{
|
||||||
var value = BaseRequest.GetOption(codec, "videobitdepth");
|
var value = BaseRequest.GetOption(codec, "videobitdepth");
|
||||||
int result;
|
if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
|
||||||
if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -233,8 +231,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
if (!string.IsNullOrEmpty(codec))
|
if (!string.IsNullOrEmpty(codec))
|
||||||
{
|
{
|
||||||
var value = BaseRequest.GetOption(codec, "audiobitdepth");
|
var value = BaseRequest.GetOption(codec, "audiobitdepth");
|
||||||
int result;
|
if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
|
||||||
if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -257,8 +254,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
if (!string.IsNullOrEmpty(codec))
|
if (!string.IsNullOrEmpty(codec))
|
||||||
{
|
{
|
||||||
var value = BaseRequest.GetOption(codec, "audiochannels");
|
var value = BaseRequest.GetOption(codec, "audiochannels");
|
||||||
int result;
|
if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
|
||||||
if (!string.IsNullOrEmpty(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -419,8 +415,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
}
|
}
|
||||||
|
|
||||||
var level = GetRequestedLevel(ActualOutputVideoCodec);
|
var level = GetRequestedLevel(ActualOutputVideoCodec);
|
||||||
double result;
|
if (!string.IsNullOrEmpty(level) && double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
|
||||||
if (!string.IsNullOrEmpty(level) && double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -228,8 +228,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
|
|
||||||
public string GetOption(string name)
|
public string GetOption(string name)
|
||||||
{
|
{
|
||||||
string value;
|
if (StreamOptions.TryGetValue(name, out var value))
|
||||||
if (StreamOptions.TryGetValue(name, out value))
|
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -74,9 +74,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
(i + 1 < parts.Length))
|
(i + 1 < parts.Length))
|
||||||
{
|
{
|
||||||
var rate = parts[i + 1];
|
var rate = parts[i + 1];
|
||||||
float val;
|
|
||||||
|
|
||||||
if (float.TryParse(rate, NumberStyles.Any, _usCulture, out val))
|
if (float.TryParse(rate, NumberStyles.Any, _usCulture, out var val))
|
||||||
{
|
{
|
||||||
framerate = val;
|
framerate = val;
|
||||||
}
|
}
|
||||||
@ -85,9 +84,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
part.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
|
part.StartsWith("time=", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var time = part.Split(new[] { '=' }, 2).Last();
|
var time = part.Split(new[] { '=' }, 2).Last();
|
||||||
TimeSpan val;
|
|
||||||
|
|
||||||
if (TimeSpan.TryParse(time, _usCulture, out val))
|
if (TimeSpan.TryParse(time, _usCulture, out var val))
|
||||||
{
|
{
|
||||||
var currentMs = startMs + val.TotalMilliseconds;
|
var currentMs = startMs + val.TotalMilliseconds;
|
||||||
|
|
||||||
@ -110,9 +108,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
|
|
||||||
if (scale.HasValue)
|
if (scale.HasValue)
|
||||||
{
|
{
|
||||||
long val;
|
if (long.TryParse(size, NumberStyles.Any, _usCulture, out var val))
|
||||||
|
|
||||||
if (long.TryParse(size, NumberStyles.Any, _usCulture, out val))
|
|
||||||
{
|
{
|
||||||
bytesTranscoded = val * scale.Value;
|
bytesTranscoded = val * scale.Value;
|
||||||
}
|
}
|
||||||
@ -131,9 +127,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
|
|
||||||
if (scale.HasValue)
|
if (scale.HasValue)
|
||||||
{
|
{
|
||||||
float val;
|
if (float.TryParse(rate, NumberStyles.Any, _usCulture, out var val))
|
||||||
|
|
||||||
if (float.TryParse(rate, NumberStyles.Any, _usCulture, out val))
|
|
||||||
{
|
{
|
||||||
bitRate = (int)Math.Ceiling(val * scale.Value);
|
bitRate = (int)Math.Ceiling(val * scale.Value);
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
|
|
||||||
public FileSystemMetadata[] GetFileSystemEntries(string path)
|
public FileSystemMetadata[] GetFileSystemEntries(string path)
|
||||||
{
|
{
|
||||||
FileSystemMetadata[] entries;
|
if (!_cache.TryGetValue(path, out var entries))
|
||||||
|
|
||||||
if (!_cache.TryGetValue(path, out entries))
|
|
||||||
{
|
{
|
||||||
//_logger.LogDebug("Getting files for " + path);
|
//_logger.LogDebug("Getting files for " + path);
|
||||||
|
|
||||||
@ -56,8 +54,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
|
|
||||||
public FileSystemMetadata GetFile(string path)
|
public FileSystemMetadata GetFile(string path)
|
||||||
{
|
{
|
||||||
FileSystemMetadata file;
|
if (!_fileCache.TryGetValue(path, out var file))
|
||||||
if (!_fileCache.TryGetValue(path, out file))
|
|
||||||
{
|
{
|
||||||
file = _fileSystem.GetFileInfo(path);
|
file = _fileSystem.GetFileInfo(path);
|
||||||
|
|
||||||
@ -83,8 +80,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
|
|
||||||
public List<string> GetFilePaths(string path, bool clearCache)
|
public List<string> GetFilePaths(string path, bool clearCache)
|
||||||
{
|
{
|
||||||
List<string> result;
|
if (clearCache || !_filePathCache.TryGetValue(path, out var result))
|
||||||
if (clearCache || !_filePathCache.TryGetValue(path, out result))
|
|
||||||
{
|
{
|
||||||
result = _fileSystem.GetFilePaths(path).ToList();
|
result = _fileSystem.GetFilePaths(path).ToList();
|
||||||
|
|
||||||
|
@ -151,8 +151,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(val))
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
{
|
{
|
||||||
DateTime added;
|
if (DateTime.TryParse(val, out var added))
|
||||||
if (DateTime.TryParse(val, out added))
|
|
||||||
{
|
{
|
||||||
item.DateCreated = added.ToUniversalTime();
|
item.DateCreated = added.ToUniversalTime();
|
||||||
}
|
}
|
||||||
@ -185,8 +184,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(text))
|
if (!string.IsNullOrEmpty(text))
|
||||||
{
|
{
|
||||||
float value;
|
if (float.TryParse(text, NumberStyles.Any, _usCulture, out var value))
|
||||||
if (float.TryParse(text, NumberStyles.Any, _usCulture, out value))
|
|
||||||
{
|
{
|
||||||
item.CriticRating = value;
|
item.CriticRating = value;
|
||||||
}
|
}
|
||||||
@ -261,9 +259,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
{
|
{
|
||||||
item.LockedFields = val.Split('|').Select(i =>
|
item.LockedFields = val.Split('|').Select(i =>
|
||||||
{
|
{
|
||||||
MetadataFields field;
|
if (Enum.TryParse(i, true, out MetadataFields field))
|
||||||
|
|
||||||
if (Enum.TryParse(i, true, out field))
|
|
||||||
{
|
{
|
||||||
return (MetadataFields?)field;
|
return (MetadataFields?)field;
|
||||||
}
|
}
|
||||||
@ -337,8 +333,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(text))
|
if (!string.IsNullOrWhiteSpace(text))
|
||||||
{
|
{
|
||||||
int runtime;
|
if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out var runtime))
|
||||||
if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out runtime))
|
|
||||||
{
|
{
|
||||||
item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks;
|
item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks;
|
||||||
}
|
}
|
||||||
@ -494,8 +489,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(val))
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
{
|
{
|
||||||
int productionYear;
|
if (int.TryParse(val, out var productionYear) && productionYear > 1850)
|
||||||
if (int.TryParse(val, out productionYear) && productionYear > 1850)
|
|
||||||
{
|
{
|
||||||
item.ProductionYear = productionYear;
|
item.ProductionYear = productionYear;
|
||||||
}
|
}
|
||||||
@ -512,9 +506,8 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(rating))
|
if (!string.IsNullOrWhiteSpace(rating))
|
||||||
{
|
{
|
||||||
float val;
|
|
||||||
// All external meta is saving this as '.' for decimal I believe...but just to be sure
|
// All external meta is saving this as '.' for decimal I believe...but just to be sure
|
||||||
if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out val))
|
if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var val))
|
||||||
{
|
{
|
||||||
item.CommunityRating = val;
|
item.CommunityRating = val;
|
||||||
}
|
}
|
||||||
@ -530,9 +523,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(firstAired))
|
if (!string.IsNullOrWhiteSpace(firstAired))
|
||||||
{
|
{
|
||||||
DateTime airDate;
|
if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var airDate) && airDate.Year > 1850)
|
||||||
|
|
||||||
if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out airDate) && airDate.Year > 1850)
|
|
||||||
{
|
{
|
||||||
item.PremiereDate = airDate.ToUniversalTime();
|
item.PremiereDate = airDate.ToUniversalTime();
|
||||||
item.ProductionYear = airDate.Year;
|
item.ProductionYear = airDate.Year;
|
||||||
@ -549,9 +540,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(firstAired))
|
if (!string.IsNullOrWhiteSpace(firstAired))
|
||||||
{
|
{
|
||||||
DateTime airDate;
|
if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var airDate) && airDate.Year > 1850)
|
||||||
|
|
||||||
if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out airDate) && airDate.Year > 1850)
|
|
||||||
{
|
{
|
||||||
item.EndDate = airDate.ToUniversalTime();
|
item.EndDate = airDate.ToUniversalTime();
|
||||||
}
|
}
|
||||||
@ -687,8 +676,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
string readerName = reader.Name;
|
string readerName = reader.Name;
|
||||||
string providerIdValue;
|
if (_validProviderIds.TryGetValue(readerName, out var providerIdValue))
|
||||||
if (_validProviderIds.TryGetValue(readerName, out providerIdValue))
|
|
||||||
{
|
{
|
||||||
var id = reader.ReadElementContentAsString();
|
var id = reader.ReadElementContentAsString();
|
||||||
if (!string.IsNullOrWhiteSpace(id))
|
if (!string.IsNullOrWhiteSpace(id))
|
||||||
@ -1127,8 +1115,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(val))
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
{
|
{
|
||||||
int intVal;
|
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var intVal))
|
||||||
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out intVal))
|
|
||||||
{
|
{
|
||||||
sortOrder = intVal;
|
sortOrder = intVal;
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
|
|||||||
var val = reader.ReadElementContentAsString();
|
var val = reader.ReadElementContentAsString();
|
||||||
if (!string.IsNullOrWhiteSpace(val))
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
{
|
{
|
||||||
int num;
|
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var num))
|
||||||
|
|
||||||
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out num))
|
|
||||||
{
|
{
|
||||||
item.PlayersSupported = num;
|
item.PlayersSupported = num;
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string val;
|
tags.TryGetValue(key, out var val);
|
||||||
|
|
||||||
tags.TryGetValue(key, out val);
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +68,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(val))
|
if (!string.IsNullOrEmpty(val))
|
||||||
{
|
{
|
||||||
int i;
|
if (int.TryParse(val, out var i))
|
||||||
|
|
||||||
if (int.TryParse(val, out i))
|
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -93,9 +89,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(val))
|
if (!string.IsNullOrEmpty(val))
|
||||||
{
|
{
|
||||||
DateTime i;
|
if (DateTime.TryParse(val, out var i))
|
||||||
|
|
||||||
if (DateTime.TryParse(val, out i))
|
|
||||||
{
|
{
|
||||||
return i.ToUniversalTime();
|
return i.ToUniversalTime();
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(data.format.bit_rate))
|
if (!string.IsNullOrEmpty(data.format.bit_rate))
|
||||||
{
|
{
|
||||||
int value;
|
if (int.TryParse(data.format.bit_rate, NumberStyles.Any, _usCulture, out var value))
|
||||||
if (int.TryParse(data.format.bit_rate, NumberStyles.Any, _usCulture, out value))
|
|
||||||
{
|
{
|
||||||
info.Bitrate = value;
|
info.Bitrate = value;
|
||||||
}
|
}
|
||||||
@ -579,8 +578,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(streamInfo.sample_rate))
|
if (!string.IsNullOrEmpty(streamInfo.sample_rate))
|
||||||
{
|
{
|
||||||
int value;
|
if (int.TryParse(streamInfo.sample_rate, NumberStyles.Any, _usCulture, out var value))
|
||||||
if (int.TryParse(streamInfo.sample_rate, NumberStyles.Any, _usCulture, out value))
|
|
||||||
{
|
{
|
||||||
stream.SampleRate = value;
|
stream.SampleRate = value;
|
||||||
}
|
}
|
||||||
@ -669,8 +667,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(streamInfo.bit_rate))
|
if (!string.IsNullOrEmpty(streamInfo.bit_rate))
|
||||||
{
|
{
|
||||||
int value;
|
if (int.TryParse(streamInfo.bit_rate, NumberStyles.Any, _usCulture, out var value))
|
||||||
if (int.TryParse(streamInfo.bit_rate, NumberStyles.Any, _usCulture, out value))
|
|
||||||
{
|
{
|
||||||
bitrate = 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 (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
|
// 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 var value))
|
||||||
if (int.TryParse(formatInfo.bit_rate, NumberStyles.Any, _usCulture, out value))
|
|
||||||
{
|
{
|
||||||
bitrate = value;
|
bitrate = value;
|
||||||
}
|
}
|
||||||
@ -732,9 +728,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string val;
|
tags.TryGetValue(key, out var val);
|
||||||
|
|
||||||
tags.TryGetValue(key, out val);
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,13 +746,10 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
{
|
{
|
||||||
var original = info.display_aspect_ratio;
|
var original = info.display_aspect_ratio;
|
||||||
|
|
||||||
int height;
|
|
||||||
int width;
|
|
||||||
|
|
||||||
var parts = (original ?? string.Empty).Split(':');
|
var parts = (original ?? string.Empty).Split(':');
|
||||||
if (!(parts.Length == 2 &&
|
if (!(parts.Length == 2 &&
|
||||||
int.TryParse(parts[0], NumberStyles.Any, _usCulture, out width) &&
|
int.TryParse(parts[0], NumberStyles.Any, _usCulture, out var width) &&
|
||||||
int.TryParse(parts[1], NumberStyles.Any, _usCulture, out height) &&
|
int.TryParse(parts[1], NumberStyles.Any, _usCulture, out var height) &&
|
||||||
width > 0 &&
|
width > 0 &&
|
||||||
height > 0))
|
height > 0))
|
||||||
{
|
{
|
||||||
@ -1187,9 +1178,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
{
|
{
|
||||||
disc = disc.Split('/')[0];
|
disc = disc.Split('/')[0];
|
||||||
|
|
||||||
int num;
|
if (int.TryParse(disc, out var num))
|
||||||
|
|
||||||
if (int.TryParse(disc, out num))
|
|
||||||
{
|
{
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
@ -1204,8 +1193,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
|
|
||||||
if (chapter.tags != null)
|
if (chapter.tags != null)
|
||||||
{
|
{
|
||||||
string name;
|
if (chapter.tags.TryGetValue("title", out var name))
|
||||||
if (chapter.tags.TryGetValue("title", out name))
|
|
||||||
{
|
{
|
||||||
info.Name = name;
|
info.Name = name;
|
||||||
}
|
}
|
||||||
@ -1213,9 +1201,8 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
|
|
||||||
// Limit accuracy to milliseconds to match xml saving
|
// Limit accuracy to milliseconds to match xml saving
|
||||||
var secondsString = chapter.start_time;
|
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);
|
var ms = Math.Round(TimeSpan.FromSeconds(seconds).TotalMilliseconds);
|
||||||
info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
|
info.StartPositionTicks = TimeSpan.FromMilliseconds(ms).Ticks;
|
||||||
@ -1269,9 +1256,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
var year = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/OriginalReleaseTime");
|
var year = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/OriginalReleaseTime");
|
||||||
if (!string.IsNullOrWhiteSpace(year))
|
if (!string.IsNullOrWhiteSpace(year))
|
||||||
{
|
{
|
||||||
int val;
|
if (int.TryParse(year, NumberStyles.Integer, _usCulture, out var val))
|
||||||
|
|
||||||
if (int.TryParse(year, NumberStyles.Integer, _usCulture, out val))
|
|
||||||
{
|
{
|
||||||
video.ProductionYear = val;
|
video.ProductionYear = val;
|
||||||
}
|
}
|
||||||
@ -1280,11 +1265,9 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
var premiereDateString = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/MediaOriginalBroadcastDateTime");
|
var premiereDateString = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/MediaOriginalBroadcastDateTime");
|
||||||
if (!string.IsNullOrWhiteSpace(premiereDateString))
|
if (!string.IsNullOrWhiteSpace(premiereDateString))
|
||||||
{
|
{
|
||||||
DateTime val;
|
|
||||||
|
|
||||||
// Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
|
// Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
|
||||||
// DateTime is reported along with timezone info (typically Z i.e. UTC hence assume None)
|
// 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();
|
video.PremiereDate = val.ToUniversalTime();
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
|
|
||||||
long GetTicks(string time)
|
long GetTicks(string time)
|
||||||
{
|
{
|
||||||
TimeSpan span;
|
return TimeSpan.TryParseExact(time, @"h\:mm\:ss\.ff", _usCulture, out var span)
|
||||||
return TimeSpan.TryParseExact(time, @"h\:mm\:ss\.ff", _usCulture, out span)
|
|
||||||
? span.Ticks : 0;
|
? span.Ticks : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +83,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
|
|
||||||
long GetTicks(string time)
|
long GetTicks(string time)
|
||||||
{
|
{
|
||||||
TimeSpan span;
|
return TimeSpan.TryParseExact(time, @"hh\:mm\:ss\.fff", _usCulture, out var span)
|
||||||
return TimeSpan.TryParseExact(time, @"hh\:mm\:ss\.fff", _usCulture, out span)
|
|
||||||
? span.Ticks
|
? span.Ticks
|
||||||
: (TimeSpan.TryParseExact(time, @"hh\:mm\:ss\,fff", _usCulture, out span)
|
: (TimeSpan.TryParseExact(time, @"hh\:mm\:ss\,fff", _usCulture, out span)
|
||||||
? span.Ticks : 0);
|
? span.Ticks : 0);
|
||||||
|
@ -288,8 +288,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
|
|
||||||
private static bool IsInteger(string s)
|
private static bool IsInteger(string s)
|
||||||
{
|
{
|
||||||
int i;
|
if (int.TryParse(s, out var i))
|
||||||
if (int.TryParse(s, out i))
|
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,7 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageOption[] options;
|
if (DefaultImageOptions.TryGetValue(Type, out var options))
|
||||||
if (DefaultImageOptions.TryGetValue(Type, out options))
|
|
||||||
{
|
{
|
||||||
foreach (var i in options)
|
foreach (var i in options)
|
||||||
{
|
{
|
||||||
|
@ -129,8 +129,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return !condition.IsRequired;
|
return !condition.IsRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
int expected;
|
if (int.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var expected))
|
||||||
if (int.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out expected))
|
|
||||||
{
|
{
|
||||||
switch (condition.Condition)
|
switch (condition.Condition)
|
||||||
{
|
{
|
||||||
@ -184,8 +183,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return !condition.IsRequired;
|
return !condition.IsRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool expected;
|
if (bool.TryParse(condition.Value, out var expected))
|
||||||
if (bool.TryParse(condition.Value, out expected))
|
|
||||||
{
|
{
|
||||||
switch (condition.Condition)
|
switch (condition.Condition)
|
||||||
{
|
{
|
||||||
@ -209,8 +207,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return !condition.IsRequired;
|
return !condition.IsRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
float expected;
|
if (float.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var expected))
|
||||||
if (float.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out expected))
|
|
||||||
{
|
{
|
||||||
switch (condition.Condition)
|
switch (condition.Condition)
|
||||||
{
|
{
|
||||||
@ -238,8 +235,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return !condition.IsRequired;
|
return !condition.IsRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
double expected;
|
if (double.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var expected))
|
||||||
if (double.TryParse(condition.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out expected))
|
|
||||||
{
|
{
|
||||||
switch (condition.Condition)
|
switch (condition.Condition)
|
||||||
{
|
{
|
||||||
|
@ -688,8 +688,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(transcodingProfile.MaxAudioChannels))
|
if (!string.IsNullOrEmpty(transcodingProfile.MaxAudioChannels))
|
||||||
{
|
{
|
||||||
int transcodingMaxAudioChannels;
|
if (int.TryParse(transcodingProfile.MaxAudioChannels, NumberStyles.Any, CultureInfo.InvariantCulture, out var transcodingMaxAudioChannels))
|
||||||
if (int.TryParse(transcodingProfile.MaxAudioChannels, NumberStyles.Any, CultureInfo.InvariantCulture, out transcodingMaxAudioChannels))
|
|
||||||
{
|
{
|
||||||
playlistItem.TranscodingMaxAudioChannels = transcodingMaxAudioChannels;
|
playlistItem.TranscodingMaxAudioChannels = transcodingMaxAudioChannels;
|
||||||
}
|
}
|
||||||
@ -1491,8 +1490,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num;
|
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
if (condition.Condition == ProfileConditionType.Equals)
|
if (condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1526,8 +1524,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int num;
|
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
if (condition.Condition == ProfileConditionType.Equals)
|
if (condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1551,8 +1548,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAvc;
|
if (bool.TryParse(value, out var isAvc))
|
||||||
if (bool.TryParse(value, out isAvc))
|
|
||||||
{
|
{
|
||||||
if (isAvc && condition.Condition == ProfileConditionType.Equals)
|
if (isAvc && condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1572,8 +1568,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAnamorphic;
|
if (bool.TryParse(value, out var isAnamorphic))
|
||||||
if (bool.TryParse(value, out isAnamorphic))
|
|
||||||
{
|
{
|
||||||
if (isAnamorphic && condition.Condition == ProfileConditionType.Equals)
|
if (isAnamorphic && condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1603,8 +1598,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInterlaced;
|
if (bool.TryParse(value, out var isInterlaced))
|
||||||
if (bool.TryParse(value, out isInterlaced))
|
|
||||||
{
|
{
|
||||||
if (!isInterlaced && condition.Condition == ProfileConditionType.Equals)
|
if (!isInterlaced && condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1645,8 +1639,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int num;
|
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
if (condition.Condition == ProfileConditionType.Equals)
|
if (condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1680,8 +1673,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int num;
|
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
if (condition.Condition == ProfileConditionType.Equals)
|
if (condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1727,8 +1719,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num;
|
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
if (condition.Condition == ProfileConditionType.Equals)
|
if (condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1752,8 +1743,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num;
|
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
if (condition.Condition == ProfileConditionType.Equals)
|
if (condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1777,8 +1767,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float num;
|
if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
|
||||||
if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
if (condition.Condition == ProfileConditionType.Equals)
|
if (condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1802,8 +1791,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num;
|
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
if (condition.Condition == ProfileConditionType.Equals)
|
if (condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
@ -1827,8 +1815,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num;
|
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var num))
|
||||||
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
|
|
||||||
{
|
{
|
||||||
if (condition.Condition == ProfileConditionType.Equals)
|
if (condition.Condition == ProfileConditionType.Equals)
|
||||||
{
|
{
|
||||||
|
@ -56,8 +56,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
|
|
||||||
public string GetOption(string name)
|
public string GetOption(string name)
|
||||||
{
|
{
|
||||||
string value;
|
if (StreamOptions.TryGetValue(name, out var value))
|
||||||
if (StreamOptions.TryGetValue(name, out value))
|
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -622,8 +621,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result;
|
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
|
||||||
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -639,8 +637,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result;
|
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
|
||||||
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -656,8 +653,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
double result;
|
if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
|
||||||
if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -673,8 +669,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result;
|
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
|
||||||
if (int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -781,8 +776,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result;
|
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
|
||||||
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result))
|
|
||||||
{
|
{
|
||||||
return Math.Min(result, defaultValue ?? result);
|
return Math.Min(result, defaultValue ?? result);
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,7 @@ namespace MediaBrowser.Model.Drawing
|
|||||||
|
|
||||||
if (parts.Length == 2)
|
if (parts.Length == 2)
|
||||||
{
|
{
|
||||||
double val;
|
if (double.TryParse(parts[0], NumberStyles.Any, CultureInfo.InvariantCulture, out var val))
|
||||||
|
|
||||||
if (double.TryParse(parts[0], NumberStyles.Any, CultureInfo.InvariantCulture, out val))
|
|
||||||
{
|
{
|
||||||
_width = val;
|
_width = val;
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,7 @@ namespace MediaBrowser.Model.Entities
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string id;
|
instance.ProviderIds.TryGetValue(name, out var id);
|
||||||
instance.ProviderIds.TryGetValue(name, out id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,8 +132,7 @@ namespace MediaBrowser.Model.Net
|
|||||||
|
|
||||||
var ext = Path.GetExtension(path) ?? string.Empty;
|
var ext = Path.GetExtension(path) ?? string.Empty;
|
||||||
|
|
||||||
string result;
|
if (MimeTypeLookup.TryGetValue(ext, out var result))
|
||||||
if (MimeTypeLookup.TryGetValue(ext, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -339,8 +338,7 @@ namespace MediaBrowser.Model.Net
|
|||||||
// handle text/html; charset=UTF-8
|
// handle text/html; charset=UTF-8
|
||||||
mimeType = mimeType.Split(';')[0];
|
mimeType = mimeType.Split(';')[0];
|
||||||
|
|
||||||
string result;
|
if (ExtensionLookup.TryGetValue(mimeType, out var result))
|
||||||
if (ExtensionLookup.TryGetValue(mimeType, out result))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -968,8 +968,7 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
{
|
{
|
||||||
lock (_activeRefreshes)
|
lock (_activeRefreshes)
|
||||||
{
|
{
|
||||||
double value;
|
if (_activeRefreshes.TryGetValue(id, out var value))
|
||||||
if (_activeRefreshes.TryGetValue(id, out value))
|
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -1029,7 +1028,6 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
|
|
||||||
private async Task StartProcessingRefreshQueue()
|
private async Task StartProcessingRefreshQueue()
|
||||||
{
|
{
|
||||||
Tuple<Guid, MetadataRefreshOptions> refreshItem;
|
|
||||||
var libraryManager = _libraryManagerFactory();
|
var libraryManager = _libraryManagerFactory();
|
||||||
|
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
@ -1039,7 +1037,7 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
|
|
||||||
var cancellationToken = _disposeCancellationTokenSource.Token;
|
var cancellationToken = _disposeCancellationTokenSource.Token;
|
||||||
|
|
||||||
while (_refreshQueue.TryDequeue(out refreshItem))
|
while (_refreshQueue.TryDequeue(out var refreshItem))
|
||||||
{
|
{
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
{
|
{
|
||||||
|
@ -133,8 +133,7 @@ namespace Priority_Queue
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleNode node;
|
if (_queue.TryDequeue(out var node))
|
||||||
if (_queue.TryDequeue(out node))
|
|
||||||
{
|
{
|
||||||
item = node.Data;
|
item = node.Data;
|
||||||
return true;
|
return true;
|
||||||
|
@ -251,12 +251,10 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
|
|
||||||
foreach (var chapter in chapters)
|
foreach (var chapter in chapters)
|
||||||
{
|
{
|
||||||
TimeSpan time;
|
|
||||||
|
|
||||||
// Check if the name is empty and/or if the name is a time
|
// Check if the name is empty and/or if the name is a time
|
||||||
// Some ripping programs do that.
|
// Some ripping programs do that.
|
||||||
if (string.IsNullOrWhiteSpace(chapter.Name) ||
|
if (string.IsNullOrWhiteSpace(chapter.Name) ||
|
||||||
TimeSpan.TryParse(chapter.Name, out time))
|
TimeSpan.TryParse(chapter.Name, out var time))
|
||||||
{
|
{
|
||||||
chapter.Name = string.Format(_localization.GetLocalizedString("ChapterNameValue"), index.ToString(CultureInfo.InvariantCulture));
|
chapter.Name = string.Format(_localization.GetLocalizedString("ChapterNameValue"), index.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,6 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
if (!string.IsNullOrEmpty(url))
|
if (!string.IsNullOrEmpty(url))
|
||||||
{
|
{
|
||||||
var likesString = i.likes;
|
var likesString = i.likes;
|
||||||
int likes;
|
|
||||||
|
|
||||||
var info = new RemoteImageInfo
|
var info = new RemoteImageInfo
|
||||||
{
|
{
|
||||||
@ -181,7 +180,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
Language = i.lang
|
Language = i.lang
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out likes))
|
if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out var likes))
|
||||||
{
|
{
|
||||||
info.CommunityRating = likes;
|
info.CommunityRating = likes;
|
||||||
}
|
}
|
||||||
|
@ -161,10 +161,9 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float rating;
|
|
||||||
string voteAvg = movieData.vote_average.ToString(CultureInfo.InvariantCulture);
|
string voteAvg = movieData.vote_average.ToString(CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
if (float.TryParse(voteAvg, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out rating))
|
if (float.TryParse(voteAvg, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var rating))
|
||||||
{
|
{
|
||||||
movie.CommunityRating = rating;
|
movie.CommunityRating = rating;
|
||||||
}
|
}
|
||||||
@ -195,10 +194,8 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(movieData.release_date))
|
if (!string.IsNullOrWhiteSpace(movieData.release_date))
|
||||||
{
|
{
|
||||||
DateTime r;
|
|
||||||
|
|
||||||
// These dates are always in this exact format
|
// These dates are always in this exact format
|
||||||
if (DateTime.TryParse(movieData.release_date, _usCulture, DateTimeStyles.None, out r))
|
if (DateTime.TryParse(movieData.release_date, _usCulture, DateTimeStyles.None, out var r))
|
||||||
{
|
{
|
||||||
movie.PremiereDate = r.ToUniversalTime();
|
movie.PremiereDate = r.ToUniversalTime();
|
||||||
movie.ProductionYear = movie.PremiereDate.Value.Year;
|
movie.ProductionYear = movie.PremiereDate.Value.Year;
|
||||||
|
@ -86,10 +86,8 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(obj.release_date))
|
if (!string.IsNullOrWhiteSpace(obj.release_date))
|
||||||
{
|
{
|
||||||
DateTime r;
|
|
||||||
|
|
||||||
// These dates are always in this exact format
|
// These dates are always in this exact format
|
||||||
if (DateTime.TryParse(obj.release_date, _usCulture, DateTimeStyles.None, out r))
|
if (DateTime.TryParse(obj.release_date, _usCulture, DateTimeStyles.None, out var r))
|
||||||
{
|
{
|
||||||
remoteResult.PremiereDate = r.ToUniversalTime();
|
remoteResult.PremiereDate = r.ToUniversalTime();
|
||||||
remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year;
|
remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year;
|
||||||
|
@ -180,10 +180,8 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(i.release_date))
|
if (!string.IsNullOrWhiteSpace(i.release_date))
|
||||||
{
|
{
|
||||||
DateTime r;
|
|
||||||
|
|
||||||
// These dates are always in this exact format
|
// These dates are always in this exact format
|
||||||
if (DateTime.TryParseExact(i.release_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r))
|
if (DateTime.TryParseExact(i.release_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out var r))
|
||||||
{
|
{
|
||||||
remoteResult.PremiereDate = r.ToUniversalTime();
|
remoteResult.PremiereDate = r.ToUniversalTime();
|
||||||
remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year;
|
remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year;
|
||||||
@ -235,10 +233,8 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(i.first_air_date))
|
if (!string.IsNullOrWhiteSpace(i.first_air_date))
|
||||||
{
|
{
|
||||||
DateTime r;
|
|
||||||
|
|
||||||
// These dates are always in this exact format
|
// These dates are always in this exact format
|
||||||
if (DateTime.TryParseExact(i.first_air_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r))
|
if (DateTime.TryParseExact(i.first_air_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out var r))
|
||||||
{
|
{
|
||||||
remoteResult.PremiereDate = r.ToUniversalTime();
|
remoteResult.PremiereDate = r.ToUniversalTime();
|
||||||
remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year;
|
remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year;
|
||||||
|
@ -47,8 +47,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
|
|
||||||
public static string GetMusicBrainzArtistId(this AlbumInfo info)
|
public static string GetMusicBrainzArtistId(this AlbumInfo info)
|
||||||
{
|
{
|
||||||
string id;
|
info.ProviderIds.TryGetValue(MetadataProviders.MusicBrainzAlbumArtist.ToString(), out var id);
|
||||||
info.ProviderIds.TryGetValue(MetadataProviders.MusicBrainzAlbumArtist.ToString(), out id);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(id))
|
if (string.IsNullOrEmpty(id))
|
||||||
{
|
{
|
||||||
@ -66,8 +65,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
|
|
||||||
public static string GetMusicBrainzArtistId(this ArtistInfo info)
|
public static string GetMusicBrainzArtistId(this ArtistInfo info)
|
||||||
{
|
{
|
||||||
string id;
|
info.ProviderIds.TryGetValue(MetadataProviders.MusicBrainzArtist.ToString(), out var id);
|
||||||
info.ProviderIds.TryGetValue(MetadataProviders.MusicBrainzArtist.ToString(), out id);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(id))
|
if (string.IsNullOrEmpty(id))
|
||||||
{
|
{
|
||||||
|
@ -163,7 +163,6 @@ namespace MediaBrowser.Providers.Music
|
|||||||
if (!string.IsNullOrEmpty(url))
|
if (!string.IsNullOrEmpty(url))
|
||||||
{
|
{
|
||||||
var likesString = i.likes;
|
var likesString = i.likes;
|
||||||
int likes;
|
|
||||||
|
|
||||||
var info = new RemoteImageInfo
|
var info = new RemoteImageInfo
|
||||||
{
|
{
|
||||||
@ -176,7 +175,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
Language = i.lang
|
Language = i.lang
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out likes))
|
if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out var likes))
|
||||||
{
|
{
|
||||||
info.CommunityRating = likes;
|
info.CommunityRating = likes;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,6 @@ namespace MediaBrowser.Providers.Music
|
|||||||
if (!string.IsNullOrEmpty(url))
|
if (!string.IsNullOrEmpty(url))
|
||||||
{
|
{
|
||||||
var likesString = i.likes;
|
var likesString = i.likes;
|
||||||
int likes;
|
|
||||||
|
|
||||||
var info = new RemoteImageInfo
|
var info = new RemoteImageInfo
|
||||||
{
|
{
|
||||||
@ -174,7 +173,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
Language = i.lang
|
Language = i.lang
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out likes))
|
if (!string.IsNullOrEmpty(likesString) && int.TryParse(likesString, NumberStyles.Integer, _usCulture, out var likes))
|
||||||
{
|
{
|
||||||
info.CommunityRating = likes;
|
info.CommunityRating = likes;
|
||||||
}
|
}
|
||||||
|
@ -413,8 +413,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
case "date":
|
case "date":
|
||||||
{
|
{
|
||||||
var val = reader.ReadElementContentAsString();
|
var val = reader.ReadElementContentAsString();
|
||||||
DateTime date;
|
if (DateTime.TryParse(val, out var date))
|
||||||
if (DateTime.TryParse(val, out date))
|
|
||||||
{
|
{
|
||||||
result.Year = date.Year;
|
result.Year = date.Year;
|
||||||
}
|
}
|
||||||
|
@ -161,16 +161,14 @@ namespace MediaBrowser.Providers.Omdb
|
|||||||
|
|
||||||
item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
|
item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
|
||||||
|
|
||||||
int parsedYear;
|
|
||||||
if (result.Year.Length > 0
|
if (result.Year.Length > 0
|
||||||
&& int.TryParse(result.Year.Substring(0, Math.Min(result.Year.Length, 4)), NumberStyles.Integer, CultureInfo.InvariantCulture, out parsedYear))
|
&& int.TryParse(result.Year.Substring(0, Math.Min(result.Year.Length, 4)), NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedYear))
|
||||||
{
|
{
|
||||||
item.ProductionYear = parsedYear;
|
item.ProductionYear = parsedYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime released;
|
|
||||||
if (!string.IsNullOrEmpty(result.Released)
|
if (!string.IsNullOrEmpty(result.Released)
|
||||||
&& DateTime.TryParse(result.Released, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out released))
|
&& DateTime.TryParse(result.Released, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out var released))
|
||||||
{
|
{
|
||||||
item.PremiereDate = released;
|
item.PremiereDate = released;
|
||||||
}
|
}
|
||||||
|
@ -58,10 +58,8 @@ namespace MediaBrowser.Providers.Omdb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int year;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4
|
if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4
|
||||||
&& int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out year)
|
&& int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out var year)
|
||||||
&& year >= 0)
|
&& year >= 0)
|
||||||
{
|
{
|
||||||
item.ProductionYear = year;
|
item.ProductionYear = year;
|
||||||
@ -74,19 +72,15 @@ namespace MediaBrowser.Providers.Omdb
|
|||||||
item.CriticRating = tomatoScore;
|
item.CriticRating = tomatoScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
int voteCount;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.imdbVotes)
|
if (!string.IsNullOrEmpty(result.imdbVotes)
|
||||||
&& int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount)
|
&& int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out var voteCount)
|
||||||
&& voteCount >= 0)
|
&& voteCount >= 0)
|
||||||
{
|
{
|
||||||
//item.VoteCount = voteCount;
|
//item.VoteCount = voteCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
float imdbRating;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.imdbRating)
|
if (!string.IsNullOrEmpty(result.imdbRating)
|
||||||
&& float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out imdbRating)
|
&& float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out var imdbRating)
|
||||||
&& imdbRating >= 0)
|
&& imdbRating >= 0)
|
||||||
{
|
{
|
||||||
item.CommunityRating = imdbRating;
|
item.CommunityRating = imdbRating;
|
||||||
@ -165,10 +159,8 @@ namespace MediaBrowser.Providers.Omdb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int year;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4
|
if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4
|
||||||
&& int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out year)
|
&& int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out var year)
|
||||||
&& year >= 0)
|
&& year >= 0)
|
||||||
{
|
{
|
||||||
item.ProductionYear = year;
|
item.ProductionYear = year;
|
||||||
@ -181,19 +173,15 @@ namespace MediaBrowser.Providers.Omdb
|
|||||||
item.CriticRating = tomatoScore;
|
item.CriticRating = tomatoScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
int voteCount;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.imdbVotes)
|
if (!string.IsNullOrEmpty(result.imdbVotes)
|
||||||
&& int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount)
|
&& int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out var voteCount)
|
||||||
&& voteCount >= 0)
|
&& voteCount >= 0)
|
||||||
{
|
{
|
||||||
//item.VoteCount = voteCount;
|
//item.VoteCount = voteCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
float imdbRating;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.imdbRating)
|
if (!string.IsNullOrEmpty(result.imdbRating)
|
||||||
&& float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out imdbRating)
|
&& float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out var imdbRating)
|
||||||
&& imdbRating >= 0)
|
&& imdbRating >= 0)
|
||||||
{
|
{
|
||||||
item.CommunityRating = imdbRating;
|
item.CommunityRating = imdbRating;
|
||||||
@ -254,8 +242,7 @@ namespace MediaBrowser.Providers.Omdb
|
|||||||
|
|
||||||
internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds)
|
internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds)
|
||||||
{
|
{
|
||||||
string id;
|
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out var id) && !string.IsNullOrEmpty(id))
|
||||||
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id) && !string.IsNullOrEmpty(id))
|
|
||||||
{
|
{
|
||||||
// This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet.
|
// This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet.
|
||||||
if (!string.IsNullOrWhiteSpace(id))
|
if (!string.IsNullOrWhiteSpace(id))
|
||||||
@ -515,8 +502,7 @@ namespace MediaBrowser.Providers.Omdb
|
|||||||
if (rating != null && rating.Value != null)
|
if (rating != null && rating.Value != null)
|
||||||
{
|
{
|
||||||
var value = rating.Value.TrimEnd('%');
|
var value = rating.Value.TrimEnd('%');
|
||||||
float score;
|
if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var score))
|
||||||
if (float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out score))
|
|
||||||
{
|
{
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
@ -167,9 +167,7 @@ namespace MediaBrowser.Providers.People
|
|||||||
}
|
}
|
||||||
item.Overview = info.biography;
|
item.Overview = info.biography;
|
||||||
|
|
||||||
DateTime date;
|
if (DateTime.TryParseExact(info.birthday, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out var date))
|
||||||
|
|
||||||
if (DateTime.TryParseExact(info.birthday, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out date))
|
|
||||||
{
|
{
|
||||||
item.PremiereDate = date.ToUniversalTime();
|
item.PremiereDate = date.ToUniversalTime();
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user