The Free Software Media System - Server Backend & API
Fix always null expressions
Bond_0098af256f9c2ea
diff --git a/Emby.Dlna/ContentDirectory/ContentDirectory.cs b/Emby.Dlna/ContentDirectory/ContentDirectory.csindex cd21599d01..b0fec90e69 100644--- a/Emby.Dlna/ContentDirectory/ContentDirectory.cs+++ b/Emby.Dlna/ContentDirectory/ContentDirectory.cs@@ -76,7 +76,6 @@ namespace Emby.Dlna.ContentDirectory_dlna.GetDefaultProfile();var serverAddress = request.RequestedUrl.Substring(0, request.RequestedUrl.IndexOf("/dlna", StringComparison.OrdinalIgnoreCase));- string accessToken = null;var user = GetUser(profile);@@ -85,7 +84,7 @@ namespace Emby.Dlna.ContentDirectory_libraryManager,profile,serverAddress,- accessToken,+ null,_imageProcessor,_userDataManager,user,diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.csindex 8e82e6f69a..790625705a 100644--- a/Emby.Dlna/PlayTo/PlayToManager.cs+++ b/Emby.Dlna/PlayTo/PlayToManager.cs@@ -162,9 +162,7 @@ namespace Emby.Dlna.PlayTouuid = location.GetMD5().ToString("N");}- string deviceName = null;-- var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion, uuid, deviceName, uri.OriginalString, null);+ var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion, uuid, null, uri.OriginalString, null);var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault();@@ -172,7 +170,7 @@ namespace Emby.Dlna.PlayTo{var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger, _timerFactory, cancellationToken).ConfigureAwait(false);- deviceName = device.Properties.Name;+ string deviceName = device.Properties.Name;_sessionManager.UpdateDeviceName(sessionInfo.Id, deviceName);@@ -186,8 +184,6 @@ namespace Emby.Dlna.PlayToserverAddress = _appHost.GetLocalApiUrl(info.LocalIpAddress);}- string accessToken = null;-controller = new PlayToController(sessionInfo,_sessionManager,_libraryManager,@@ -196,7 +192,7 @@ namespace Emby.Dlna.PlayTo_userManager,_imageProcessor,serverAddress,- accessToken,+ null,_deviceDiscovery,_userDataManager,_localization,diff --git a/Emby.Naming/AudioBook/AudioBookResolver.cs b/Emby.Naming/AudioBook/AudioBookResolver.csindex 67451a6396..67ab62e801 100644--- a/Emby.Naming/AudioBook/AudioBookResolver.cs+++ b/Emby.Naming/AudioBook/AudioBookResolver.cs@@ -36,7 +36,7 @@ namespace Emby.Naming.AudioBookreturn null;}- var extension = Path.GetExtension(path) ?? string.Empty;+ var extension = Path.GetExtension(path);// Check supported extensionsif (!_options.AudioFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)){diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex f5a4f15817..f29e732da9 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -466,9 +466,8 @@ namespace Emby.Server.Implementationsprivate static Tuple<Assembly, string> GetAssembly(Type type){var assembly = type.GetTypeInfo().Assembly;- string path = null;- return new Tuple<Assembly, string>(assembly, path);+ return new Tuple<Assembly, string>(assembly, null);}public virtual IStreamHelper CreateStreamHelper()diff --git a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.csindex 52e58ed8da..52ec7a135d 100644--- a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs+++ b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs@@ -1005,7 +1005,7 @@ namespace Emby.XmlTv.Classes}}- public static Regex _regDateWithOffset = new Regex(@"^(?<dateDigits>[0-9]{4,14})(\s(?<dateOffset>[+-]*[0-9]{1,4}))?$");+ public const string _regDateWithOffset = @"^(?<dateDigits>[0-9]{4,14})(\s(?<dateOffset>[+-]*[0-9]{1,4}))?$";public DateTimeOffset? ParseDate(string dateValue){@@ -1018,50 +1018,47 @@ namespace Emby.XmlTv.Classes'200007281733 BST', '200209', '19880523083000 +0300'. (BST == +0100.)*/- DateTimeOffset? result = null;-- if (!string.IsNullOrEmpty(dateValue))+ if (string.IsNullOrEmpty(dateValue)){- var completeDate = "20000101000000";- var dateComponent = string.Empty;- var dateOffset = "+00:00";+ return null;+ }- var match = _regDateWithOffset.Match(dateValue);- if (match.Success)+ var completeDate = "20000101000000";+ var dateComponent = string.Empty;+ var dateOffset = "+00:00";+ var match = Regex.Match(dateValue, _regDateWithOffset);+ if (match.Success)+ {+ dateComponent = match.Groups["dateDigits"].Value;+ if (!string.IsNullOrEmpty(match.Groups["dateOffset"].Value)){- dateComponent = match.Groups["dateDigits"].Value;- if (!string.IsNullOrEmpty(match.Groups["dateOffset"].Value))+ dateOffset = match.Groups["dateOffset"].Value; // Add in the colon to ease parsing later+ if (dateOffset.Length == 5){- dateOffset = match.Groups["dateOffset"].Value; // Add in the colon to ease parsing later- if (dateOffset.Length == 5)- {- dateOffset = dateOffset.Insert(3, ":"); // Add in the colon to ease parsing later- }- else- {- dateOffset = "+00:00";- }+ dateOffset = dateOffset.Insert(3, ":"); // Add in the colon to ease parsing later+ }+ else+ {+ dateOffset = "+00:00";}}+ }- // Pad out the date component part to 14 characaters so 2016061509 becomes 20160615090000- if (dateComponent.Length < 14)- {- dateComponent = dateComponent + completeDate.Substring(dateComponent.Length, completeDate.Length - dateComponent.Length);- }+ // Pad out the date component part to 14 characaters so 2016061509 becomes 20160615090000+ if (dateComponent.Length < 14)+ {+ dateComponent = dateComponent + completeDate.Substring(dateComponent.Length, completeDate.Length - dateComponent.Length);+ }- var standardDate = string.Format("{0} {1}", dateComponent, dateOffset);- if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out var parsedDateTime))- {- return parsedDateTime.ToUniversalTime();- }- else- {- //Logger.LogWarning("Unable to parse the date {0} from standardised form {1}", dateValue, standardDate);- }+ var standardDate = string.Format("{0} {1}", dateComponent, dateOffset);+ if (DateTimeOffset.TryParseExact(standardDate, "yyyyMMddHHmmss zzz", CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTimeOffset parsedDateTime))+ {+ return parsedDateTime.ToUniversalTime();}- return result;+ // Logger.LogWarning("Unable to parse the date {0} from standardised form {1}", dateValue, standardDate);++ return null;}public string StandardiseDate(string value)@@ -1070,7 +1067,7 @@ namespace Emby.XmlTv.Classesvar dateComponent = string.Empty;var dateOffset = "+0000";- var match = _regDateWithOffset.Match(value);+ var match = Regex.Match(value, _regDateWithOffset);if (match.Success){dateComponent = match.Groups["dateDigits"].Value;diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.csindex 6f98fcd8d6..0b0134669e 100644--- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs+++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs@@ -508,7 +508,7 @@ namespace MediaBrowser.Controller.Entitiesif (query.IsLiked.HasValue){- userData = userData ?? userDataManager.GetUserData(user, item);+ userData = userDataManager.GetUserData(user, item);if (!userData.Likes.HasValue || userData.Likes != query.IsLiked.Value){diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.csindex ecae0c39da..e4bb52217c 100644--- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs+++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs@@ -510,13 +510,11 @@ namespace MediaBrowser.Providers.Musicreturn new ValueTuple<string, string>();}- private static ValueTuple<string, string> ParseArtistNameCredit(XmlReader reader)+ private static (string, string) ParseArtistNameCredit(XmlReader reader){reader.MoveToContent();reader.Read();- string name = null;-// http://stackoverflow.com/questions/2299632/why-does-xmlreader-skip-every-other-element-if-there-is-no-whitespace-separator// Loop through each element@@ -547,7 +545,7 @@ namespace MediaBrowser.Providers.Music}}- return new ValueTuple<string, string>(name, null);+ return (null, null);}private static ValueTuple<string, string> ParseArtistArtistCredit(XmlReader reader, string artistId)