Replace != null with is not null

pull/8511/head
Bond_009 1 year ago
parent c7d50d640e
commit 52194f56b5

@ -141,7 +141,7 @@ namespace Emby.Dlna.ContentDirectory
{ {
var user = _userManager.GetUserById(Guid.Parse(profile.UserId)); var user = _userManager.GetUserById(Guid.Parse(profile.UserId));
if (user != null) if (user is not null)
{ {
return user; return user;
} }
@ -153,7 +153,7 @@ namespace Emby.Dlna.ContentDirectory
{ {
var user = _userManager.GetUserById(Guid.Parse(userId)); var user = _userManager.GetUserById(Guid.Parse(userId));
if (user != null) if (user is not null)
{ {
return user; return user;
} }

@ -1048,7 +1048,7 @@ namespace Emby.Dlna.ContentDirectory
ParentId = parent?.Id ?? Guid.Empty, ParentId = parent?.Id ?? Guid.Empty,
GroupItems = true GroupItems = true
}, },
query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i != null).ToArray(); query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i is not null).ToArray();
return ToResult(query.StartIndex, items); return ToResult(query.StartIndex, items);
} }

@ -153,7 +153,7 @@ namespace Emby.Dlna.Didl
writer.WriteAttributeString("restricted", "1"); writer.WriteAttributeString("restricted", "1");
writer.WriteAttributeString("id", clientId); writer.WriteAttributeString("id", clientId);
if (context != null) if (context is not null)
{ {
writer.WriteAttributeString("parentID", GetClientId(context, contextStubType)); writer.WriteAttributeString("parentID", GetClientId(context, contextStubType));
} }
@ -652,7 +652,7 @@ namespace Emby.Dlna.Didl
{ {
writer.WriteAttributeString("id", clientId); writer.WriteAttributeString("id", clientId);
if (context != null) if (context is not null)
{ {
writer.WriteAttributeString("parentID", GetClientId(context, null)); writer.WriteAttributeString("parentID", GetClientId(context, null));
} }
@ -701,7 +701,7 @@ namespace Emby.Dlna.Didl
} }
var userdata = _userDataManager.GetUserData(user, item); var userdata = _userDataManager.GetUserData(user, item);
var playbackPositionTicks = (streamInfo != null && streamInfo.StartPositionTicks > 0) ? streamInfo.StartPositionTicks : userdata.PlaybackPositionTicks; var playbackPositionTicks = (streamInfo is not null && streamInfo.StartPositionTicks > 0) ? streamInfo.StartPositionTicks : userdata.PlaybackPositionTicks;
if (playbackPositionTicks > 0) if (playbackPositionTicks > 0)
{ {
@ -916,7 +916,7 @@ namespace Emby.Dlna.Didl
} }
} }
if (hasAlbumArtists != null) if (hasAlbumArtists is not null)
{ {
foreach (var albumArtist in hasAlbumArtists.AlbumArtists) foreach (var albumArtist in hasAlbumArtists.AlbumArtists)
{ {
@ -1093,7 +1093,7 @@ namespace Emby.Dlna.Didl
if (item is Audio audioItem) if (item is Audio audioItem)
{ {
var album = audioItem.AlbumEntity; var album = audioItem.AlbumEntity;
return album != null && album.HasImage(ImageType.Primary) return album is not null && album.HasImage(ImageType.Primary)
? GetImageInfo(album, ImageType.Primary) ? GetImageInfo(album, ImageType.Primary)
: null; : null;
} }
@ -1106,7 +1106,7 @@ namespace Emby.Dlna.Didl
// For other item types check parents, but be aware that image retrieved from a parent may be not suitable for this media item. // For other item types check parents, but be aware that image retrieved from a parent may be not suitable for this media item.
var parentWithImage = GetFirstParentWithImageBelowUserRoot(item); var parentWithImage = GetFirstParentWithImageBelowUserRoot(item);
if (parentWithImage != null) if (parentWithImage is not null)
{ {
return GetImageInfo(parentWithImage, ImageType.Primary); return GetImageInfo(parentWithImage, ImageType.Primary);
} }

@ -105,7 +105,7 @@ namespace Emby.Dlna
ArgumentNullException.ThrowIfNull(deviceInfo); ArgumentNullException.ThrowIfNull(deviceInfo);
var profile = GetProfiles() var profile = GetProfiles()
.FirstOrDefault(i => i.Identification != null && IsMatch(deviceInfo, i.Identification)); .FirstOrDefault(i => i.Identification is not null && IsMatch(deviceInfo, i.Identification));
if (profile is null) if (profile is null)
{ {
@ -171,7 +171,7 @@ namespace Emby.Dlna
{ {
ArgumentNullException.ThrowIfNull(headers); ArgumentNullException.ThrowIfNull(headers);
var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(headers, i.Identification)); var profile = GetProfiles().FirstOrDefault(i => i.Identification is not null && IsMatch(headers, i.Identification));
if (profile is null) if (profile is null)
{ {
_logger.LogDebug("No matching device profile found. {@Headers}", headers); _logger.LogDebug("No matching device profile found. {@Headers}", headers);
@ -224,7 +224,7 @@ namespace Emby.Dlna
return _fileSystem.GetFilePaths(path) return _fileSystem.GetFilePaths(path)
.Where(i => string.Equals(Path.GetExtension(i), ".xml", StringComparison.OrdinalIgnoreCase)) .Where(i => string.Equals(Path.GetExtension(i), ".xml", StringComparison.OrdinalIgnoreCase))
.Select(i => ParseProfileFile(i, type)) .Select(i => ParseProfileFile(i, type))
.Where(i => i != null) .Where(i => i is not null)
.ToList()!; // We just filtered out all the nulls .ToList()!; // We just filtered out all the nulls
} }
catch (IOException) catch (IOException)

@ -35,7 +35,7 @@ namespace Emby.Dlna.Eventing
public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string notificationType, string requestedTimeoutString, string callbackUrl) public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string notificationType, string requestedTimeoutString, string callbackUrl)
{ {
var subscription = GetSubscription(subscriptionId, false); var subscription = GetSubscription(subscriptionId, false);
if (subscription != null) if (subscription is not null)
{ {
subscription.TimeoutSeconds = ParseTimeout(requestedTimeoutString) ?? 300; subscription.TimeoutSeconds = ParseTimeout(requestedTimeoutString) ?? 300;
int timeoutSeconds = subscription.TimeoutSeconds; int timeoutSeconds = subscription.TimeoutSeconds;

@ -222,7 +222,7 @@ namespace Emby.Dlna.Main
{ {
try try
{ {
if (communicationsServer != null) if (communicationsServer is not null)
{ {
((DeviceDiscovery)_deviceDiscovery).Start(communicationsServer); ((DeviceDiscovery)_deviceDiscovery).Start(communicationsServer);
} }
@ -253,7 +253,7 @@ namespace Emby.Dlna.Main
return; return;
} }
if (_publisher != null) if (_publisher is not null)
{ {
return; return;
} }
@ -382,7 +382,7 @@ namespace Emby.Dlna.Main
{ {
lock (_syncLock) lock (_syncLock)
{ {
if (_manager != null) if (_manager is not null)
{ {
return; return;
} }
@ -417,7 +417,7 @@ namespace Emby.Dlna.Main
{ {
lock (_syncLock) lock (_syncLock)
{ {
if (_manager != null) if (_manager is not null)
{ {
try try
{ {
@ -436,7 +436,7 @@ namespace Emby.Dlna.Main
public void DisposeDevicePublisher() public void DisposeDevicePublisher()
{ {
if (_publisher != null) if (_publisher is not null)
{ {
_logger.LogInformation("Disposing SsdpDevicePublisher"); _logger.LogInformation("Disposing SsdpDevicePublisher");
_publisher.Dispose(); _publisher.Dispose();
@ -456,7 +456,7 @@ namespace Emby.Dlna.Main
DisposePlayToManager(); DisposePlayToManager();
DisposeDeviceDiscovery(); DisposeDeviceDiscovery();
if (_communicationsServer != null) if (_communicationsServer is not null)
{ {
_logger.LogInformation("Disposing SsdpCommunicationsServer"); _logger.LogInformation("Disposing SsdpCommunicationsServer");
_communicationsServer.Dispose(); _communicationsServer.Dispose();

@ -543,7 +543,7 @@ namespace Emby.Dlna.PlayTo
currentObject = await GetMediaInfo(avCommands, cancellationToken).ConfigureAwait(false); currentObject = await GetMediaInfo(avCommands, cancellationToken).ConfigureAwait(false);
} }
if (currentObject != null) if (currentObject is not null)
{ {
UpdateMediaInfo(currentObject, transportState.Value); UpdateMediaInfo(currentObject, transportState.Value);
} }
@ -585,7 +585,7 @@ namespace Emby.Dlna.PlayTo
if (_connectFailureCount >= 3) if (_connectFailureCount >= 3)
{ {
var action = OnDeviceUnavailable; var action = OnDeviceUnavailable;
if (action != null) if (action is not null)
{ {
_logger.LogDebug("Disposing device due to loss of connection"); _logger.LogDebug("Disposing device due to loss of connection");
action(); action();
@ -631,7 +631,7 @@ namespace Emby.Dlna.PlayTo
return; return;
} }
var volume = result.Document.Descendants(UPnpNamespaces.RenderingControl + "GetVolumeResponse").Select(i => i.Element("CurrentVolume")).FirstOrDefault(i => i != null); var volume = result.Document.Descendants(UPnpNamespaces.RenderingControl + "GetVolumeResponse").Select(i => i.Element("CurrentVolume")).FirstOrDefault(i => i is not null);
var volumeValue = volume?.Value; var volumeValue = volume?.Value;
if (string.IsNullOrWhiteSpace(volumeValue)) if (string.IsNullOrWhiteSpace(volumeValue))
@ -683,7 +683,7 @@ namespace Emby.Dlna.PlayTo
var valueNode = result.Document.Descendants(UPnpNamespaces.RenderingControl + "GetMuteResponse") var valueNode = result.Document.Descendants(UPnpNamespaces.RenderingControl + "GetMuteResponse")
.Select(i => i.Element("CurrentMute")) .Select(i => i.Element("CurrentMute"))
.FirstOrDefault(i => i != null); .FirstOrDefault(i => i is not null);
IsMuted = string.Equals(valueNode?.Value, "1", StringComparison.OrdinalIgnoreCase); IsMuted = string.Equals(valueNode?.Value, "1", StringComparison.OrdinalIgnoreCase);
} }
@ -715,11 +715,11 @@ namespace Emby.Dlna.PlayTo
} }
var transportState = var transportState =
result.Document.Descendants(UPnpNamespaces.AvTransport + "GetTransportInfoResponse").Select(i => i.Element("CurrentTransportState")).FirstOrDefault(i => i != null); result.Document.Descendants(UPnpNamespaces.AvTransport + "GetTransportInfoResponse").Select(i => i.Element("CurrentTransportState")).FirstOrDefault(i => i is not null);
var transportStateValue = transportState?.Value; var transportStateValue = transportState?.Value;
if (transportStateValue != null if (transportStateValue is not null
&& Enum.TryParse(transportStateValue, true, out TransportState state)) && Enum.TryParse(transportStateValue, true, out TransportState state))
{ {
return state; return state;
@ -832,10 +832,10 @@ namespace Emby.Dlna.PlayTo
return (false, null); return (false, null);
} }
var trackUriElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackURI")).FirstOrDefault(i => i != null); var trackUriElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackURI")).FirstOrDefault(i => i is not null);
var trackUri = trackUriElem?.Value; var trackUri = trackUriElem?.Value;
var durationElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackDuration")).FirstOrDefault(i => i != null); var durationElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackDuration")).FirstOrDefault(i => i is not null);
var duration = durationElem?.Value; var duration = durationElem?.Value;
if (!string.IsNullOrWhiteSpace(duration) if (!string.IsNullOrWhiteSpace(duration)
@ -848,7 +848,7 @@ namespace Emby.Dlna.PlayTo
Duration = null; Duration = null;
} }
var positionElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("RelTime")).FirstOrDefault(i => i != null); var positionElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("RelTime")).FirstOrDefault(i => i is not null);
var position = positionElem?.Value; var position = positionElem?.Value;
if (!string.IsNullOrWhiteSpace(position) && !string.Equals(position, "NOT_IMPLEMENTED", StringComparison.OrdinalIgnoreCase)) if (!string.IsNullOrWhiteSpace(position) && !string.Equals(position, "NOT_IMPLEMENTED", StringComparison.OrdinalIgnoreCase))
@ -959,11 +959,11 @@ namespace Emby.Dlna.PlayTo
var resElement = container.Element(UPnpNamespaces.Res); var resElement = container.Element(UPnpNamespaces.Res);
if (resElement != null) if (resElement is not null)
{ {
var info = resElement.Attribute(UPnpNamespaces.ProtocolInfo); var info = resElement.Attribute(UPnpNamespaces.ProtocolInfo);
if (info != null && !string.IsNullOrWhiteSpace(info.Value)) if (info is not null && !string.IsNullOrWhiteSpace(info.Value))
{ {
return info.Value.Split(':'); return info.Value.Split(':');
} }
@ -974,7 +974,7 @@ namespace Emby.Dlna.PlayTo
private async Task<TransportCommands> GetAVProtocolAsync(CancellationToken cancellationToken) private async Task<TransportCommands> GetAVProtocolAsync(CancellationToken cancellationToken)
{ {
if (AvCommands != null) if (AvCommands is not null)
{ {
return AvCommands; return AvCommands;
} }
@ -1006,7 +1006,7 @@ namespace Emby.Dlna.PlayTo
private async Task<TransportCommands> GetRenderingProtocolAsync(CancellationToken cancellationToken) private async Task<TransportCommands> GetRenderingProtocolAsync(CancellationToken cancellationToken)
{ {
if (RendererCommands != null) if (RendererCommands is not null)
{ {
return RendererCommands; return RendererCommands;
} }
@ -1070,13 +1070,13 @@ namespace Emby.Dlna.PlayTo
var friendlyNames = new List<string>(); var friendlyNames = new List<string>();
var name = document.Descendants(UPnpNamespaces.Ud.GetName("friendlyName")).FirstOrDefault(); var name = document.Descendants(UPnpNamespaces.Ud.GetName("friendlyName")).FirstOrDefault();
if (name != null && !string.IsNullOrWhiteSpace(name.Value)) if (name is not null && !string.IsNullOrWhiteSpace(name.Value))
{ {
friendlyNames.Add(name.Value); friendlyNames.Add(name.Value);
} }
var room = document.Descendants(UPnpNamespaces.Ud.GetName("roomName")).FirstOrDefault(); var room = document.Descendants(UPnpNamespaces.Ud.GetName("roomName")).FirstOrDefault();
if (room != null && !string.IsNullOrWhiteSpace(room.Value)) if (room is not null && !string.IsNullOrWhiteSpace(room.Value))
{ {
friendlyNames.Add(room.Value); friendlyNames.Add(room.Value);
} }
@ -1088,61 +1088,61 @@ namespace Emby.Dlna.PlayTo
}; };
var model = document.Descendants(UPnpNamespaces.Ud.GetName("modelName")).FirstOrDefault(); var model = document.Descendants(UPnpNamespaces.Ud.GetName("modelName")).FirstOrDefault();
if (model != null) if (model is not null)
{ {
deviceProperties.ModelName = model.Value; deviceProperties.ModelName = model.Value;
} }
var modelNumber = document.Descendants(UPnpNamespaces.Ud.GetName("modelNumber")).FirstOrDefault(); var modelNumber = document.Descendants(UPnpNamespaces.Ud.GetName("modelNumber")).FirstOrDefault();
if (modelNumber != null) if (modelNumber is not null)
{ {
deviceProperties.ModelNumber = modelNumber.Value; deviceProperties.ModelNumber = modelNumber.Value;
} }
var uuid = document.Descendants(UPnpNamespaces.Ud.GetName("UDN")).FirstOrDefault(); var uuid = document.Descendants(UPnpNamespaces.Ud.GetName("UDN")).FirstOrDefault();
if (uuid != null) if (uuid is not null)
{ {
deviceProperties.UUID = uuid.Value; deviceProperties.UUID = uuid.Value;
} }
var manufacturer = document.Descendants(UPnpNamespaces.Ud.GetName("manufacturer")).FirstOrDefault(); var manufacturer = document.Descendants(UPnpNamespaces.Ud.GetName("manufacturer")).FirstOrDefault();
if (manufacturer != null) if (manufacturer is not null)
{ {
deviceProperties.Manufacturer = manufacturer.Value; deviceProperties.Manufacturer = manufacturer.Value;
} }
var manufacturerUrl = document.Descendants(UPnpNamespaces.Ud.GetName("manufacturerURL")).FirstOrDefault(); var manufacturerUrl = document.Descendants(UPnpNamespaces.Ud.GetName("manufacturerURL")).FirstOrDefault();
if (manufacturerUrl != null) if (manufacturerUrl is not null)
{ {
deviceProperties.ManufacturerUrl = manufacturerUrl.Value; deviceProperties.ManufacturerUrl = manufacturerUrl.Value;
} }
var presentationUrl = document.Descendants(UPnpNamespaces.Ud.GetName("presentationURL")).FirstOrDefault(); var presentationUrl = document.Descendants(UPnpNamespaces.Ud.GetName("presentationURL")).FirstOrDefault();
if (presentationUrl != null) if (presentationUrl is not null)
{ {
deviceProperties.PresentationUrl = presentationUrl.Value; deviceProperties.PresentationUrl = presentationUrl.Value;
} }
var modelUrl = document.Descendants(UPnpNamespaces.Ud.GetName("modelURL")).FirstOrDefault(); var modelUrl = document.Descendants(UPnpNamespaces.Ud.GetName("modelURL")).FirstOrDefault();
if (modelUrl != null) if (modelUrl is not null)
{ {
deviceProperties.ModelUrl = modelUrl.Value; deviceProperties.ModelUrl = modelUrl.Value;
} }
var serialNumber = document.Descendants(UPnpNamespaces.Ud.GetName("serialNumber")).FirstOrDefault(); var serialNumber = document.Descendants(UPnpNamespaces.Ud.GetName("serialNumber")).FirstOrDefault();
if (serialNumber != null) if (serialNumber is not null)
{ {
deviceProperties.SerialNumber = serialNumber.Value; deviceProperties.SerialNumber = serialNumber.Value;
} }
var modelDescription = document.Descendants(UPnpNamespaces.Ud.GetName("modelDescription")).FirstOrDefault(); var modelDescription = document.Descendants(UPnpNamespaces.Ud.GetName("modelDescription")).FirstOrDefault();
if (modelDescription != null) if (modelDescription is not null)
{ {
deviceProperties.ModelDescription = modelDescription.Value; deviceProperties.ModelDescription = modelDescription.Value;
} }
var icon = document.Descendants(UPnpNamespaces.Ud.GetName("icon")).FirstOrDefault(); var icon = document.Descendants(UPnpNamespaces.Ud.GetName("icon")).FirstOrDefault();
if (icon != null) if (icon is not null)
{ {
deviceProperties.Icon = CreateIcon(icon); deviceProperties.Icon = CreateIcon(icon);
} }
@ -1164,7 +1164,7 @@ namespace Emby.Dlna.PlayTo
{ {
var service = Create(element); var service = Create(element);
if (service != null) if (service is not null)
{ {
deviceProperties.Services.Add(service); deviceProperties.Services.Add(service);
} }
@ -1214,7 +1214,7 @@ namespace Emby.Dlna.PlayTo
if (mediaInfo is null) if (mediaInfo is null)
{ {
if (previousMediaInfo != null) if (previousMediaInfo is not null)
{ {
OnPlaybackStop(previousMediaInfo); OnPlaybackStop(previousMediaInfo);
} }

@ -84,7 +84,7 @@ namespace Emby.Dlna.PlayTo
_mediaEncoder = mediaEncoder; _mediaEncoder = mediaEncoder;
} }
public bool IsSessionActive => !_disposed && _device != null; public bool IsSessionActive => !_disposed && _device is not null;
public bool SupportsMediaControl => IsSessionActive; public bool SupportsMediaControl => IsSessionActive;
@ -156,7 +156,7 @@ namespace Emby.Dlna.PlayTo
try try
{ {
var streamInfo = StreamParams.ParseFromUrl(e.OldMediaInfo.Url, _libraryManager, _mediaSourceManager); var streamInfo = StreamParams.ParseFromUrl(e.OldMediaInfo.Url, _libraryManager, _mediaSourceManager);
if (streamInfo.Item != null) if (streamInfo.Item is not null)
{ {
var positionTicks = GetProgressPositionTicks(streamInfo); var positionTicks = GetProgressPositionTicks(streamInfo);
@ -268,7 +268,7 @@ namespace Emby.Dlna.PlayTo
{ {
var info = StreamParams.ParseFromUrl(e.MediaInfo.Url, _libraryManager, _mediaSourceManager); var info = StreamParams.ParseFromUrl(e.MediaInfo.Url, _libraryManager, _mediaSourceManager);
if (info.Item != null) if (info.Item is not null)
{ {
var progress = GetProgressInfo(info); var progress = GetProgressInfo(info);
@ -299,7 +299,7 @@ namespace Emby.Dlna.PlayTo
var info = StreamParams.ParseFromUrl(mediaUrl, _libraryManager, _mediaSourceManager); var info = StreamParams.ParseFromUrl(mediaUrl, _libraryManager, _mediaSourceManager);
if (info.Item != null) if (info.Item is not null)
{ {
var progress = GetProgressInfo(info); var progress = GetProgressInfo(info);
@ -441,11 +441,11 @@ namespace Emby.Dlna.PlayTo
{ {
var media = _device.CurrentMediaInfo; var media = _device.CurrentMediaInfo;
if (media != null) if (media is not null)
{ {
var info = StreamParams.ParseFromUrl(media.Url, _libraryManager, _mediaSourceManager); var info = StreamParams.ParseFromUrl(media.Url, _libraryManager, _mediaSourceManager);
if (info.Item != null && !EnableClientSideSeek(info)) if (info.Item is not null && !EnableClientSideSeek(info))
{ {
var user = _session.UserId.Equals(default) var user = _session.UserId.Equals(default)
? null ? null
@ -760,11 +760,11 @@ namespace Emby.Dlna.PlayTo
{ {
var media = _device.CurrentMediaInfo; var media = _device.CurrentMediaInfo;
if (media != null) if (media is not null)
{ {
var info = StreamParams.ParseFromUrl(media.Url, _libraryManager, _mediaSourceManager); var info = StreamParams.ParseFromUrl(media.Url, _libraryManager, _mediaSourceManager);
if (info.Item != null) if (info.Item is not null)
{ {
var newPosition = GetProgressPositionTicks(info) ?? 0; var newPosition = GetProgressPositionTicks(info) ?? 0;
@ -791,11 +791,11 @@ namespace Emby.Dlna.PlayTo
{ {
var media = _device.CurrentMediaInfo; var media = _device.CurrentMediaInfo;
if (media != null) if (media is not null)
{ {
var info = StreamParams.ParseFromUrl(media.Url, _libraryManager, _mediaSourceManager); var info = StreamParams.ParseFromUrl(media.Url, _libraryManager, _mediaSourceManager);
if (info.Item != null) if (info.Item is not null)
{ {
var newPosition = GetProgressPositionTicks(info) ?? 0; var newPosition = GetProgressPositionTicks(info) ?? 0;
@ -916,7 +916,7 @@ namespace Emby.Dlna.PlayTo
public async Task<MediaSourceInfo> GetMediaSource(CancellationToken cancellationToken) public async Task<MediaSourceInfo> GetMediaSource(CancellationToken cancellationToken)
{ {
if (_mediaSource != null) if (_mediaSource is not null)
{ {
return _mediaSource; return _mediaSource;
} }
@ -926,7 +926,7 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
if (_mediaSourceManager != null) if (_mediaSourceManager is not null)
{ {
_mediaSource = await _mediaSourceManager.GetMediaSource(Item, MediaSourceId, LiveStreamId, false, cancellationToken).ConfigureAwait(false); _mediaSource = await _mediaSourceManager.GetMediaSource(Item, MediaSourceId, LiveStreamId, false, cancellationToken).ConfigureAwait(false);
} }

@ -29,7 +29,7 @@ namespace Emby.Dlna.PlayTo
var directPlay = profile.DirectPlayProfiles var directPlay = profile.DirectPlayProfiles
.FirstOrDefault(i => i.Type == DlnaProfileType.Photo && IsSupported(i, item)); .FirstOrDefault(i => i.Type == DlnaProfileType.Photo && IsSupported(i, item));
if (directPlay != null) if (directPlay is not null)
{ {
playlistItem.StreamInfo.PlayMethod = PlayMethod.DirectStream; playlistItem.StreamInfo.PlayMethod = PlayMethod.DirectStream;
playlistItem.StreamInfo.Container = Path.GetExtension(item.Path); playlistItem.StreamInfo.Container = Path.GetExtension(item.Path);
@ -40,7 +40,7 @@ namespace Emby.Dlna.PlayTo
var transcodingProfile = profile.TranscodingProfiles var transcodingProfile = profile.TranscodingProfiles
.FirstOrDefault(i => i.Type == DlnaProfileType.Photo); .FirstOrDefault(i => i.Type == DlnaProfileType.Photo);
if (transcodingProfile != null) if (transcodingProfile is not null)
{ {
playlistItem.StreamInfo.PlayMethod = PlayMethod.Transcode; playlistItem.StreamInfo.PlayMethod = PlayMethod.Transcode;
playlistItem.StreamInfo.Container = "." + transcodingProfile.Container.TrimStart('.'); playlistItem.StreamInfo.Container = "." + transcodingProfile.Container.TrimStart('.');

@ -31,7 +31,7 @@ namespace Emby.Dlna.PlayTo
var stateValues = document.Descendants(UPnpNamespaces.ServiceStateTable).FirstOrDefault(); var stateValues = document.Descendants(UPnpNamespaces.ServiceStateTable).FirstOrDefault();
if (stateValues != null) if (stateValues is not null)
{ {
foreach (var container in stateValues.Elements(UPnpNamespaces.Svc + "stateVariable")) foreach (var container in stateValues.Elements(UPnpNamespaces.Svc + "stateVariable"))
{ {
@ -77,7 +77,7 @@ namespace Emby.Dlna.PlayTo
var element = container.Descendants(UPnpNamespaces.Svc + "allowedValueList") var element = container.Descendants(UPnpNamespaces.Svc + "allowedValueList")
.FirstOrDefault(); .FirstOrDefault();
if (element != null) if (element is not null)
{ {
var values = element.Descendants(UPnpNamespaces.Svc + "allowedValue"); var values = element.Descendants(UPnpNamespaces.Svc + "allowedValue");
@ -167,7 +167,7 @@ namespace Emby.Dlna.PlayTo
{ {
var state = StateVariables.FirstOrDefault(a => string.Equals(a.Name, argument.RelatedStateVariable, StringComparison.OrdinalIgnoreCase)); var state = StateVariables.FirstOrDefault(a => string.Equals(a.Name, argument.RelatedStateVariable, StringComparison.OrdinalIgnoreCase));
if (state != null) if (state is not null)
{ {
var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ?? var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ??
(state.AllowedValues.Count > 0 ? state.AllowedValues[0] : value); (state.AllowedValues.Count > 0 ? state.AllowedValues[0] : value);

@ -173,7 +173,7 @@ namespace Emby.Dlna.Service
} }
} }
if (localName != null && namespaceURI != null) if (localName is not null && namespaceURI is not null)
{ {
return new ControlRequestInfo(localName, namespaceURI); return new ControlRequestInfo(localName, namespaceURI);
} }

@ -71,7 +71,7 @@ namespace Emby.Dlna.Ssdp
{ {
lock (_syncLock) lock (_syncLock)
{ {
if (_listenerCount > 0 && _deviceLocator is null && _commsServer != null) if (_listenerCount > 0 && _deviceLocator is null && _commsServer is not null)
{ {
_deviceLocator = new SsdpDeviceLocator(_commsServer); _deviceLocator = new SsdpDeviceLocator(_commsServer);
@ -136,7 +136,7 @@ namespace Emby.Dlna.Ssdp
if (!_disposed) if (!_disposed)
{ {
_disposed = true; _disposed = true;
if (_deviceLocator != null) if (_deviceLocator is not null)
{ {
_deviceLocator.Dispose(); _deviceLocator.Dispose();
_deviceLocator = null; _deviceLocator = null;

@ -69,7 +69,7 @@ namespace Emby.Naming.AudioBook
extras = new List<AudioBookFileInfo>(); extras = new List<AudioBookFileInfo>();
alternativeVersions = new List<AudioBookFileInfo>(); alternativeVersions = new List<AudioBookFileInfo>();
var haveChaptersOrPages = stackFiles.Any(x => x.ChapterNumber != null || x.PartNumber != null); var haveChaptersOrPages = stackFiles.Any(x => x.ChapterNumber is not null || x.PartNumber is not null);
var groupedBy = stackFiles.GroupBy(file => new { file.ChapterNumber, file.PartNumber }); var groupedBy = stackFiles.GroupBy(file => new { file.ChapterNumber, file.PartNumber });
var nameWithReplacedDots = nameParserResult.Name.Replace(' ', '.'); var nameWithReplacedDots = nameParserResult.Name.Replace(' ', '.');

@ -94,12 +94,12 @@ namespace Emby.Naming.ExternalFiles
// Try to translate to three character code // Try to translate to three character code
var culture = _localizationManager.FindLanguageInfo(currentSliceWithoutSeparator); var culture = _localizationManager.FindLanguageInfo(currentSliceWithoutSeparator);
if (culture != null && pathInfo.Language is null) if (culture is not null && pathInfo.Language is null)
{ {
pathInfo.Language = culture.ThreeLetterISOLanguageName; pathInfo.Language = culture.ThreeLetterISOLanguageName;
extraString = extraString.Replace(currentSlice, string.Empty, StringComparison.OrdinalIgnoreCase); extraString = extraString.Replace(currentSlice, string.Empty, StringComparison.OrdinalIgnoreCase);
} }
else if (culture != null && pathInfo.Language == "hin") else if (culture is not null && pathInfo.Language == "hin")
{ {
// Hindi language code "hi" collides with a hearing impaired flag - use as Hindi only if no other language is set // Hindi language code "hi" collides with a hearing impaired flag - use as Hindi only if no other language is set
pathInfo.IsHearingImpaired = true; pathInfo.IsHearingImpaired = true;

@ -76,7 +76,7 @@ namespace Emby.Naming.TV
} }
} }
if (result != null && fillExtendedInfo) if (result is not null && fillExtendedInfo)
{ {
FillAdditional(path, result); FillAdditional(path, result);

@ -28,7 +28,7 @@ namespace Emby.Naming.TV
} }
} }
if (result != null) if (result is not null)
{ {
if (!string.IsNullOrEmpty(result.SeriesName)) if (!string.IsNullOrEmpty(result.SeriesName))
{ {

@ -76,7 +76,7 @@ namespace Emby.Naming.Video
} }
} }
if (result.ExtraType != null) if (result.ExtraType is not null)
{ {
return result; return result;
} }

@ -109,7 +109,7 @@ namespace Emby.Naming.Video
for (var i = 0; i < videos.Count; i++) for (var i = 0; i < videos.Count; i++)
{ {
var video = videos[i]; var video = videos[i];
if (video.ExtraType != null) if (video.ExtraType is not null)
{ {
continue; continue;
} }

@ -113,7 +113,7 @@ namespace Emby.Notifications
} }
} }
if (options != null && !string.IsNullOrEmpty(request.NotificationType)) if (options is not null && !string.IsNullOrEmpty(request.NotificationType))
{ {
var config = GetConfiguration(); var config = GetConfiguration();

@ -49,7 +49,7 @@ namespace Emby.Photos
if (item.IsFileProtocol) if (item.IsFileProtocol)
{ {
var file = directoryService.GetFile(item.Path); var file = directoryService.GetFile(item.Path);
return file != null && file.LastWriteTimeUtc != item.DateModified; return file is not null && file.LastWriteTimeUtc != item.DateModified;
} }
return false; return false;
@ -70,20 +70,20 @@ namespace Emby.Photos
if (file.GetTag(TagTypes.TiffIFD) is IFDTag tag) if (file.GetTag(TagTypes.TiffIFD) is IFDTag tag)
{ {
var structure = tag.Structure; var structure = tag.Structure;
if (structure != null if (structure is not null
&& structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) is SubIFDEntry exif) && structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) is SubIFDEntry exif)
{ {
var exifStructure = exif.Structure; var exifStructure = exif.Structure;
if (exifStructure != null) if (exifStructure is not null)
{ {
var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry; var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;
if (entry != null) if (entry is not null)
{ {
item.Aperture = (double)entry.Value.Numerator / entry.Value.Denominator; item.Aperture = (double)entry.Value.Numerator / entry.Value.Denominator;
} }
entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry; entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;
if (entry != null) if (entry is not null)
{ {
item.ShutterSpeed = (double)entry.Value.Numerator / entry.Value.Denominator; item.ShutterSpeed = (double)entry.Value.Numerator / entry.Value.Denominator;
} }

@ -131,7 +131,7 @@ namespace Emby.Server.Implementations.AppBase
{ {
_configuration = value; _configuration = value;
_configurationLoaded = value != null; _configurationLoaded = value is not null;
} }
} }

@ -196,7 +196,7 @@ namespace Emby.Server.Implementations
/// <summary> /// <summary>
/// Gets a value indicating whether this instance can self restart. /// Gets a value indicating whether this instance can self restart.
/// </summary> /// </summary>
public bool CanSelfRestart => _startupOptions.RestartPath != null; public bool CanSelfRestart => _startupOptions.RestartPath is not null;
public bool CoreStartupHasCompleted { get; private set; } public bool CoreStartupHasCompleted { get; private set; }
@ -311,7 +311,7 @@ namespace Emby.Server.Implementations
public X509Certificate2 Certificate { get; private set; } public X509Certificate2 Certificate { get; private set; }
/// <inheritdoc/> /// <inheritdoc/>
public bool ListenWithHttps => Certificate != null && ConfigurationManager.GetNetworkConfiguration().EnableHttps; public bool ListenWithHttps => Certificate is not null && ConfigurationManager.GetNetworkConfiguration().EnableHttps;
public string FriendlyName => public string FriendlyName =>
string.IsNullOrEmpty(ConfigurationManager.Configuration.ServerName) string.IsNullOrEmpty(ConfigurationManager.Configuration.ServerName)
@ -403,7 +403,7 @@ namespace Emby.Server.Implementations
// Convert to list so this isn't executed for each iteration // Convert to list so this isn't executed for each iteration
var parts = GetExportTypes<T>() var parts = GetExportTypes<T>()
.Select(CreateInstanceSafe) .Select(CreateInstanceSafe)
.Where(i => i != null) .Where(i => i is not null)
.Cast<T>() .Cast<T>()
.ToList(); .ToList();
@ -424,7 +424,7 @@ namespace Emby.Server.Implementations
// Convert to list so this isn't executed for each iteration // Convert to list so this isn't executed for each iteration
var parts = GetExportTypes<T>() var parts = GetExportTypes<T>()
.Select(i => defaultFunc(i)) .Select(i => defaultFunc(i))
.Where(i => i != null) .Where(i => i is not null)
.Cast<T>() .Cast<T>()
.ToList(); .ToList();

@ -227,7 +227,7 @@ namespace Emby.Server.Implementations.Channels
.ToList(); .ToList();
} }
if (user != null) if (user is not null)
{ {
channels = channels.Where(i => channels = channels.Where(i =>
{ {
@ -739,7 +739,7 @@ namespace Emby.Server.Implementations.Channels
query.GroupByPresentationUniqueKey = false; query.GroupByPresentationUniqueKey = false;
// null if came from cache // null if came from cache
if (itemsResult != null) if (itemsResult is not null)
{ {
var items = itemsResult.Items; var items = itemsResult.Items;
var itemsLen = items.Count; var itemsLen = items.Count;
@ -761,7 +761,7 @@ namespace Emby.Server.Implementations.Channels
foreach (var deadId in deadIds) foreach (var deadId in deadIds)
{ {
var deadItem = _libraryManager.GetItemById(deadId); var deadItem = _libraryManager.GetItemById(deadId);
if (deadItem != null) if (deadItem is not null)
{ {
_libraryManager.DeleteItem( _libraryManager.DeleteItem(
deadItem, deadItem,
@ -813,7 +813,7 @@ namespace Emby.Server.Implementations.Channels
{ {
await using FileStream jsonStream = AsyncFile.OpenRead(cachePath); await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false); var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
if (cachedResult != null) if (cachedResult is not null)
{ {
return null; return null;
} }
@ -836,7 +836,7 @@ namespace Emby.Server.Implementations.Channels
{ {
await using FileStream jsonStream = AsyncFile.OpenRead(cachePath); await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false); var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
if (cachedResult != null) if (cachedResult is not null)
{ {
return null; return null;
} }
@ -1156,7 +1156,7 @@ namespace Emby.Server.Implementations.Channels
{ {
_libraryManager.CreateItem(item, parentFolder); _libraryManager.CreateItem(item, parentFolder);
if (info.People != null && info.People.Count > 0) if (info.People is not null && info.People.Count > 0)
{ {
_libraryManager.UpdatePeople(item, info.People); _libraryManager.UpdatePeople(item, info.People);
} }

@ -59,7 +59,7 @@ namespace Emby.Server.Implementations.Collections
var episode = subItem as Episode; var episode = subItem as Episode;
var series = episode?.Series; var series = episode?.Series;
if (series != null && series.HasImage(ImageType.Primary)) if (series is not null && series.HasImage(ImageType.Primary))
{ {
return series; return series;
} }
@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.Collections
var parent = subItem.GetOwner() ?? subItem.GetParent(); var parent = subItem.GetOwner() ?? subItem.GetParent();
if (parent != null && parent.HasImage(ImageType.Primary)) if (parent is not null && parent.HasImage(ImageType.Primary))
{ {
if (parent is MusicAlbum) if (parent is MusicAlbum)
{ {
@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Collections
return null; return null;
}) })
.Where(i => i != null) .Where(i => i is not null)
.GroupBy(x => x!.Id) // We removed the null values .GroupBy(x => x!.Id) // We removed the null values
.Select(x => x.First()) .Select(x => x.First())
.ToList()!; // Again... the list doesn't contain any null values .ToList()!; // Again... the list doesn't contain any null values

@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Collections
internal async Task<Folder?> EnsureLibraryFolder(string path, bool createIfNeeded) internal async Task<Folder?> EnsureLibraryFolder(string path, bool createIfNeeded)
{ {
var existingFolder = FindFolders(path).FirstOrDefault(); var existingFolder = FindFolders(path).FirstOrDefault();
if (existingFolder != null) if (existingFolder is not null)
{ {
return existingFolder; return existingFolder;
} }
@ -265,7 +265,7 @@ namespace Emby.Server.Implementations.Collections
{ {
var childItem = _libraryManager.GetItemById(guidId); var childItem = _libraryManager.GetItemById(guidId);
var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value.Equals(guidId)) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase))); var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value.Equals(guidId)) || (childItem is not null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase)));
if (child is null) if (child is null)
{ {
@ -275,7 +275,7 @@ namespace Emby.Server.Implementations.Collections
list.Add(child); list.Add(child);
if (childItem != null) if (childItem is not null)
{ {
itemList.Add(childItem); itemList.Add(childItem);
} }

@ -101,7 +101,7 @@ namespace Emby.Server.Implementations.Data
protected ManagedConnection GetConnection(bool readOnly = false) protected ManagedConnection GetConnection(bool readOnly = false)
{ {
WriteLock.Wait(); WriteLock.Wait();
if (WriteConnection != null) if (WriteConnection is not null)
{ {
return new ManagedConnection(WriteConnection, WriteLock); return new ManagedConnection(WriteConnection, WriteLock);
} }

@ -44,7 +44,7 @@ namespace Emby.Server.Implementations.Data
var item = _libraryManager.GetItemById(itemId); var item = _libraryManager.GetItemById(itemId);
if (item != null) if (item is not null)
{ {
_logger.LogInformation("Cleaning item {0} type: {1} path: {2}", item.Name, item.GetType().Name, item.Path ?? string.Empty); _logger.LogInformation("Cleaning item {0} type: {1} path: {2}", item.Name, item.GetType().Name, item.Path ?? string.Empty);

@ -1146,7 +1146,7 @@ namespace Emby.Server.Implementations.Data
{ {
var image = ItemImageInfoFromValueString(part); var image = ItemImageInfoFromValueString(part);
if (image != null) if (image is not null)
{ {
result[position++] = image; result[position++] = image;
} }
@ -1825,7 +1825,7 @@ namespace Emby.Server.Implementations.Data
var hasSeries = item as IHasSeries; var hasSeries = item as IHasSeries;
if (hasSeriesFields) if (hasSeriesFields)
{ {
if (hasSeries != null) if (hasSeries is not null)
{ {
if (reader.TryGetGuid(index, out var seriesId)) if (reader.TryGetGuid(index, out var seriesId))
{ {
@ -1938,7 +1938,7 @@ namespace Emby.Server.Implementations.Data
if (HasField(query, ItemFields.SeriesPresentationUniqueKey)) if (HasField(query, ItemFields.SeriesPresentationUniqueKey))
{ {
if (hasSeries != null) if (hasSeries is not null)
{ {
if (reader.TryGetString(index, out var seriesPresentationUniqueKey)) if (reader.TryGetString(index, out var seriesPresentationUniqueKey))
{ {
@ -2205,7 +2205,7 @@ namespace Emby.Server.Implementations.Data
private bool HasProgramAttributes(InternalItemsQuery query) private bool HasProgramAttributes(InternalItemsQuery query)
{ {
if (query.ParentType != null && _programExcludeParentTypes.Contains(query.ParentType.Value)) if (query.ParentType is not null && _programExcludeParentTypes.Contains(query.ParentType.Value))
{ {
return false; return false;
} }
@ -2220,7 +2220,7 @@ namespace Emby.Server.Implementations.Data
private bool HasServiceName(InternalItemsQuery query) private bool HasServiceName(InternalItemsQuery query)
{ {
if (query.ParentType != null && _programExcludeParentTypes.Contains(query.ParentType.Value)) if (query.ParentType is not null && _programExcludeParentTypes.Contains(query.ParentType.Value))
{ {
return false; return false;
} }
@ -2235,7 +2235,7 @@ namespace Emby.Server.Implementations.Data
private bool HasStartDate(InternalItemsQuery query) private bool HasStartDate(InternalItemsQuery query)
{ {
if (query.ParentType != null && _programExcludeParentTypes.Contains(query.ParentType.Value)) if (query.ParentType is not null && _programExcludeParentTypes.Contains(query.ParentType.Value))
{ {
return false; return false;
} }
@ -2270,7 +2270,7 @@ namespace Emby.Server.Implementations.Data
private bool HasArtistFields(InternalItemsQuery query) private bool HasArtistFields(InternalItemsQuery query)
{ {
if (query.ParentType != null && _artistExcludeParentTypes.Contains(query.ParentType.Value)) if (query.ParentType is not null && _artistExcludeParentTypes.Contains(query.ParentType.Value))
{ {
return false; return false;
} }
@ -2392,7 +2392,7 @@ namespace Emby.Server.Implementations.Data
columns.Add("UserDatas.rating"); columns.Add("UserDatas.rating");
} }
if (query.SimilarTo != null) if (query.SimilarTo is not null)
{ {
var item = query.SimilarTo; var item = query.SimilarTo;
@ -2681,7 +2681,7 @@ namespace Emby.Server.Implementations.Data
foreach (var row in statement.ExecuteQuery()) foreach (var row in statement.ExecuteQuery())
{ {
var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields); var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields);
if (item != null) if (item is not null)
{ {
items.Add(item); items.Add(item);
} }
@ -2923,7 +2923,7 @@ namespace Emby.Server.Implementations.Data
foreach (var row in statement.ExecuteQuery()) foreach (var row in statement.ExecuteQuery())
{ {
var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields); var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields);
if (item != null) if (item is not null)
{ {
list.Add(item); list.Add(item);
} }
@ -2966,7 +2966,7 @@ namespace Emby.Server.Implementations.Data
private string GetOrderByText(InternalItemsQuery query) private string GetOrderByText(InternalItemsQuery query)
{ {
var orderBy = query.OrderBy; var orderBy = query.OrderBy;
bool hasSimilar = query.SimilarTo != null; bool hasSimilar = query.SimilarTo is not null;
bool hasSearch = !string.IsNullOrEmpty(query.SearchTerm); bool hasSearch = !string.IsNullOrEmpty(query.SearchTerm);
if (hasSimilar || hasSearch) if (hasSimilar || hasSearch)
@ -3396,7 +3396,7 @@ namespace Emby.Server.Implementations.Data
} }
} }
if (query.SimilarTo != null && query.MinSimilarityScore > 0) if (query.SimilarTo is not null && query.MinSimilarityScore > 0)
{ {
whereClauses.Add("SimilarityScore > " + (query.MinSimilarityScore - 1).ToString(CultureInfo.InvariantCulture)); whereClauses.Add("SimilarityScore > " + (query.MinSimilarityScore - 1).ToString(CultureInfo.InvariantCulture));
} }
@ -3683,7 +3683,7 @@ namespace Emby.Server.Implementations.Data
.Append(paramName) .Append(paramName)
.Append("))) OR "); .Append("))) OR ");
if (statement != null) if (statement is not null)
{ {
query.PersonIds[i].TryWriteBytes(idBytes); query.PersonIds[i].TryWriteBytes(idBytes);
statement.TryBind(paramName, idBytes); statement.TryBind(paramName, idBytes);
@ -3734,7 +3734,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(nameContains)) if (!string.IsNullOrWhiteSpace(nameContains))
{ {
whereClauses.Add("(CleanName like @NameContains or OriginalTitle like @NameContains)"); whereClauses.Add("(CleanName like @NameContains or OriginalTitle like @NameContains)");
if (statement != null) if (statement is not null)
{ {
nameContains = FixUnicodeChars(nameContains); nameContains = FixUnicodeChars(nameContains);
@ -3865,7 +3865,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ArtistIds" + index; var paramName = "@ArtistIds" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))"); clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))");
if (statement != null) if (statement is not null)
{ {
statement.TryBind(paramName, artistId); statement.TryBind(paramName, artistId);
} }
@ -3886,7 +3886,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ArtistIds" + index; var paramName = "@ArtistIds" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=1))"); clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=1))");
if (statement != null) if (statement is not null)
{ {
statement.TryBind(paramName, artistId); statement.TryBind(paramName, artistId);
} }
@ -3907,7 +3907,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ArtistIds" + index; var paramName = "@ArtistIds" + index;
clauses.Add("((select CleanName from TypedBaseItems where guid=" + paramName + ") in (select CleanValue from ItemValues where ItemId=Guid and Type=0) AND (select CleanName from TypedBaseItems where guid=" + paramName + ") not in (select CleanValue from ItemValues where ItemId=Guid and Type=1))"); clauses.Add("((select CleanName from TypedBaseItems where guid=" + paramName + ") in (select CleanValue from ItemValues where ItemId=Guid and Type=0) AND (select CleanName from TypedBaseItems where guid=" + paramName + ") not in (select CleanValue from ItemValues where ItemId=Guid and Type=1))");
if (statement != null) if (statement is not null)
{ {
statement.TryBind(paramName, artistId); statement.TryBind(paramName, artistId);
} }
@ -3928,7 +3928,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@AlbumIds" + index; var paramName = "@AlbumIds" + index;
clauses.Add("Album in (select Name from typedbaseitems where guid=" + paramName + ")"); clauses.Add("Album in (select Name from typedbaseitems where guid=" + paramName + ")");
if (statement != null) if (statement is not null)
{ {
statement.TryBind(paramName, albumId); statement.TryBind(paramName, albumId);
} }
@ -3949,7 +3949,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ExcludeArtistId" + index; var paramName = "@ExcludeArtistId" + index;
clauses.Add("(guid not in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))"); clauses.Add("(guid not in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))");
if (statement != null) if (statement is not null)
{ {
statement.TryBind(paramName, artistId); statement.TryBind(paramName, artistId);
} }
@ -3970,7 +3970,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@GenreId" + index; var paramName = "@GenreId" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=2))"); clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=2))");
if (statement != null) if (statement is not null)
{ {
statement.TryBind(paramName, genreId); statement.TryBind(paramName, genreId);
} }
@ -3989,7 +3989,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in query.Genres) foreach (var item in query.Genres)
{ {
clauses.Add("@Genre" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=2)"); clauses.Add("@Genre" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=2)");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@Genre" + index, GetCleanValue(item)); statement.TryBind("@Genre" + index, GetCleanValue(item));
} }
@ -4008,7 +4008,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in tags) foreach (var item in tags)
{ {
clauses.Add("@Tag" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=4)"); clauses.Add("@Tag" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=4)");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@Tag" + index, GetCleanValue(item)); statement.TryBind("@Tag" + index, GetCleanValue(item));
} }
@ -4027,7 +4027,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in excludeTags) foreach (var item in excludeTags)
{ {
clauses.Add("@ExcludeTag" + index + " not in (select CleanValue from ItemValues where ItemId=Guid and Type=4)"); clauses.Add("@ExcludeTag" + index + " not in (select CleanValue from ItemValues where ItemId=Guid and Type=4)");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@ExcludeTag" + index, GetCleanValue(item)); statement.TryBind("@ExcludeTag" + index, GetCleanValue(item));
} }
@ -4049,7 +4049,7 @@ namespace Emby.Server.Implementations.Data
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=3))"); clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=3))");
if (statement != null) if (statement is not null)
{ {
statement.TryBind(paramName, studioId); statement.TryBind(paramName, studioId);
} }
@ -4068,7 +4068,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in query.OfficialRatings) foreach (var item in query.OfficialRatings)
{ {
clauses.Add("OfficialRating=@OfficialRating" + index); clauses.Add("OfficialRating=@OfficialRating" + index);
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@OfficialRating" + index, item); statement.TryBind("@OfficialRating" + index, item);
} }
@ -4083,7 +4083,7 @@ namespace Emby.Server.Implementations.Data
if (query.MinParentalRating.HasValue) if (query.MinParentalRating.HasValue)
{ {
whereClauses.Add("InheritedParentalRatingValue>=@MinParentalRating"); whereClauses.Add("InheritedParentalRatingValue>=@MinParentalRating");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@MinParentalRating", query.MinParentalRating.Value); statement.TryBind("@MinParentalRating", query.MinParentalRating.Value);
} }
@ -4092,7 +4092,7 @@ namespace Emby.Server.Implementations.Data
if (query.MaxParentalRating.HasValue) if (query.MaxParentalRating.HasValue)
{ {
whereClauses.Add("InheritedParentalRatingValue<=@MaxParentalRating"); whereClauses.Add("InheritedParentalRatingValue<=@MaxParentalRating");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@MaxParentalRating", query.MaxParentalRating.Value); statement.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
} }
@ -4149,7 +4149,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(query.HasNoAudioTrackWithLanguage)) if (!string.IsNullOrWhiteSpace(query.HasNoAudioTrackWithLanguage))
{ {
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Audio' and MediaStreams.Language=@HasNoAudioTrackWithLanguage limit 1) is null)"); whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Audio' and MediaStreams.Language=@HasNoAudioTrackWithLanguage limit 1) is null)");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@HasNoAudioTrackWithLanguage", query.HasNoAudioTrackWithLanguage); statement.TryBind("@HasNoAudioTrackWithLanguage", query.HasNoAudioTrackWithLanguage);
} }
@ -4158,7 +4158,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(query.HasNoInternalSubtitleTrackWithLanguage)) if (!string.IsNullOrWhiteSpace(query.HasNoInternalSubtitleTrackWithLanguage))
{ {
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=0 and MediaStreams.Language=@HasNoInternalSubtitleTrackWithLanguage limit 1) is null)"); whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=0 and MediaStreams.Language=@HasNoInternalSubtitleTrackWithLanguage limit 1) is null)");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@HasNoInternalSubtitleTrackWithLanguage", query.HasNoInternalSubtitleTrackWithLanguage); statement.TryBind("@HasNoInternalSubtitleTrackWithLanguage", query.HasNoInternalSubtitleTrackWithLanguage);
} }
@ -4167,7 +4167,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(query.HasNoExternalSubtitleTrackWithLanguage)) if (!string.IsNullOrWhiteSpace(query.HasNoExternalSubtitleTrackWithLanguage))
{ {
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=1 and MediaStreams.Language=@HasNoExternalSubtitleTrackWithLanguage limit 1) is null)"); whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=1 and MediaStreams.Language=@HasNoExternalSubtitleTrackWithLanguage limit 1) is null)");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@HasNoExternalSubtitleTrackWithLanguage", query.HasNoExternalSubtitleTrackWithLanguage); statement.TryBind("@HasNoExternalSubtitleTrackWithLanguage", query.HasNoExternalSubtitleTrackWithLanguage);
} }
@ -4176,7 +4176,7 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(query.HasNoSubtitleTrackWithLanguage)) if (!string.IsNullOrWhiteSpace(query.HasNoSubtitleTrackWithLanguage))
{ {
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.Language=@HasNoSubtitleTrackWithLanguage limit 1) is null)"); whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.Language=@HasNoSubtitleTrackWithLanguage limit 1) is null)");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@HasNoSubtitleTrackWithLanguage", query.HasNoSubtitleTrackWithLanguage); statement.TryBind("@HasNoSubtitleTrackWithLanguage", query.HasNoSubtitleTrackWithLanguage);
} }
@ -4229,7 +4229,7 @@ namespace Emby.Server.Implementations.Data
if (query.Years.Length == 1) if (query.Years.Length == 1)
{ {
whereClauses.Add("ProductionYear=@Years"); whereClauses.Add("ProductionYear=@Years");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@Years", query.Years[0].ToString(CultureInfo.InvariantCulture)); statement.TryBind("@Years", query.Years[0].ToString(CultureInfo.InvariantCulture));
} }
@ -4245,7 +4245,7 @@ namespace Emby.Server.Implementations.Data
if (isVirtualItem.HasValue) if (isVirtualItem.HasValue)
{ {
whereClauses.Add("IsVirtualItem=@IsVirtualItem"); whereClauses.Add("IsVirtualItem=@IsVirtualItem");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@IsVirtualItem", isVirtualItem.Value); statement.TryBind("@IsVirtualItem", isVirtualItem.Value);
} }
@ -4279,7 +4279,7 @@ namespace Emby.Server.Implementations.Data
if (queryMediaTypes.Length == 1) if (queryMediaTypes.Length == 1)
{ {
whereClauses.Add("MediaType=@MediaTypes"); whereClauses.Add("MediaType=@MediaTypes");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@MediaTypes", queryMediaTypes[0]); statement.TryBind("@MediaTypes", queryMediaTypes[0]);
} }
@ -4299,7 +4299,7 @@ namespace Emby.Server.Implementations.Data
foreach (var id in query.ItemIds) foreach (var id in query.ItemIds)
{ {
includeIds.Add("Guid = @IncludeId" + index); includeIds.Add("Guid = @IncludeId" + index);
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@IncludeId" + index, id); statement.TryBind("@IncludeId" + index, id);
} }
@ -4318,7 +4318,7 @@ namespace Emby.Server.Implementations.Data
foreach (var id in query.ExcludeItemIds) foreach (var id in query.ExcludeItemIds)
{ {
excludeIds.Add("Guid <> @ExcludeId" + index); excludeIds.Add("Guid <> @ExcludeId" + index);
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@ExcludeId" + index, id); statement.TryBind("@ExcludeId" + index, id);
} }
@ -4329,7 +4329,7 @@ namespace Emby.Server.Implementations.Data
whereClauses.Add(string.Join(" AND ", excludeIds)); whereClauses.Add(string.Join(" AND ", excludeIds));
} }
if (query.ExcludeProviderIds != null && query.ExcludeProviderIds.Count > 0) if (query.ExcludeProviderIds is not null && query.ExcludeProviderIds.Count > 0)
{ {
var excludeIds = new List<string>(); var excludeIds = new List<string>();
@ -4343,7 +4343,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ExcludeProviderId" + index; var paramName = "@ExcludeProviderId" + index;
excludeIds.Add("(ProviderIds is null or ProviderIds not like " + paramName + ")"); excludeIds.Add("(ProviderIds is null or ProviderIds not like " + paramName + ")");
if (statement != null) if (statement is not null)
{ {
statement.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%"); statement.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
} }
@ -4359,7 +4359,7 @@ namespace Emby.Server.Implementations.Data
} }
} }
if (query.HasAnyProviderId != null && query.HasAnyProviderId.Count > 0) if (query.HasAnyProviderId is not null && query.HasAnyProviderId.Count > 0)
{ {
var hasProviderIds = new List<string>(); var hasProviderIds = new List<string>();
@ -4386,7 +4386,7 @@ namespace Emby.Server.Implementations.Data
hasProviderIds.Add("ProviderIds like " + paramName); hasProviderIds.Add("ProviderIds like " + paramName);
// this replaces the placeholder with a value, here: %key=val% // this replaces the placeholder with a value, here: %key=val%
if (statement != null) if (statement is not null)
{ {
statement.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%"); statement.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
} }
@ -4468,7 +4468,7 @@ namespace Emby.Server.Implementations.Data
{ {
whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)"); whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@AncestorId", query.AncestorIds[0]); statement.TryBind("@AncestorId", query.AncestorIds[0]);
} }
@ -4484,7 +4484,7 @@ namespace Emby.Server.Implementations.Data
{ {
var inClause = "select guid from TypedBaseItems where PresentationUniqueKey=@AncestorWithPresentationUniqueKey"; var inClause = "select guid from TypedBaseItems where PresentationUniqueKey=@AncestorWithPresentationUniqueKey";
whereClauses.Add(string.Format(CultureInfo.InvariantCulture, "Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause)); whereClauses.Add(string.Format(CultureInfo.InvariantCulture, "Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause));
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@AncestorWithPresentationUniqueKey", query.AncestorWithPresentationUniqueKey); statement.TryBind("@AncestorWithPresentationUniqueKey", query.AncestorWithPresentationUniqueKey);
} }
@ -4494,7 +4494,7 @@ namespace Emby.Server.Implementations.Data
{ {
whereClauses.Add("SeriesPresentationUniqueKey=@SeriesPresentationUniqueKey"); whereClauses.Add("SeriesPresentationUniqueKey=@SeriesPresentationUniqueKey");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@SeriesPresentationUniqueKey", query.SeriesPresentationUniqueKey); statement.TryBind("@SeriesPresentationUniqueKey", query.SeriesPresentationUniqueKey);
} }
@ -4503,7 +4503,7 @@ namespace Emby.Server.Implementations.Data
if (query.BlockUnratedItems.Length == 1) if (query.BlockUnratedItems.Length == 1)
{ {
whereClauses.Add("(InheritedParentalRatingValue > 0 or UnratedType <> @UnratedType)"); whereClauses.Add("(InheritedParentalRatingValue > 0 or UnratedType <> @UnratedType)");
if (statement != null) if (statement is not null)
{ {
statement.TryBind("@UnratedType", query.BlockUnratedItems[0].ToString()); statement.TryBind("@UnratedType", query.BlockUnratedItems[0].ToString());
} }
@ -4916,7 +4916,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{ {
var whereClauses = new List<string>(); var whereClauses = new List<string>();
if (query.User != null && query.IsFavorite.HasValue) if (query.User is not null && query.IsFavorite.HasValue)
{ {
whereClauses.Add(@"p.Name IN ( whereClauses.Add(@"p.Name IN (
SELECT Name FROM TypedBaseItems WHERE UserDataKey IN ( SELECT Name FROM TypedBaseItems WHERE UserDataKey IN (
@ -5293,7 +5293,7 @@ AND Type = @InternalPersonType)");
.Append(" group by PresentationUniqueKey"); .Append(" group by PresentationUniqueKey");
if (query.OrderBy.Count != 0 if (query.OrderBy.Count != 0
|| query.SimilarTo != null || query.SimilarTo is not null
|| !string.IsNullOrEmpty(query.SearchTerm)) || !string.IsNullOrEmpty(query.SearchTerm))
{ {
stringBuilder.Append(GetOrderByText(query)); stringBuilder.Append(GetOrderByText(query));
@ -5361,7 +5361,7 @@ AND Type = @InternalPersonType)");
statement.TryBind("@UserId", query.User.InternalId); statement.TryBind("@UserId", query.User.InternalId);
} }
if (typeSubQuery != null) if (typeSubQuery is not null)
{ {
GetWhereClauses(typeSubQuery, null); GetWhereClauses(typeSubQuery, null);
} }
@ -5382,7 +5382,7 @@ AND Type = @InternalPersonType)");
foreach (var row in statement.ExecuteQuery()) foreach (var row in statement.ExecuteQuery())
{ {
var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields); var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields);
if (item != null) if (item is not null)
{ {
var countStartColumn = columns.Count - 1; var countStartColumn = columns.Count - 1;
@ -5402,7 +5402,7 @@ AND Type = @InternalPersonType)");
statement.TryBind("@UserId", query.User.InternalId); statement.TryBind("@UserId", query.User.InternalId);
} }
if (typeSubQuery != null) if (typeSubQuery is not null)
{ {
GetWhereClauses(typeSubQuery, null); GetWhereClauses(typeSubQuery, null);
} }

@ -30,7 +30,7 @@ namespace Emby.Server.Implementations.Data
return _typeMap.GetOrAdd(typeName, k => AppDomain.CurrentDomain.GetAssemblies() return _typeMap.GetOrAdd(typeName, k => AppDomain.CurrentDomain.GetAssemblies()
.Select(a => a.GetType(k)) .Select(a => a.GetType(k))
.FirstOrDefault(t => t != null)); .FirstOrDefault(t => t is not null));
} }
} }
} }

@ -213,7 +213,7 @@ namespace Emby.Server.Implementations.Dto
dto.DisplayPreferencesId = item.DisplayPreferencesId.ToString("N", CultureInfo.InvariantCulture); dto.DisplayPreferencesId = item.DisplayPreferencesId.ToString("N", CultureInfo.InvariantCulture);
} }
if (user != null) if (user is not null)
{ {
AttachUserSpecificInfo(dto, item, user, options); AttachUserSpecificInfo(dto, item, user, options);
} }
@ -254,7 +254,7 @@ namespace Emby.Server.Implementations.Dto
var liveTvManager = LivetvManager; var liveTvManager = LivetvManager;
var activeRecording = liveTvManager.GetActiveRecordingInfo(item.Path); var activeRecording = liveTvManager.GetActiveRecordingInfo(item.Path);
if (activeRecording != null) if (activeRecording is not null)
{ {
dto.Type = BaseItemKind.Recording; dto.Type = BaseItemKind.Recording;
dto.CanDownload = false; dto.CanDownload = false;
@ -317,7 +317,7 @@ namespace Emby.Server.Implementations.Dto
{ {
var dto = GetBaseItemDtoInternal(item, options, user); var dto = GetBaseItemDtoInternal(item, options, user);
if (taggedItems != null && options.ContainsField(ItemFields.ItemCounts)) if (taggedItems is not null && options.ContainsField(ItemFields.ItemCounts))
{ {
SetItemByNameInfo(item, dto, taggedItems); SetItemByNameInfo(item, dto, taggedItems);
} }
@ -417,7 +417,7 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.BasicSyncInfo)) if (options.ContainsField(ItemFields.BasicSyncInfo))
{ {
var userCanSync = user != null && user.HasPermission(PermissionKind.EnableContentDownloading); var userCanSync = user is not null && user.HasPermission(PermissionKind.EnableContentDownloading);
if (userCanSync && item.SupportsExternalTransfer) if (userCanSync && item.SupportsExternalTransfer)
{ {
dto.SupportsSync = true; dto.SupportsSync = true;
@ -460,7 +460,7 @@ namespace Emby.Server.Implementations.Dto
var album = item.AlbumEntity; var album = item.AlbumEntity;
if (album != null) if (album is not null)
{ {
dto.Album = album.Name; dto.Album = album.Name;
dto.AlbumId = album.Id; dto.AlbumId = album.Id;
@ -491,7 +491,7 @@ namespace Emby.Server.Implementations.Dto
{ {
return images return images
.Select(p => GetImageCacheTag(item, p)) .Select(p => GetImageCacheTag(item, p))
.Where(i => i != null) .Where(i => i is not null)
.ToArray(); .ToArray();
} }
@ -570,7 +570,7 @@ namespace Emby.Server.Implementations.Dto
_logger.LogError(ex, "Error getting person {Name}", c); _logger.LogError(ex, "Error getting person {Name}", c);
return null; return null;
} }
}).Where(i => i != null) }).Where(i => i is not null)
.Where(i => user is null ? .Where(i => user is null ?
true : true :
i.IsVisible(user)) i.IsVisible(user))
@ -593,13 +593,13 @@ namespace Emby.Server.Implementations.Dto
{ {
baseItemPerson.PrimaryImageTag = GetTagAndFillBlurhash(dto, entity, ImageType.Primary); baseItemPerson.PrimaryImageTag = GetTagAndFillBlurhash(dto, entity, ImageType.Primary);
baseItemPerson.Id = entity.Id; baseItemPerson.Id = entity.Id;
if (dto.ImageBlurHashes != null) if (dto.ImageBlurHashes is not null)
{ {
// Only add BlurHash for the person's image. // Only add BlurHash for the person's image.
baseItemPerson.ImageBlurHashes = new Dictionary<ImageType, Dictionary<string, string>>(); baseItemPerson.ImageBlurHashes = new Dictionary<ImageType, Dictionary<string, string>>();
foreach (var (imageType, blurHash) in dto.ImageBlurHashes) foreach (var (imageType, blurHash) in dto.ImageBlurHashes)
{ {
if (blurHash != null) if (blurHash is not null)
{ {
baseItemPerson.ImageBlurHashes[imageType] = new Dictionary<string, string>(); baseItemPerson.ImageBlurHashes[imageType] = new Dictionary<string, string>();
foreach (var (imageId, blurHashValue) in blurHash) foreach (var (imageId, blurHashValue) in blurHash)
@ -662,7 +662,7 @@ namespace Emby.Server.Implementations.Dto
private string GetTagAndFillBlurhash(BaseItemDto dto, BaseItem item, ImageType imageType, int imageIndex = 0) private string GetTagAndFillBlurhash(BaseItemDto dto, BaseItem item, ImageType imageType, int imageIndex = 0)
{ {
var image = item.GetImageInfo(imageType, imageIndex); var image = item.GetImageInfo(imageType, imageIndex);
if (image != null) if (image is not null)
{ {
return GetTagAndFillBlurhash(dto, item, image); return GetTagAndFillBlurhash(dto, item, image);
} }
@ -782,7 +782,7 @@ namespace Emby.Server.Implementations.Dto
{ {
var tag = GetTagAndFillBlurhash(dto, item, image); var tag = GetTagAndFillBlurhash(dto, item, image);
if (tag != null) if (tag is not null)
{ {
dto.ImageTags[image.Type] = tag; dto.ImageTags[image.Type] = tag;
} }
@ -917,7 +917,7 @@ namespace Emby.Server.Implementations.Dto
var albumParent = audio.AlbumEntity; var albumParent = audio.AlbumEntity;
if (albumParent != null) if (albumParent is not null)
{ {
dto.AlbumId = albumParent.Id; dto.AlbumId = albumParent.Id;
dto.AlbumPrimaryImageTag = GetTagAndFillBlurhash(dto, albumParent, ImageType.Primary); dto.AlbumPrimaryImageTag = GetTagAndFillBlurhash(dto, albumParent, ImageType.Primary);
@ -967,7 +967,7 @@ namespace Emby.Server.Implementations.Dto
{ {
EnableImages = false EnableImages = false
}); });
if (artist != null) if (artist is not null)
{ {
return new NameGuidPair return new NameGuidPair
{ {
@ -977,7 +977,7 @@ namespace Emby.Server.Implementations.Dto
} }
return null; return null;
}).Where(i => i != null).ToArray(); }).Where(i => i is not null).ToArray();
} }
if (item is IHasAlbumArtist hasAlbumArtist) if (item is IHasAlbumArtist hasAlbumArtist)
@ -1016,7 +1016,7 @@ namespace Emby.Server.Implementations.Dto
{ {
EnableImages = false EnableImages = false
}); });
if (artist != null) if (artist is not null)
{ {
return new NameGuidPair return new NameGuidPair
{ {
@ -1026,7 +1026,7 @@ namespace Emby.Server.Implementations.Dto
} }
return null; return null;
}).Where(i => i != null).ToArray(); }).Where(i => i is not null).ToArray();
} }
// Add video info // Add video info
@ -1073,7 +1073,7 @@ namespace Emby.Server.Implementations.Dto
{ {
MediaStream[] mediaStreams; MediaStream[] mediaStreams;
if (dto.MediaSources != null && dto.MediaSources.Length > 0) if (dto.MediaSources is not null && dto.MediaSources.Length > 0)
{ {
if (item.SourceType == SourceType.Channel) if (item.SourceType == SourceType.Channel)
{ {
@ -1140,7 +1140,7 @@ namespace Emby.Server.Implementations.Dto
// if (options.ContainsField(ItemFields.SeriesPrimaryImage)) // if (options.ContainsField(ItemFields.SeriesPrimaryImage))
{ {
episodeSeries ??= episode.Series; episodeSeries ??= episode.Series;
if (episodeSeries != null) if (episodeSeries is not null)
{ {
dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, episodeSeries, ImageType.Primary); dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, episodeSeries, ImageType.Primary);
if (dto.ImageTags is null || !dto.ImageTags.ContainsKey(ImageType.Primary)) if (dto.ImageTags is null || !dto.ImageTags.ContainsKey(ImageType.Primary))
@ -1153,7 +1153,7 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.SeriesStudio)) if (options.ContainsField(ItemFields.SeriesStudio))
{ {
episodeSeries ??= episode.Series; episodeSeries ??= episode.Series;
if (episodeSeries != null) if (episodeSeries is not null)
{ {
dto.SeriesStudio = episodeSeries.Studios.FirstOrDefault(); dto.SeriesStudio = episodeSeries.Studios.FirstOrDefault();
} }
@ -1179,7 +1179,7 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.SeriesStudio)) if (options.ContainsField(ItemFields.SeriesStudio))
{ {
series ??= season.Series; series ??= season.Series;
if (series != null) if (series is not null)
{ {
dto.SeriesStudio = series.Studios.FirstOrDefault(); dto.SeriesStudio = series.Studios.FirstOrDefault();
} }
@ -1190,7 +1190,7 @@ namespace Emby.Server.Implementations.Dto
// if (options.ContainsField(ItemFields.SeriesPrimaryImage)) // if (options.ContainsField(ItemFields.SeriesPrimaryImage))
{ {
series ??= season.Series; series ??= season.Series;
if (series != null) if (series is not null)
{ {
dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, series, ImageType.Primary); dto.SeriesPrimaryImageTag = GetTagAndFillBlurhash(dto, series, ImageType.Primary);
if (dto.ImageTags is null || !dto.ImageTags.ContainsKey(ImageType.Primary)) if (dto.ImageTags is null || !dto.ImageTags.ContainsKey(ImageType.Primary))
@ -1256,7 +1256,7 @@ namespace Emby.Server.Implementations.Dto
if (item.SourceType == SourceType.Channel) if (item.SourceType == SourceType.Channel)
{ {
var channel = _libraryManager.GetItemById(item.ChannelId); var channel = _libraryManager.GetItemById(item.ChannelId);
if (channel != null) if (channel is not null)
{ {
dto.ChannelName = channel.Name; dto.ChannelName = channel.Name;
} }
@ -1268,7 +1268,7 @@ namespace Emby.Server.Implementations.Dto
if (currentItem is MusicAlbum musicAlbum) if (currentItem is MusicAlbum musicAlbum)
{ {
var artist = musicAlbum.GetMusicArtist(new DtoOptions(false)); var artist = musicAlbum.GetMusicArtist(new DtoOptions(false));
if (artist != null) if (artist is not null)
{ {
return artist; return artist;
} }
@ -1309,9 +1309,9 @@ namespace Emby.Server.Implementations.Dto
var imageTags = dto.ImageTags; var imageTags = dto.ImageTags;
while ((!(imageTags != null && imageTags.ContainsKey(ImageType.Logo)) && logoLimit > 0) while ((!(imageTags is not null && imageTags.ContainsKey(ImageType.Logo)) && logoLimit > 0)
|| (!(imageTags != null && imageTags.ContainsKey(ImageType.Art)) && artLimit > 0) || (!(imageTags is not null && imageTags.ContainsKey(ImageType.Art)) && artLimit > 0)
|| (!(imageTags != null && imageTags.ContainsKey(ImageType.Thumb)) && thumbLimit > 0) || (!(imageTags is not null && imageTags.ContainsKey(ImageType.Thumb)) && thumbLimit > 0)
|| parent is Series) || parent is Series)
{ {
parent ??= isFirst ? GetImageDisplayParent(item, item) ?? owner : parent; parent ??= isFirst ? GetImageDisplayParent(item, item) ?? owner : parent;
@ -1322,40 +1322,40 @@ namespace Emby.Server.Implementations.Dto
var allImages = parent.ImageInfos; var allImages = parent.ImageInfos;
if (logoLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Logo)) && dto.ParentLogoItemId is null) if (logoLimit > 0 && !(imageTags is not null && imageTags.ContainsKey(ImageType.Logo)) && dto.ParentLogoItemId is null)
{ {
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Logo); var image = allImages.FirstOrDefault(i => i.Type == ImageType.Logo);
if (image != null) if (image is not null)
{ {
dto.ParentLogoItemId = parent.Id; dto.ParentLogoItemId = parent.Id;
dto.ParentLogoImageTag = GetTagAndFillBlurhash(dto, parent, image); dto.ParentLogoImageTag = GetTagAndFillBlurhash(dto, parent, image);
} }
} }
if (artLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Art)) && dto.ParentArtItemId is null) if (artLimit > 0 && !(imageTags is not null && imageTags.ContainsKey(ImageType.Art)) && dto.ParentArtItemId is null)
{ {
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Art); var image = allImages.FirstOrDefault(i => i.Type == ImageType.Art);
if (image != null) if (image is not null)
{ {
dto.ParentArtItemId = parent.Id; dto.ParentArtItemId = parent.Id;
dto.ParentArtImageTag = GetTagAndFillBlurhash(dto, parent, image); dto.ParentArtImageTag = GetTagAndFillBlurhash(dto, parent, image);
} }
} }
if (thumbLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Thumb)) && (dto.ParentThumbItemId is null || parent is Series) && parent is not ICollectionFolder && parent is not UserView) if (thumbLimit > 0 && !(imageTags is not null && imageTags.ContainsKey(ImageType.Thumb)) && (dto.ParentThumbItemId is null || parent is Series) && parent is not ICollectionFolder && parent is not UserView)
{ {
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Thumb); var image = allImages.FirstOrDefault(i => i.Type == ImageType.Thumb);
if (image != null) if (image is not null)
{ {
dto.ParentThumbItemId = parent.Id; dto.ParentThumbItemId = parent.Id;
dto.ParentThumbImageTag = GetTagAndFillBlurhash(dto, parent, image); dto.ParentThumbImageTag = GetTagAndFillBlurhash(dto, parent, image);
} }
} }
if (backdropLimit > 0 && !((dto.BackdropImageTags != null && dto.BackdropImageTags.Length > 0) || (dto.ParentBackdropImageTags != null && dto.ParentBackdropImageTags.Length > 0))) if (backdropLimit > 0 && !((dto.BackdropImageTags is not null && dto.BackdropImageTags.Length > 0) || (dto.ParentBackdropImageTags is not null && dto.ParentBackdropImageTags.Length > 0)))
{ {
var images = allImages.Where(i => i.Type == ImageType.Backdrop).Take(backdropLimit).ToList(); var images = allImages.Where(i => i.Type == ImageType.Backdrop).Take(backdropLimit).ToList();

@ -299,7 +299,7 @@ namespace Emby.Server.Implementations.EntryPoints
SendChangeNotifications(_itemsAdded.ToList(), itemsUpdated, _itemsRemoved.ToList(), foldersAddedTo, foldersRemovedFrom, CancellationToken.None).GetAwaiter().GetResult(); SendChangeNotifications(_itemsAdded.ToList(), itemsUpdated, _itemsRemoved.ToList(), foldersAddedTo, foldersRemovedFrom, CancellationToken.None).GetAwaiter().GetResult();
if (LibraryUpdateTimer != null) if (LibraryUpdateTimer is not null)
{ {
LibraryUpdateTimer.Dispose(); LibraryUpdateTimer.Dispose();
LibraryUpdateTimer = null; LibraryUpdateTimer = null;
@ -475,7 +475,7 @@ namespace Emby.Server.Implementations.EntryPoints
{ {
if (dispose) if (dispose)
{ {
if (LibraryUpdateTimer != null) if (LibraryUpdateTimer is not null)
{ {
LibraryUpdateTimer.Dispose(); LibraryUpdateTimer.Dispose();
LibraryUpdateTimer = null; LibraryUpdateTimer = null;

@ -75,11 +75,11 @@ namespace Emby.Server.Implementations.EntryPoints
var baseItem = e.Item; var baseItem = e.Item;
// Go up one level for indicators // Go up one level for indicators
if (baseItem != null) if (baseItem is not null)
{ {
var parent = baseItem.GetOwner() ?? baseItem.GetParent(); var parent = baseItem.GetOwner() ?? baseItem.GetParent();
if (parent != null) if (parent is not null)
{ {
keys.Add(parent); keys.Add(parent);
} }
@ -97,7 +97,7 @@ namespace Emby.Server.Implementations.EntryPoints
SendNotifications(changes, CancellationToken.None).GetAwaiter().GetResult(); SendNotifications(changes, CancellationToken.None).GetAwaiter().GetResult();
if (_updateTimer != null) if (_updateTimer is not null)
{ {
_updateTimer.Dispose(); _updateTimer.Dispose();
_updateTimer = null; _updateTimer = null;
@ -145,7 +145,7 @@ namespace Emby.Server.Implementations.EntryPoints
public void Dispose() public void Dispose()
{ {
if (_updateTimer != null) if (_updateTimer is not null)
{ {
_updateTimer.Dispose(); _updateTimer.Dispose();
_updateTimer = null; _updateTimer = null;

@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.IO
IEnumerable<BaseItem> itemsToRefresh = paths IEnumerable<BaseItem> itemsToRefresh = paths
.Distinct(StringComparer.OrdinalIgnoreCase) .Distinct(StringComparer.OrdinalIgnoreCase)
.Select(GetAffectedBaseItem) .Select(GetAffectedBaseItem)
.Where(item => item != null) .Where(item => item is not null)
.GroupBy(x => x!.Id) // Removed null values in the previous .Where() .GroupBy(x => x!.Id) // Removed null values in the previous .Where()
.Select(x => x.First())!; .Select(x => x.First())!;
@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.IO
path = System.IO.Path.GetDirectoryName(path) ?? string.Empty; path = System.IO.Path.GetDirectoryName(path) ?? string.Empty;
} }
if (item != null) if (item is not null)
{ {
// If the item has been deleted find the first valid parent that still exists // If the item has been deleted find the first valid parent that still exists
while (!Directory.Exists(item.Path) && !File.Exists(item.Path)) while (!Directory.Exists(item.Path) && !File.Exists(item.Path))
@ -206,7 +206,7 @@ namespace Emby.Server.Implementations.IO
{ {
lock (_timerLock) lock (_timerLock)
{ {
if (_timer != null) if (_timer is not null)
{ {
_timer.Dispose(); _timer.Dispose();
_timer = null; _timer = null;

@ -115,7 +115,7 @@ namespace Emby.Server.Implementations.IO
var options = _libraryManager.GetLibraryOptions(item); var options = _libraryManager.GetLibraryOptions(item);
if (options != null) if (options is not null)
{ {
return options.EnableRealtimeMonitor; return options.EnableRealtimeMonitor;
} }

@ -149,7 +149,7 @@ namespace Emby.Server.Implementations.IO
var extension = Path.GetExtension(shortcutPath); var extension = Path.GetExtension(shortcutPath);
var handler = _shortcutHandlers.Find(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase)); var handler = _shortcutHandlers.Find(i => string.Equals(extension, i.Extension, StringComparison.OrdinalIgnoreCase));
if (handler != null) if (handler is not null)
{ {
handler.Create(shortcutPath, target); handler.Create(shortcutPath, target);
} }
@ -621,14 +621,14 @@ namespace Emby.Server.Implementations.IO
// On linux and osx the search pattern is case sensitive // On linux and osx the search pattern is case sensitive
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method // If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions != null && extensions.Count == 1) if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions is not null && extensions.Count == 1)
{ {
return ToMetadata(new DirectoryInfo(path).EnumerateFiles("*" + extensions[0], enumerationOptions)); return ToMetadata(new DirectoryInfo(path).EnumerateFiles("*" + extensions[0], enumerationOptions));
} }
var files = new DirectoryInfo(path).EnumerateFiles("*", enumerationOptions); var files = new DirectoryInfo(path).EnumerateFiles("*", enumerationOptions);
if (extensions != null && extensions.Count > 0) if (extensions is not null && extensions.Count > 0)
{ {
files = files.Where(i => files = files.Where(i =>
{ {
@ -678,14 +678,14 @@ namespace Emby.Server.Implementations.IO
// On linux and osx the search pattern is case sensitive // On linux and osx the search pattern is case sensitive
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method // If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions != null && extensions.Length == 1) if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions is not null && extensions.Length == 1)
{ {
return Directory.EnumerateFiles(path, "*" + extensions[0], enumerationOptions); return Directory.EnumerateFiles(path, "*" + extensions[0], enumerationOptions);
} }
var files = Directory.EnumerateFiles(path, "*", enumerationOptions); var files = Directory.EnumerateFiles(path, "*", enumerationOptions);
if (extensions != null && extensions.Length > 0) if (extensions is not null && extensions.Length > 0)
{ {
files = files.Where(i => files = files.Where(i =>
{ {

@ -23,7 +23,7 @@ namespace Emby.Server.Implementations.IO
await destination.WriteAsync(buffer.AsMemory(0, read), cancellationToken).ConfigureAwait(false); await destination.WriteAsync(buffer.AsMemory(0, read), cancellationToken).ConfigureAwait(false);
if (onStarted != null) if (onStarted is not null)
{ {
onStarted(); onStarted();
onStarted = null; onStarted = null;

@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Images
{ {
var image = item.GetImageInfo(imageType, 0); var image = item.GetImageInfo(imageType, 0);
if (image != null) if (image is not null)
{ {
if (!image.IsLocalFile) if (!image.IsLocalFile)
{ {
@ -143,20 +143,20 @@ namespace Emby.Server.Implementations.Images
if (useBackdrop) if (useBackdrop)
{ {
var backdrop = i.GetImageInfo(ImageType.Backdrop, 0); var backdrop = i.GetImageInfo(ImageType.Backdrop, 0);
if (backdrop != null && backdrop.IsLocalFile) if (backdrop is not null && backdrop.IsLocalFile)
{ {
return backdrop.Path; return backdrop.Path;
} }
} }
var image = i.GetImageInfo(ImageType.Primary, 0); var image = i.GetImageInfo(ImageType.Primary, 0);
if (image != null && image.IsLocalFile) if (image is not null && image.IsLocalFile)
{ {
return image.Path; return image.Path;
} }
image = i.GetImageInfo(ImageType.Thumb, 0); image = i.GetImageInfo(ImageType.Thumb, 0);
if (image != null && image.IsLocalFile) if (image is not null && image.IsLocalFile)
{ {
return image.Path; return image.Path;
} }
@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Images
{ {
var image = item.GetImageInfo(type, 0); var image = item.GetImageInfo(type, 0);
if (image != null) if (image is not null)
{ {
if (!image.IsLocalFile) if (!image.IsLocalFile)
{ {

@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.Images
if (i is Episode episode) if (i is Episode episode)
{ {
var series = episode.Series; var series = episode.Series;
if (series != null) if (series is not null)
{ {
return series; return series;
} }
@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.Images
if (i is Season season) if (i is Season season)
{ {
var series = season.Series; var series = season.Series;
if (series != null) if (series is not null)
{ {
return series; return series;
} }
@ -74,7 +74,7 @@ namespace Emby.Server.Implementations.Images
if (i is Audio audio) if (i is Audio audio)
{ {
var album = audio.AlbumEntity; var album = audio.AlbumEntity;
if (album != null && album.HasImage(ImageType.Primary)) if (album is not null && album.HasImage(ImageType.Primary))
{ {
return album; return album;
} }

@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Images
if (subItem is Episode episode) if (subItem is Episode episode)
{ {
var series = episode.Series; var series = episode.Series;
if (series != null && series.HasImage(ImageType.Primary)) if (series is not null && series.HasImage(ImageType.Primary))
{ {
return series; return series;
} }
@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Images
var parent = subItem.GetOwner() ?? subItem.GetParent(); var parent = subItem.GetOwner() ?? subItem.GetParent();
if (parent != null && parent.HasImage(ImageType.Primary)) if (parent is not null && parent.HasImage(ImageType.Primary))
{ {
if (parent is MusicAlbum) if (parent is MusicAlbum)
{ {
@ -57,7 +57,7 @@ namespace Emby.Server.Implementations.Images
return null; return null;
}) })
.Where(i => i != null) .Where(i => i is not null)
.GroupBy(x => x.Id) .GroupBy(x => x.Id)
.Select(x => x.First()) .Select(x => x.First())
.ToList(); .ToList();

@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.Library
if (fileInfo.IsDirectory) if (fileInfo.IsDirectory)
{ {
if (parent != null) if (parent is not null)
{ {
// Ignore extras folders but allow it at the collection level // Ignore extras folders but allow it at the collection level
if (_namingOptions.AllExtrasTypesFolderNames.ContainsKey(filename) if (_namingOptions.AllExtrasTypesFolderNames.ContainsKey(filename)
@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.Library
} }
else else
{ {
if (parent != null) if (parent is not null)
{ {
// Don't resolve these into audio files // Don't resolve these into audio files
if (Path.GetFileNameWithoutExtension(filename.AsSpan()).Equals(BaseItem.ThemeSongFileName, StringComparison.Ordinal) if (Path.GetFileNameWithoutExtension(filename.AsSpan()).Equals(BaseItem.ThemeSongFileName, StringComparison.Ordinal)

@ -465,9 +465,9 @@ namespace Emby.Server.Implementations.Library
private BaseItem ResolveItem(ItemResolveArgs args, IItemResolver[] resolvers) private BaseItem ResolveItem(ItemResolveArgs args, IItemResolver[] resolvers)
{ {
var item = (resolvers ?? EntityResolvers).Select(r => Resolve(args, r)) var item = (resolvers ?? EntityResolvers).Select(r => Resolve(args, r))
.FirstOrDefault(i => i != null); .FirstOrDefault(i => i is not null);
if (item != null) if (item is not null)
{ {
ResolverHelper.SetInitialItemValues(item, args, _fileSystem, this); ResolverHelper.SetInitialItemValues(item, args, _fileSystem, this);
} }
@ -536,7 +536,7 @@ namespace Emby.Server.Implementations.Library
var fullPath = fileInfo.FullName; var fullPath = fileInfo.FullName;
if (string.IsNullOrEmpty(collectionType) && parent != null) if (string.IsNullOrEmpty(collectionType) && parent is not null)
{ {
collectionType = GetContentTypeOverride(fullPath, true); collectionType = GetContentTypeOverride(fullPath, true);
} }
@ -572,7 +572,7 @@ namespace Emby.Server.Implementations.Library
} }
catch (Exception ex) catch (Exception ex)
{ {
if (parent != null && parent.IsPhysicalRoot) if (parent is not null && parent.IsPhysicalRoot)
{ {
_logger.LogError(ex, "Error in GetFilteredFileSystemEntries isPhysicalRoot: {0} IsVf: {1}", isPhysicalRoot, isVf); _logger.LogError(ex, "Error in GetFilteredFileSystemEntries isPhysicalRoot: {0} IsVf: {1}", isPhysicalRoot, isVf);
@ -654,7 +654,7 @@ namespace Emby.Server.Implementations.Library
{ {
var fileList = files.Where(i => !IgnoreFile(i, parent)).ToList(); var fileList = files.Where(i => !IgnoreFile(i, parent)).ToList();
if (parent != null) if (parent is not null)
{ {
var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray(); var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray();
@ -697,7 +697,7 @@ namespace Emby.Server.Implementations.Library
_logger.LogError(ex, "Error resolving path {Path}", file.FullName); _logger.LogError(ex, "Error resolving path {Path}", file.FullName);
} }
if (result != null) if (result is not null)
{ {
yield return result; yield return result;
} }
@ -750,7 +750,7 @@ namespace Emby.Server.Implementations.Library
var dbItem = GetItemById(folder.Id) as BasePluginFolder; var dbItem = GetItemById(folder.Id) as BasePluginFolder;
if (dbItem != null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase)) if (dbItem is not null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase))
{ {
folder = dbItem; folder = dbItem;
} }
@ -952,7 +952,7 @@ namespace Emby.Server.Implementations.Library
.Cast<T>() .Cast<T>()
.FirstOrDefault(); .FirstOrDefault();
if (existing != null) if (existing is not null)
{ {
return existing; return existing;
} }
@ -1181,7 +1181,7 @@ namespace Emby.Server.Implementations.Library
return null; return null;
} }
}) })
.Where(i => i != null) .Where(i => i is not null)
.OrderBy(i => i) .OrderBy(i => i)
.ToArray(), .ToArray(),
@ -1190,17 +1190,17 @@ namespace Emby.Server.Implementations.Library
var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase)); var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
if (libraryFolder != null && libraryFolder.HasImage(ImageType.Primary)) if (libraryFolder is not null && libraryFolder.HasImage(ImageType.Primary))
{ {
info.PrimaryImageItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture); info.PrimaryImageItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
} }
if (libraryFolder != null) if (libraryFolder is not null)
{ {
info.ItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture); info.ItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
info.LibraryOptions = GetLibraryOptions(libraryFolder); info.LibraryOptions = GetLibraryOptions(libraryFolder);
if (refreshQueue != null) if (refreshQueue is not null)
{ {
info.RefreshProgress = libraryFolder.GetRefreshProgress(); info.RefreshProgress = libraryFolder.GetRefreshProgress();
@ -1245,7 +1245,7 @@ namespace Emby.Server.Implementations.Library
item = RetrieveItem(id); item = RetrieveItem(id);
if (item != null) if (item is not null)
{ {
RegisterItem(item); RegisterItem(item);
} }
@ -1258,13 +1258,13 @@ namespace Emby.Server.Implementations.Library
if (query.Recursive && !query.ParentId.Equals(default)) if (query.Recursive && !query.ParentId.Equals(default))
{ {
var parent = GetItemById(query.ParentId); var parent = GetItemById(query.ParentId);
if (parent != null) if (parent is not null)
{ {
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent }); SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
} }
} }
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User, allowExternalContent); AddUserToQuery(query, query.User, allowExternalContent);
} }
@ -1282,13 +1282,13 @@ namespace Emby.Server.Implementations.Library
if (query.Recursive && !query.ParentId.Equals(default)) if (query.Recursive && !query.ParentId.Equals(default))
{ {
var parent = GetItemById(query.ParentId); var parent = GetItemById(query.ParentId);
if (parent != null) if (parent is not null)
{ {
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent }); SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
} }
} }
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1302,7 +1302,7 @@ namespace Emby.Server.Implementations.Library
if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0) if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0)
{ {
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1313,7 +1313,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<BaseItem> QueryItems(InternalItemsQuery query) public QueryResult<BaseItem> QueryItems(InternalItemsQuery query)
{ {
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1331,7 +1331,7 @@ namespace Emby.Server.Implementations.Library
public List<Guid> GetItemIds(InternalItemsQuery query) public List<Guid> GetItemIds(InternalItemsQuery query)
{ {
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1341,7 +1341,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery query) public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery query)
{ {
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1352,7 +1352,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery query) public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery query)
{ {
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1363,7 +1363,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery query) public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery query)
{ {
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1374,7 +1374,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery query) public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery query)
{ {
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1385,7 +1385,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery query) public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery query)
{ {
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1426,7 +1426,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery query) public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery query)
{ {
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1440,13 +1440,13 @@ namespace Emby.Server.Implementations.Library
if (query.Recursive && !query.ParentId.Equals(default)) if (query.Recursive && !query.ParentId.Equals(default))
{ {
var parent = GetItemById(query.ParentId); var parent = GetItemById(query.ParentId);
if (parent != null) if (parent is not null)
{ {
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent }); SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
} }
} }
if (query.User != null) if (query.User is not null)
{ {
AddUserToQuery(query, query.User); AddUserToQuery(query, query.User);
} }
@ -1524,7 +1524,7 @@ namespace Emby.Server.Implementations.Library
if (!view.DisplayParentId.Equals(default)) if (!view.DisplayParentId.Equals(default))
{ {
var displayParent = GetItemById(view.DisplayParentId); var displayParent = GetItemById(view.DisplayParentId);
if (displayParent != null) if (displayParent is not null)
{ {
return GetTopParentIdsForQuery(displayParent, user); return GetTopParentIdsForQuery(displayParent, user);
} }
@ -1535,7 +1535,7 @@ namespace Emby.Server.Implementations.Library
if (!view.ParentId.Equals(default)) if (!view.ParentId.Equals(default))
{ {
var displayParent = GetItemById(view.ParentId); var displayParent = GetItemById(view.ParentId);
if (displayParent != null) if (displayParent is not null)
{ {
return GetTopParentIdsForQuery(displayParent, user); return GetTopParentIdsForQuery(displayParent, user);
} }
@ -1544,7 +1544,7 @@ namespace Emby.Server.Implementations.Library
} }
// Handle grouping // Handle grouping
if (user != null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType) if (user is not null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType)
&& user.GetPreference(PreferenceKind.GroupedFolders).Length > 0) && user.GetPreference(PreferenceKind.GroupedFolders).Length > 0)
{ {
return GetUserRootFolder() return GetUserRootFolder()
@ -1564,7 +1564,7 @@ namespace Emby.Server.Implementations.Library
} }
var topParent = item.GetTopParent(); var topParent = item.GetTopParent();
if (topParent != null) if (topParent is not null)
{ {
return new[] { topParent.Id }; return new[] { topParent.Id };
} }
@ -1589,7 +1589,7 @@ namespace Emby.Server.Implementations.Library
return items return items
.SelectMany(i => i.ToArray()) .SelectMany(i => i.ToArray())
.Select(ResolveIntro) .Select(ResolveIntro)
.Where(i => i != null); .Where(i => i is not null);
} }
/// <summary> /// <summary>
@ -1648,7 +1648,7 @@ namespace Emby.Server.Implementations.Library
// Pull the saved db item that will include metadata // Pull the saved db item that will include metadata
var dbItem = GetItemById(video.Id) as Video; var dbItem = GetItemById(video.Id) as Video;
if (dbItem != null) if (dbItem is not null)
{ {
video = dbItem; video = dbItem;
} }
@ -1685,7 +1685,7 @@ namespace Emby.Server.Implementations.Library
IOrderedEnumerable<BaseItem> orderedItems = null; IOrderedEnumerable<BaseItem> orderedItems = null;
foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c != null)) foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c is not null))
{ {
if (isFirst) if (isFirst)
{ {
@ -1781,7 +1781,7 @@ namespace Emby.Server.Implementations.Library
RegisterItem(item); RegisterItem(item);
} }
if (ItemAdded != null) if (ItemAdded is not null)
{ {
foreach (var item in items) foreach (var item in items)
{ {
@ -1811,7 +1811,7 @@ namespace Emby.Server.Implementations.Library
private bool ImageNeedsRefresh(ItemImageInfo image) private bool ImageNeedsRefresh(ItemImageInfo image)
{ {
if (image.Path != null && image.IsLocalFile) if (image.Path is not null && image.IsLocalFile)
{ {
if (image.Width == 0 || image.Height == 0 || string.IsNullOrEmpty(image.BlurHash)) if (image.Width == 0 || image.Height == 0 || string.IsNullOrEmpty(image.BlurHash))
{ {
@ -1829,7 +1829,7 @@ namespace Emby.Server.Implementations.Library
} }
} }
return image.Path != null && !image.IsLocalFile; return image.Path is not null && !image.IsLocalFile;
} }
/// <inheritdoc /> /// <inheritdoc />
@ -1838,7 +1838,7 @@ namespace Emby.Server.Implementations.Library
ArgumentNullException.ThrowIfNull(item); ArgumentNullException.ThrowIfNull(item);
var outdated = forceUpdate var outdated = forceUpdate
? item.ImageInfos.Where(i => i.Path != null).ToArray() ? item.ImageInfos.Where(i => i.Path is not null).ToArray()
: item.ImageInfos.Where(ImageNeedsRefresh).ToArray(); : item.ImageInfos.Where(ImageNeedsRefresh).ToArray();
// Skip image processing if current or live tv source // Skip image processing if current or live tv source
if (outdated.Length == 0 || item.SourceType != SourceType.Library) if (outdated.Length == 0 || item.SourceType != SourceType.Library)
@ -1923,7 +1923,7 @@ namespace Emby.Server.Implementations.Library
_itemRepository.SaveItems(items, cancellationToken); _itemRepository.SaveItems(items, cancellationToken);
if (ItemUpdated != null) if (ItemUpdated is not null)
{ {
foreach (var item in items) foreach (var item in items)
{ {
@ -1975,7 +1975,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="parent">The parent item.</param> /// <param name="parent">The parent item.</param>
public void ReportItemRemoved(BaseItem item, BaseItem parent) public void ReportItemRemoved(BaseItem item, BaseItem parent)
{ {
if (ItemRemoved != null) if (ItemRemoved is not null)
{ {
try try
{ {
@ -2006,7 +2006,7 @@ namespace Emby.Server.Implementations.Library
public List<Folder> GetCollectionFolders(BaseItem item) public List<Folder> GetCollectionFolders(BaseItem item)
{ {
while (item != null) while (item is not null)
{ {
var parent = item.GetParent(); var parent = item.GetParent();
@ -2028,7 +2028,7 @@ namespace Emby.Server.Implementations.Library
public List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren) public List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren)
{ {
while (item != null) while (item is not null)
{ {
var parent = item.GetParent(); var parent = item.GetParent();
@ -2251,7 +2251,7 @@ namespace Emby.Server.Implementations.Library
if (!refresh && !item.DisplayParentId.Equals(default)) if (!refresh && !item.DisplayParentId.Equals(default))
{ {
var displayParent = GetItemById(item.DisplayParentId); var displayParent = GetItemById(item.DisplayParentId);
refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed; refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
} }
if (refresh) if (refresh)
@ -2315,7 +2315,7 @@ namespace Emby.Server.Implementations.Library
if (!refresh && !item.DisplayParentId.Equals(default)) if (!refresh && !item.DisplayParentId.Equals(default))
{ {
var displayParent = GetItemById(item.DisplayParentId); var displayParent = GetItemById(item.DisplayParentId);
refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed; refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
} }
if (refresh) if (refresh)
@ -2394,7 +2394,7 @@ namespace Emby.Server.Implementations.Library
if (!refresh && !item.DisplayParentId.Equals(default)) if (!refresh && !item.DisplayParentId.Equals(default))
{ {
var displayParent = GetItemById(item.DisplayParentId); var displayParent = GetItemById(item.DisplayParentId);
refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed; refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
} }
if (refresh) if (refresh)
@ -2441,7 +2441,7 @@ namespace Emby.Server.Implementations.Library
public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh) public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh)
{ {
var series = episode.Series; var series = episode.Series;
bool? isAbsoluteNaming = series != null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase); bool? isAbsoluteNaming = series is not null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase);
if (!isAbsoluteNaming.Value) if (!isAbsoluteNaming.Value)
{ {
// In other words, no filter applied // In other words, no filter applied
@ -2462,7 +2462,7 @@ namespace Emby.Server.Implementations.Library
if (episodeInfo is null && parent.GetType() == typeof(Folder)) if (episodeInfo is null && parent.GetType() == typeof(Folder))
{ {
episodeInfo = resolver.Resolve(parent.Path, true, null, null, isAbsoluteNaming); episodeInfo = resolver.Resolve(parent.Path, true, null, null, isAbsoluteNaming);
if (episodeInfo != null) if (episodeInfo is not null)
{ {
// add the container // add the container
episodeInfo.Container = Path.GetExtension(episode.Path)?.TrimStart('.'); episodeInfo.Container = Path.GetExtension(episode.Path)?.TrimStart('.');
@ -2582,7 +2582,7 @@ namespace Emby.Server.Implementations.Library
{ {
var season = episode.Season; var season = episode.Season;
if (season != null) if (season is not null)
{ {
episode.ParentIndexNumber = season.IndexNumber; episode.ParentIndexNumber = season.IndexNumber;
} }
@ -2640,7 +2640,7 @@ namespace Emby.Server.Implementations.Library
} }
var extra = GetExtra(file, extraType.Value); var extra = GetExtra(file, extraType.Value);
if (extra != null) if (extra is not null)
{ {
yield return extra; yield return extra;
} }
@ -2649,7 +2649,7 @@ namespace Emby.Server.Implementations.Library
else if (!current.IsDirectory && _extraResolver.TryGetExtraTypeForOwner(current.FullName, ownerVideoInfo, out var extraType)) else if (!current.IsDirectory && _extraResolver.TryGetExtraTypeForOwner(current.FullName, ownerVideoInfo, out var extraType))
{ {
var extra = GetExtra(current, extraType.Value); var extra = GetExtra(current, extraType.Value);
if (extra != null) if (extra is not null)
{ {
yield return extra; yield return extra;
} }
@ -2666,7 +2666,7 @@ namespace Emby.Server.Implementations.Library
// Try to retrieve it from the db. If we don't find it, use the resolved version // Try to retrieve it from the db. If we don't find it, use the resolved version
var itemById = GetItemById(extra.Id); var itemById = GetItemById(extra.Id);
if (itemById != null) if (itemById is not null)
{ {
extra = itemById; extra = itemById;
} }
@ -2681,10 +2681,10 @@ namespace Emby.Server.Implementations.Library
public string GetPathAfterNetworkSubstitution(string path, BaseItem ownerItem) public string GetPathAfterNetworkSubstitution(string path, BaseItem ownerItem)
{ {
string newPath; string newPath;
if (ownerItem != null) if (ownerItem is not null)
{ {
var libraryOptions = GetLibraryOptions(ownerItem); var libraryOptions = GetLibraryOptions(ownerItem);
if (libraryOptions != null) if (libraryOptions is not null)
{ {
foreach (var pathInfo in libraryOptions.PathInfos) foreach (var pathInfo in libraryOptions.PathInfos)
{ {
@ -2753,7 +2753,7 @@ namespace Emby.Server.Implementations.Library
return null; return null;
} }
}) })
.Where(i => i != null) .Where(i => i is not null)
.Where(i => query.User is null ? .Where(i => query.User is null ?
true : true :
i.IsVisible(query.User)) i.IsVisible(query.User))
@ -2838,10 +2838,10 @@ namespace Emby.Server.Implementations.Library
} }
var mediaPathInfos = options.PathInfos; var mediaPathInfos = options.PathInfos;
if (mediaPathInfos != null) if (mediaPathInfos is not null)
{ {
var invalidpath = mediaPathInfos.FirstOrDefault(i => !Directory.Exists(i.Path)); var invalidpath = mediaPathInfos.FirstOrDefault(i => !Directory.Exists(i.Path));
if (invalidpath != null) if (invalidpath is not null)
{ {
throw new ArgumentException("The specified path does not exist: " + invalidpath.Path + "."); throw new ArgumentException("The specified path does not exist: " + invalidpath.Path + ".");
} }
@ -2853,7 +2853,7 @@ namespace Emby.Server.Implementations.Library
{ {
Directory.CreateDirectory(virtualFolderPath); Directory.CreateDirectory(virtualFolderPath);
if (collectionType != null) if (collectionType is not null)
{ {
var path = Path.Combine(virtualFolderPath, collectionType.ToString().ToLowerInvariant() + ".collection"); var path = Path.Combine(virtualFolderPath, collectionType.ToString().ToLowerInvariant() + ".collection");
@ -2862,7 +2862,7 @@ namespace Emby.Server.Implementations.Library
CollectionFolder.SaveLibraryOptions(virtualFolderPath, options); CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
if (mediaPathInfos != null) if (mediaPathInfos is not null)
{ {
foreach (var path in mediaPathInfos) foreach (var path in mediaPathInfos)
{ {

@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Library
}, },
cancellationToken).ConfigureAwait(false); cancellationToken).ConfigureAwait(false);
if (cacheFilePath != null) if (cacheFilePath is not null)
{ {
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
await using FileStream createStream = AsyncFile.OpenWrite(cacheFilePath); await using FileStream createStream = AsyncFile.OpenWrite(cacheFilePath);
@ -140,7 +140,7 @@ namespace Emby.Server.Implementations.Library
} }
var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
if (videoStream != null) if (videoStream is not null)
{ {
if (!videoStream.BitRate.HasValue) if (!videoStream.BitRate.HasValue)
{ {

@ -182,7 +182,7 @@ namespace Emby.Server.Implementations.Library
source.SupportsDirectStream = SupportsDirectStream(source.Path, source.Protocol); source.SupportsDirectStream = SupportsDirectStream(source.Path, source.Protocol);
} }
if (user != null) if (user is not null)
{ {
SetDefaultAudioAndSubtitleStreamIndexes(item, source, user); SetDefaultAudioAndSubtitleStreamIndexes(item, source, user);
@ -248,7 +248,7 @@ namespace Emby.Server.Implementations.Library
if (protocol == MediaProtocol.Http) if (protocol == MediaProtocol.Http)
{ {
if (path != null) if (path is not null)
{ {
if (path.Contains(".m3u", StringComparison.OrdinalIgnoreCase)) if (path.Contains(".m3u", StringComparison.OrdinalIgnoreCase))
{ {
@ -328,7 +328,7 @@ namespace Emby.Server.Implementations.Library
var sources = hasMediaSources.GetMediaSources(enablePathSubstitution); var sources = hasMediaSources.GetMediaSources(enablePathSubstitution);
if (user != null) if (user is not null)
{ {
foreach (var source in sources) foreach (var source in sources)
{ {
@ -357,7 +357,7 @@ namespace Emby.Server.Implementations.Library
} }
var culture = _localizationManager.FindLanguageInfo(language); var culture = _localizationManager.FindLanguageInfo(language);
if (culture != null) if (culture is not null)
{ {
return culture.ThreeLetterISOLanguageNames; return culture.ThreeLetterISOLanguageNames;
} }
@ -432,7 +432,7 @@ namespace Emby.Server.Implementations.Library
{ {
var audio = source.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); var audio = source.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
if (audio != null) if (audio is not null)
{ {
source.DefaultAudioStreamIndex = audio.Index; source.DefaultAudioStreamIndex = audio.Index;
} }
@ -553,7 +553,7 @@ namespace Emby.Server.Implementations.Library
} }
var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
if (videoStream != null) if (videoStream is not null)
{ {
if (!videoStream.BitRate.HasValue) if (!videoStream.BitRate.HasValue)
{ {
@ -661,7 +661,7 @@ namespace Emby.Server.Implementations.Library
}, },
cancellationToken).ConfigureAwait(false); cancellationToken).ConfigureAwait(false);
if (cacheFilePath != null) if (cacheFilePath is not null)
{ {
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
await using FileStream createStream = File.Create(cacheFilePath); await using FileStream createStream = File.Create(cacheFilePath);
@ -723,7 +723,7 @@ namespace Emby.Server.Implementations.Library
} }
var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video); var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
if (videoStream != null) if (videoStream is not null)
{ {
if (!videoStream.BitRate.HasValue) if (!videoStream.BitRate.HasValue)
{ {

@ -19,7 +19,7 @@ namespace Emby.Server.Implementations.Library
{ {
var defaultStream = sortedStreams.FirstOrDefault(i => i.IsDefault); var defaultStream = sortedStreams.FirstOrDefault(i => i.IsDefault);
if (defaultStream != null) if (defaultStream is not null)
{ {
return defaultStream.Index; return defaultStream.Index;
} }

@ -31,7 +31,7 @@ namespace Emby.Server.Implementations.Library
} }
// If the resolver didn't specify this // If the resolver didn't specify this
if (parent != null) if (parent is not null)
{ {
item.SetParent(parent); item.SetParent(parent);
} }
@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.Library
} }
// If the resolver didn't specify this // If the resolver didn't specify this
if (args.Parent != null) if (args.Parent is not null)
{ {
item.SetParent(args.Parent); item.SetParent(args.Parent);
} }
@ -113,7 +113,7 @@ namespace Emby.Server.Implementations.Library
{ {
var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null; var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null;
if (childData != null) if (childData is not null)
{ {
SetDateCreated(item, childData); SetDateCreated(item, childData);
} }
@ -140,7 +140,7 @@ namespace Emby.Server.Implementations.Library
if (config.UseFileCreationTimeForDateAdded) if (config.UseFileCreationTimeForDateAdded)
{ {
// directoryService.getFile may return null // directoryService.getFile may return null
if (info != null) if (info is not null)
{ {
var dateCreated = info.CreationTimeUtc; var dateCreated = info.CreationTimeUtc;

@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
{ {
var result = ResolveMultipleInternal(parent, files, collectionType); var result = ResolveMultipleInternal(parent, files, collectionType);
if (result != null) if (result is not null)
{ {
foreach (var item in result.Items) foreach (var item in result.Items)
{ {
@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
item = new AudioBook(); item = new AudioBook();
} }
if (item != null) if (item is not null)
{ {
item.IsShortcut = string.Equals(extension, ".strm", StringComparison.OrdinalIgnoreCase); item.IsShortcut = string.Equals(extension, ".strm", StringComparison.OrdinalIgnoreCase);
@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
Items = items Items = items
}; };
var isInMixedFolder = resolverResult.Count > 1 || (parent != null && parent.IsTopParent); var isInMixedFolder = resolverResult.Count > 1 || (parent is not null && parent.IsTopParent);
foreach (var resolvedItem in resolverResult) foreach (var resolvedItem in resolverResult)
{ {

@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
var extension = Path.GetExtension(args.Path); var extension = Path.GetExtension(args.Path);
if (extension != null && _validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase)) if (extension is not null && _validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
{ {
// It's a book // It's a book
return new Book return new Book

@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
{ {
var result = ResolveMultipleInternal(parent, files, collectionType); var result = ResolveMultipleInternal(parent, files, collectionType);
if (result != null) if (result is not null)
{ {
foreach (var item in result.Items) foreach (var item in result.Items)
{ {
@ -168,12 +168,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
} }
// Ignore extras // Ignore extras
if (item?.ExtraType != null) if (item?.ExtraType is not null)
{ {
return null; return null;
} }
if (item != null) if (item is not null)
{ {
item.IsInMixedFolder = true; item.IsInMixedFolder = true;
} }
@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
var videoInfos = files var videoInfos = files
.Select(i => VideoResolver.Resolve(i.FullName, i.IsDirectory, NamingOptions, parseName)) .Select(i => VideoResolver.Resolve(i.FullName, i.IsDirectory, NamingOptions, parseName))
.Where(f => f != null) .Where(f => f is not null)
.ToList(); .ToList();
var resolverResult = VideoListResolver.Resolve(videoInfos, NamingOptions, supportMultiEditions, parseName); var resolverResult = VideoListResolver.Resolve(videoInfos, NamingOptions, supportMultiEditions, parseName);
@ -284,7 +284,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
{ {
var firstVideo = video.Files[0]; var firstVideo = video.Files[0];
var path = firstVideo.Path; var path = firstVideo.Path;
if (video.ExtraType != null) if (video.ExtraType is not null)
{ {
result.ExtraFiles.Add(files.Find(f => string.Equals(f.FullName, path, StringComparison.OrdinalIgnoreCase))); result.ExtraFiles.Add(files.Find(f => string.Equals(f.FullName, path, StringComparison.OrdinalIgnoreCase)));
continue; continue;
@ -568,7 +568,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
private bool IsInvalid(Folder parent, ReadOnlySpan<char> collectionType) private bool IsInvalid(Folder parent, ReadOnlySpan<char> collectionType)
{ {
if (parent != null) if (parent is not null)
{ {
if (parent.IsRoot) if (parent.IsRoot)
{ {

@ -46,27 +46,27 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
// If the parent is a Season or Series and the parent is not an extras folder, then this is an Episode if the VideoResolver returns something // If the parent is a Season or Series and the parent is not an extras folder, then this is an Episode if the VideoResolver returns something
// Also handle flat tv folders // Also handle flat tv folders
if (season != null || if (season is not null ||
string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) ||
args.HasParent<Series>()) args.HasParent<Series>())
{ {
var episode = ResolveVideo<Episode>(args, false); var episode = ResolveVideo<Episode>(args, false);
// Ignore extras // Ignore extras
if (episode is null || episode.ExtraType != null) if (episode is null || episode.ExtraType is not null)
{ {
return null; return null;
} }
var series = parent as Series ?? parent.GetParents().OfType<Series>().FirstOrDefault(); var series = parent as Series ?? parent.GetParents().OfType<Series>().FirstOrDefault();
if (series != null) if (series is not null)
{ {
episode.SeriesId = series.Id; episode.SeriesId = series.Id;
episode.SeriesName = series.Name; episode.SeriesName = series.Name;
} }
if (season != null) if (season is not null)
{ {
episode.SeasonId = season.Id; episode.SeasonId = season.Id;
episode.SeasonName = season.Name; episode.SeasonName = season.Name;

@ -66,7 +66,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var episodeInfo = resolver.Resolve(testPath, true); var episodeInfo = resolver.Resolve(testPath, true);
if (episodeInfo?.EpisodeNumber != null && episodeInfo.SeasonNumber.HasValue) if (episodeInfo?.EpisodeNumber is not null && episodeInfo.SeasonNumber.HasValue)
{ {
_logger.LogDebug( _logger.LogDebug(
"Found folder underneath series with episode number: {0}. Season {1}. Episode {2}", "Found folder underneath series with episode number: {0}. Season {1}. Episode {2}",

@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
{ {
if (args.ContainsFileSystemEntryByName("tvshow.nfo")) if (args.ContainsFileSystemEntryByName("tvshow.nfo"))
{ {
if (args.Parent != null && args.Parent.IsRoot) if (args.Parent is not null && args.Parent.IsRoot)
{ {
// For now, return null, but if we want to allow this in the future then add some additional checks to guard against a misplaced tvshow.nfo // For now, return null, but if we want to allow this in the future then add some additional checks to guard against a misplaced tvshow.nfo
return null; return null;
@ -89,7 +89,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
}; };
} }
if (args.Parent != null && args.Parent.IsRoot) if (args.Parent is not null && args.Parent.IsRoot)
{ {
return null; return null;
} }
@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions); var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions);
var episodeInfo = episodeResolver.Resolve(fullName, false, true, false, fillExtendedInfo: false); var episodeInfo = episodeResolver.Resolve(fullName, false, true, false, fillExtendedInfo: false);
if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue) if (episodeInfo is not null && episodeInfo.EpisodeNumber.HasValue)
{ {
return true; return true;
} }

@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Library
{ {
var userData = _repository.GetUserData(internalUserId, keys); var userData = _repository.GetUserData(internalUserId, keys);
if (userData != null) if (userData is not null)
{ {
return userData; return userData;
} }

@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.Library
continue; continue;
} }
if (collectionFolder != null && UserView.IsEligibleForGrouping(folder) && user.IsFolderGrouped(folder.Id)) if (collectionFolder is not null && UserView.IsEligibleForGrouping(folder) && user.IsFolderGrouped(folder.Id))
{ {
groupedFolders.Add(collectionFolder); groupedFolders.Add(collectionFolder);
continue; continue;
@ -214,9 +214,9 @@ namespace Emby.Server.Implementations.Library
} }
else else
{ {
var current = list.FirstOrDefault(i => i.Item1 != null && i.Item1.Id.Equals(container.Id)); var current = list.FirstOrDefault(i => i.Item1 is not null && i.Item1.Id.Equals(container.Id));
if (current != null) if (current is not null)
{ {
current.Item2.Add(item); current.Item2.Add(item);
} }

@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public Task Record(IDirectStreamProvider? directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken) public Task Record(IDirectStreamProvider? directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
{ {
if (directStreamProvider != null) if (directStreamProvider is not null)
{ {
return RecordFromDirectStreamProvider(directStreamProvider, targetFile, duration, onStarted, cancellationToken); return RecordFromDirectStreamProvider(directStreamProvider, targetFile, duration, onStarted, cancellationToken);
} }

@ -367,7 +367,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
var epgChannel = GetEpgChannelFromTunerChannel(info, tunerChannel, epgChannels); var epgChannel = GetEpgChannelFromTunerChannel(info, tunerChannel, epgChannels);
if (epgChannel != null) if (epgChannel is not null)
{ {
if (!string.IsNullOrWhiteSpace(epgChannel.Name)) if (!string.IsNullOrWhiteSpace(epgChannel.Name))
{ {
@ -450,7 +450,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelById(mappedTunerChannelId); var channel = epgChannelData.GetChannelById(mappedTunerChannelId);
if (channel != null) if (channel is not null)
{ {
return channel; return channel;
} }
@ -473,7 +473,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelById(mappedTunerChannelId); var channel = epgChannelData.GetChannelById(mappedTunerChannelId);
if (channel != null) if (channel is not null)
{ {
return channel; return channel;
} }
@ -490,7 +490,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelByNumber(tunerChannelNumber); var channel = epgChannelData.GetChannelByNumber(tunerChannelNumber);
if (channel != null) if (channel is not null)
{ {
return channel; return channel;
} }
@ -502,7 +502,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelByName(normalizedName); var channel = epgChannelData.GetChannelByName(normalizedName);
if (channel != null) if (channel is not null)
{ {
return channel; return channel;
} }
@ -552,7 +552,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
} }
var remove = _seriesTimerProvider.GetAll().FirstOrDefault(r => string.Equals(r.Id, timerId, StringComparison.OrdinalIgnoreCase)); var remove = _seriesTimerProvider.GetAll().FirstOrDefault(r => string.Equals(r.Id, timerId, StringComparison.OrdinalIgnoreCase));
if (remove != null) if (remove is not null)
{ {
_seriesTimerProvider.Delete(remove); _seriesTimerProvider.Delete(remove);
} }
@ -563,7 +563,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private void CancelTimerInternal(string timerId, bool isSeriesCancelled, bool isManualCancellation) private void CancelTimerInternal(string timerId, bool isSeriesCancelled, bool isManualCancellation)
{ {
var timer = _timerProvider.GetTimer(timerId); var timer = _timerProvider.GetTimer(timerId);
if (timer != null) if (timer is not null)
{ {
var statusChanging = timer.Status != RecordingStatus.Cancelled; var statusChanging = timer.Status != RecordingStatus.Cancelled;
timer.Status = RecordingStatus.Cancelled; timer.Status = RecordingStatus.Cancelled;
@ -582,7 +582,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_timerProvider.AddOrUpdate(timer, false); _timerProvider.AddOrUpdate(timer, false);
} }
if (statusChanging && TimerCancelled != null) if (statusChanging && TimerCancelled is not null)
{ {
TimerCancelled(this, new GenericEventArgs<string>(timerId)); TimerCancelled(this, new GenericEventArgs<string>(timerId));
} }
@ -617,7 +617,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
null : null :
_timerProvider.GetTimerByProgramId(info.ProgramId); _timerProvider.GetTimerByProgramId(info.ProgramId);
if (existingTimer != null) if (existingTimer is not null)
{ {
if (existingTimer.Status == RecordingStatus.Cancelled if (existingTimer.Status == RecordingStatus.Cancelled
|| existingTimer.Status == RecordingStatus.Completed) || existingTimer.Status == RecordingStatus.Completed)
@ -648,7 +648,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
programInfo = GetProgramInfoFromCache(info.ChannelId, info.StartDate); programInfo = GetProgramInfoFromCache(info.ChannelId, info.StartDate);
} }
if (programInfo != null) if (programInfo is not null)
{ {
CopyProgramInfoToTimerInfo(programInfo, info); CopyProgramInfoToTimerInfo(programInfo, info);
} }
@ -668,7 +668,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
// populate info.seriesID // populate info.seriesID
var program = GetProgramInfoFromCache(info.ProgramId); var program = GetProgramInfoFromCache(info.ProgramId);
if (program != null) if (program is not null)
{ {
info.SeriesId = program.ExternalSeriesId; info.SeriesId = program.ExternalSeriesId;
} }
@ -714,7 +714,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
var instance = _seriesTimerProvider.GetAll().FirstOrDefault(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase)); var instance = _seriesTimerProvider.GetAll().FirstOrDefault(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase));
if (instance != null) if (instance is not null)
{ {
instance.ChannelId = info.ChannelId; instance.ChannelId = info.ChannelId;
instance.Days = info.Days; instance.Days = info.Days;
@ -861,7 +861,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
} }
}; };
if (program != null) if (program is not null)
{ {
defaults.SeriesId = program.SeriesId; defaults.SeriesId = program.SeriesId;
defaults.ProgramId = program.Id; defaults.ProgramId = program.Id;
@ -947,7 +947,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return provider is null ? null : new Tuple<IListingsProvider, ListingsProviderInfo>(provider, i); return provider is null ? null : new Tuple<IListingsProvider, ListingsProviderInfo>(provider, i);
}) })
.Where(i => i != null) .Where(i => i is not null)
.ToList(); .ToList();
} }
@ -964,7 +964,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
null : null :
currentLiveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase)); currentLiveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase));
if (result != null && result.EnableStreamSharing) if (result is not null && result.EnableStreamSharing)
{ {
result.ConsumerCount++; result.ConsumerCount++;
@ -1134,7 +1134,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
// trim trailing period from the folder name // trim trailing period from the folder name
var folderName = _fileSystem.GetValidFilename(timer.Name).Trim().TrimEnd('.').Trim(); var folderName = _fileSystem.GetValidFilename(timer.Name).Trim().TrimEnd('.').Trim();
if (metadata != null && metadata.ProductionYear.HasValue) if (metadata is not null && metadata.ProductionYear.HasValue)
{ {
folderName += " (" + metadata.ProductionYear.Value.ToString(CultureInfo.InvariantCulture) + ")"; folderName += " (" + metadata.ProductionYear.Value.ToString(CultureInfo.InvariantCulture) + ")";
} }
@ -1238,7 +1238,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
programInfo = GetProgramInfoFromCache(timer.ChannelId, timer.StartDate); programInfo = GetProgramInfoFromCache(timer.ChannelId, timer.StartDate);
} }
if (programInfo != null) if (programInfo is not null)
{ {
CopyProgramInfoToTimerInfo(programInfo, timer); CopyProgramInfoToTimerInfo(programInfo, timer);
} }
@ -1412,7 +1412,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var item = GetAffectedBaseItem(Path.GetDirectoryName(path)); var item = GetAffectedBaseItem(Path.GetDirectoryName(path));
if (item != null) if (item is not null)
{ {
_logger.LogInformation("Refreshing recording parent {Path}", item.Path); _logger.LogInformation("Refreshing recording parent {Path}", item.Path);
@ -1444,12 +1444,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
path = Path.GetDirectoryName(path); path = Path.GetDirectoryName(path);
} }
if (item != null) if (item is not null)
{ {
if (item.GetType() == typeof(Folder) && string.Equals(item.Path, parentPath, StringComparison.OrdinalIgnoreCase)) if (item.GetType() == typeof(Folder) && string.Equals(item.Path, parentPath, StringComparison.OrdinalIgnoreCase))
{ {
var parentItem = item.GetParent(); var parentItem = item.GetParent();
if (parentItem != null && parentItem is not AggregateFolder) if (parentItem is not null && parentItem is not AggregateFolder)
{ {
item = parentItem; item = parentItem;
} }
@ -1569,7 +1569,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
var libraryItem = _libraryManager.FindByPath(timer.RecordingPath, false); var libraryItem = _libraryManager.FindByPath(timer.RecordingPath, false);
if (libraryItem != null) if (libraryItem is not null)
{ {
_libraryManager.DeleteItem( _libraryManager.DeleteItem(
libraryItem, libraryItem,
@ -1714,7 +1714,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
(program.GetImageInfo(ImageType.Thumb, 0) ?? program.GetImageInfo(ImageType.Primary, 0)) : (program.GetImageInfo(ImageType.Thumb, 0) ?? program.GetImageInfo(ImageType.Primary, 0)) :
(program.GetImageInfo(ImageType.Primary, 0) ?? program.GetImageInfo(ImageType.Thumb, 0)); (program.GetImageInfo(ImageType.Primary, 0) ?? program.GetImageInfo(ImageType.Thumb, 0));
if (image != null) if (image is not null)
{ {
try try
{ {
@ -1729,7 +1729,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (!program.IsSeries) if (!program.IsSeries)
{ {
image = program.GetImageInfo(ImageType.Backdrop, 0); image = program.GetImageInfo(ImageType.Backdrop, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -1742,7 +1742,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
} }
image = program.GetImageInfo(ImageType.Thumb, 0); image = program.GetImageInfo(ImageType.Thumb, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -1755,7 +1755,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
} }
image = program.GetImageInfo(ImageType.Logo, 0); image = program.GetImageInfo(ImageType.Logo, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -2367,13 +2367,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
DtoOptions = new DtoOptions() DtoOptions = new DtoOptions()
}).FirstOrDefault() as LiveTvChannel; }).FirstOrDefault() as LiveTvChannel;
if (channel != null && !string.IsNullOrWhiteSpace(channel.ExternalId)) if (channel is not null && !string.IsNullOrWhiteSpace(channel.ExternalId))
{ {
tempChannelCache[parent.ChannelId] = channel; tempChannelCache[parent.ChannelId] = channel;
} }
} }
if (channel != null || tempChannelCache.TryGetValue(parent.ChannelId, out channel)) if (channel is not null || tempChannelCache.TryGetValue(parent.ChannelId, out channel))
{ {
channelId = channel.ExternalId; channelId = channel.ExternalId;
} }
@ -2426,13 +2426,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
DtoOptions = new DtoOptions() DtoOptions = new DtoOptions()
}).FirstOrDefault() as LiveTvChannel; }).FirstOrDefault() as LiveTvChannel;
if (channel != null && !string.IsNullOrWhiteSpace(channel.ExternalId)) if (channel is not null && !string.IsNullOrWhiteSpace(channel.ExternalId))
{ {
tempChannelCache[programInfo.ChannelId] = channel; tempChannelCache[programInfo.ChannelId] = channel;
} }
} }
if (channel != null || tempChannelCache.TryGetValue(programInfo.ChannelId, out channel)) if (channel is not null || tempChannelCache.TryGetValue(programInfo.ChannelId, out channel))
{ {
channelId = channel.ExternalId; channelId = channel.ExternalId;
} }
@ -2626,7 +2626,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
var configuredDevice = configuredDevices.FirstOrDefault(i => string.Equals(i.DeviceId, device.DeviceId, StringComparison.OrdinalIgnoreCase)); var configuredDevice = configuredDevices.FirstOrDefault(i => string.Equals(i.DeviceId, device.DeviceId, StringComparison.OrdinalIgnoreCase));
if (configuredDevice != null && !string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase)) if (configuredDevice is not null && !string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase))
{ {
_logger.LogInformation("Tuner url has changed from {PreviousUrl} to {NewUrl}", configuredDevice.Url, device.Url); _logger.LogInformation("Tuner url has changed from {PreviousUrl} to {NewUrl}", configuredDevice.Url, device.Url);

@ -208,7 +208,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
// var audioChannels = 2; // var audioChannels = 2;
// var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); // var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
// if (audioStream != null) // if (audioStream is not null)
// { // {
// audioChannels = audioStream.Channels ?? audioChannels; // audioChannels = audioStream.Channels ?? audioChannels;
// } // }

@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
[MemberNotNull(nameof(_items))] [MemberNotNull(nameof(_items))]
private void EnsureLoaded() private void EnsureLoaded()
{ {
if (_items != null) if (_items is not null)
{ {
return; return;
} }

@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
} }
} }
} }
else if (info.IsMovie && info.ProductionYear != null) else if (info.IsMovie && info.ProductionYear is not null)
{ {
name += " (" + info.ProductionYear + ")"; name += " (" + info.ProductionYear + ")";
} }

@ -165,7 +165,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var timerId = (string?)state ?? throw new ArgumentNullException(nameof(state)); var timerId = (string?)state ?? throw new ArgumentNullException(nameof(state));
var timer = GetAll().FirstOrDefault(i => string.Equals(i.Id, timerId, StringComparison.OrdinalIgnoreCase)); var timer = GetAll().FirstOrDefault(i => string.Equals(i.Id, timerId, StringComparison.OrdinalIgnoreCase));
if (timer != null) if (timer is not null)
{ {
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo>(timer)); TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo>(timer));
} }

@ -153,7 +153,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
continue; continue;
} }
if (images != null) if (images is not null)
{ {
var imageIndex = images.FindIndex(i => i.ProgramId == schedule.ProgramId[..10]); var imageIndex = images.FindIndex(i => i.ProgramId == schedule.ProgramId[..10]);
if (imageIndex > -1) if (imageIndex > -1)
@ -266,7 +266,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
} }
string episodeTitle = null; string episodeTitle = null;
if (details.EpisodeTitle150 != null) if (details.EpisodeTitle150 is not null)
{ {
episodeTitle = details.EpisodeTitle150; episodeTitle = details.EpisodeTitle150;
} }
@ -315,13 +315,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
info.ShowId = showId; info.ShowId = showId;
if (programInfo.VideoProperties != null) if (programInfo.VideoProperties is not null)
{ {
info.IsHD = programInfo.VideoProperties.Contains("hdtv", StringComparison.OrdinalIgnoreCase); info.IsHD = programInfo.VideoProperties.Contains("hdtv", StringComparison.OrdinalIgnoreCase);
info.Is3D = programInfo.VideoProperties.Contains("3d", StringComparison.OrdinalIgnoreCase); info.Is3D = programInfo.VideoProperties.Contains("3d", StringComparison.OrdinalIgnoreCase);
} }
if (details.ContentRating != null && details.ContentRating.Count > 0) if (details.ContentRating is not null && details.ContentRating.Count > 0)
{ {
info.OfficialRating = details.ContentRating[0].Code.Replace("TV", "TV-", StringComparison.Ordinal) info.OfficialRating = details.ContentRating[0].Code.Replace("TV", "TV-", StringComparison.Ordinal)
.Replace("--", "-", StringComparison.Ordinal); .Replace("--", "-", StringComparison.Ordinal);
@ -333,13 +333,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
} }
} }
if (details.Descriptions != null) if (details.Descriptions is not null)
{ {
if (details.Descriptions.Description1000 != null && details.Descriptions.Description1000.Count > 0) if (details.Descriptions.Description1000 is not null && details.Descriptions.Description1000.Count > 0)
{ {
info.Overview = details.Descriptions.Description1000[0].Description; info.Overview = details.Descriptions.Description1000[0].Description;
} }
else if (details.Descriptions.Description100 != null && details.Descriptions.Description100.Count > 0) else if (details.Descriptions.Description100 is not null && details.Descriptions.Description100.Count > 0)
{ {
info.Overview = details.Descriptions.Description100[0].Description; info.Overview = details.Descriptions.Description100[0].Description;
} }
@ -351,12 +351,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings
info.SeriesProviderIds[MetadataProvider.Zap2It.ToString()] = info.SeriesId; info.SeriesProviderIds[MetadataProvider.Zap2It.ToString()] = info.SeriesId;
if (details.Metadata != null) if (details.Metadata is not null)
{ {
foreach (var metadataProgram in details.Metadata) foreach (var metadataProgram in details.Metadata)
{ {
var gracenote = metadataProgram.Gracenote; var gracenote = metadataProgram.Gracenote;
if (gracenote != null) if (gracenote is not null)
{ {
info.SeasonNumber = gracenote.Season; info.SeasonNumber = gracenote.Season;
@ -371,13 +371,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
} }
} }
if (details.OriginalAirDate != null) if (details.OriginalAirDate is not null)
{ {
info.OriginalAirDate = details.OriginalAirDate; info.OriginalAirDate = details.OriginalAirDate;
info.ProductionYear = info.OriginalAirDate.Value.Year; info.ProductionYear = info.OriginalAirDate.Value.Year;
} }
if (details.Movie != null) if (details.Movie is not null)
{ {
if (!string.IsNullOrEmpty(details.Movie.Year) if (!string.IsNullOrEmpty(details.Movie.Year)
&& int.TryParse(details.Movie.Year, out int year)) && int.TryParse(details.Movie.Year, out int year))
@ -386,7 +386,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
} }
} }
if (details.Genres != null) if (details.Genres is not null)
{ {
info.Genres = details.Genres.Where(g => !string.IsNullOrWhiteSpace(g)).ToList(); info.Genres = details.Genres.Where(g => !string.IsNullOrWhiteSpace(g)).ToList();
info.IsNews = details.Genres.Contains("news", StringComparison.OrdinalIgnoreCase); info.IsNews = details.Genres.Contains("news", StringComparison.OrdinalIgnoreCase);
@ -518,7 +518,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var root = await JsonSerializer.DeserializeAsync<IReadOnlyList<HeadendsDto>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false); var root = await JsonSerializer.DeserializeAsync<IReadOnlyList<HeadendsDto>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false);
if (root != null) if (root is not null)
{ {
foreach (HeadendsDto headend in root) foreach (HeadendsDto headend in root)
{ {
@ -814,7 +814,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
Name = string.IsNullOrWhiteSpace(station.Name) ? channelNumber : station.Name Name = string.IsNullOrWhiteSpace(station.Name) ? channelNumber : station.Name
}; };
if (station.Logo != null) if (station.Logo is not null)
{ {
channelInfo.ImageUrl = station.Logo.Url; channelInfo.ImageUrl = station.Logo.Url;
} }

@ -151,9 +151,9 @@ namespace Emby.Server.Implementations.LiveTv.Listings
Overview = program.Description, Overview = program.Description,
ProductionYear = program.CopyrightDate?.Year, ProductionYear = program.CopyrightDate?.Year,
SeasonNumber = program.Episode?.Series, SeasonNumber = program.Episode?.Series,
IsSeries = program.Episode != null, IsSeries = program.Episode is not null,
IsRepeat = program.IsPreviouslyShown && !program.IsNew, IsRepeat = program.IsPreviouslyShown && !program.IsNew,
IsPremiere = program.Premiere != null, IsPremiere = program.Premiere is not null,
IsKids = program.Categories.Any(c => info.KidsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)), IsKids = program.Categories.Any(c => info.KidsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparison.OrdinalIgnoreCase)), IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)), IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),

@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.LiveTv
dto.ProgramId = GetInternalProgramId(info.ProgramId).ToString("N", CultureInfo.InvariantCulture); dto.ProgramId = GetInternalProgramId(info.ProgramId).ToString("N", CultureInfo.InvariantCulture);
} }
if (program != null) if (program is not null)
{ {
dto.ProgramInfo = _dtoService.GetBaseItemDto(program, new DtoOptions()); dto.ProgramInfo = _dtoService.GetBaseItemDto(program, new DtoOptions());
@ -98,7 +98,7 @@ namespace Emby.Server.Implementations.LiveTv
} }
} }
if (channel != null) if (channel is not null)
{ {
dto.ChannelName = channel.Name; dto.ChannelName = channel.Name;
@ -168,10 +168,10 @@ namespace Emby.Server.Implementations.LiveTv
DtoOptions = new DtoOptions(false) DtoOptions = new DtoOptions(false)
}).FirstOrDefault(); }).FirstOrDefault();
if (librarySeries != null) if (librarySeries is not null)
{ {
var image = librarySeries.GetImageInfo(ImageType.Thumb, 0); var image = librarySeries.GetImageInfo(ImageType.Thumb, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.LiveTv
} }
image = librarySeries.GetImageInfo(ImageType.Backdrop, 0); image = librarySeries.GetImageInfo(ImageType.Backdrop, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -212,10 +212,10 @@ namespace Emby.Server.Implementations.LiveTv
Name = string.IsNullOrEmpty(programSeriesId) ? seriesName : null Name = string.IsNullOrEmpty(programSeriesId) ? seriesName : null
}).FirstOrDefault(); }).FirstOrDefault();
if (program != null) if (program is not null)
{ {
var image = program.GetImageInfo(ImageType.Primary, 0); var image = program.GetImageInfo(ImageType.Primary, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -231,7 +231,7 @@ namespace Emby.Server.Implementations.LiveTv
if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0) if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0)
{ {
image = program.GetImageInfo(ImageType.Backdrop, 0); image = program.GetImageInfo(ImageType.Backdrop, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -262,10 +262,10 @@ namespace Emby.Server.Implementations.LiveTv
DtoOptions = new DtoOptions(false) DtoOptions = new DtoOptions(false)
}).FirstOrDefault(); }).FirstOrDefault();
if (librarySeries != null) if (librarySeries is not null)
{ {
var image = librarySeries.GetImageInfo(ImageType.Thumb, 0); var image = librarySeries.GetImageInfo(ImageType.Thumb, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -279,7 +279,7 @@ namespace Emby.Server.Implementations.LiveTv
} }
image = librarySeries.GetImageInfo(ImageType.Backdrop, 0); image = librarySeries.GetImageInfo(ImageType.Backdrop, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -318,10 +318,10 @@ namespace Emby.Server.Implementations.LiveTv
}).FirstOrDefault(); }).FirstOrDefault();
} }
if (program != null) if (program is not null)
{ {
var image = program.GetImageInfo(ImageType.Primary, 0); var image = program.GetImageInfo(ImageType.Primary, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -337,7 +337,7 @@ namespace Emby.Server.Implementations.LiveTv
if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0) if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0)
{ {
image = program.GetImageInfo(ImageType.Backdrop, 0); image = program.GetImageInfo(ImageType.Backdrop, 0);
if (image != null) if (image is not null)
{ {
try try
{ {
@ -460,7 +460,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var channel = _libraryManager.GetItemById(dto.ChannelId); var channel = _libraryManager.GetItemById(dto.ChannelId);
if (channel != null) if (channel is not null)
{ {
info.ChannelId = channel.ExternalId; info.ChannelId = channel.ExternalId;
} }
@ -470,7 +470,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var program = _libraryManager.GetItemById(dto.ProgramId); var program = _libraryManager.GetItemById(dto.ProgramId);
if (program != null) if (program is not null)
{ {
info.ProgramId = program.ExternalId; info.ProgramId = program.ExternalId;
} }
@ -480,7 +480,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var timer = await liveTv.GetSeriesTimer(dto.SeriesTimerId, cancellationToken).ConfigureAwait(false); var timer = await liveTv.GetSeriesTimer(dto.SeriesTimerId, cancellationToken).ConfigureAwait(false);
if (timer != null) if (timer is not null)
{ {
info.SeriesTimerId = timer.ExternalId; info.SeriesTimerId = timer.ExternalId;
} }
@ -526,7 +526,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var channel = _libraryManager.GetItemById(dto.ChannelId); var channel = _libraryManager.GetItemById(dto.ChannelId);
if (channel != null) if (channel is not null)
{ {
info.ChannelId = channel.ExternalId; info.ChannelId = channel.ExternalId;
} }
@ -536,7 +536,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var program = _libraryManager.GetItemById(dto.ProgramId); var program = _libraryManager.GetItemById(dto.ProgramId);
if (program != null) if (program is not null)
{ {
info.ProgramId = program.ExternalId; info.ProgramId = program.ExternalId;
} }

@ -446,7 +446,7 @@ namespace Emby.Server.Implementations.LiveTv
isNew = true; isNew = true;
} }
if (channelInfo.Tags != null) if (channelInfo.Tags is not null)
{ {
if (!channelInfo.Tags.SequenceEqual(item.Tags, StringComparer.OrdinalIgnoreCase)) if (!channelInfo.Tags.SequenceEqual(item.Tags, StringComparer.OrdinalIgnoreCase))
{ {
@ -836,7 +836,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery(), cancellationToken).ConfigureAwait(false); var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery(), cancellationToken).ConfigureAwait(false);
var seriesTimer = seriesTimers.Items.FirstOrDefault(i => string.Equals(_tvDtoService.GetInternalSeriesTimerId(i.Id).ToString("N", CultureInfo.InvariantCulture), query.SeriesTimerId, StringComparison.OrdinalIgnoreCase)); var seriesTimer = seriesTimers.Items.FirstOrDefault(i => string.Equals(_tvDtoService.GetInternalSeriesTimerId(i.Id).ToString("N", CultureInfo.InvariantCulture), query.SeriesTimerId, StringComparison.OrdinalIgnoreCase));
if (seriesTimer != null) if (seriesTimer is not null)
{ {
internalQuery.ExternalSeriesId = seriesTimer.SeriesId; internalQuery.ExternalSeriesId = seriesTimer.SeriesId;
@ -989,7 +989,7 @@ namespace Emby.Server.Implementations.LiveTv
var timer = timerList.FirstOrDefault(i => string.Equals(i.ProgramId, externalProgramId, StringComparison.OrdinalIgnoreCase)); var timer = timerList.FirstOrDefault(i => string.Equals(i.ProgramId, externalProgramId, StringComparison.OrdinalIgnoreCase));
var foundSeriesTimer = false; var foundSeriesTimer = false;
if (timer != null) if (timer is not null)
{ {
if (timer.Status != RecordingStatus.Cancelled && timer.Status != RecordingStatus.Error) if (timer.Status != RecordingStatus.Cancelled && timer.Status != RecordingStatus.Error)
{ {
@ -1016,7 +1016,7 @@ namespace Emby.Server.Implementations.LiveTv
var seriesTimer = seriesTimerList.FirstOrDefault(i => string.Equals(i.SeriesId, externalSeriesId, StringComparison.OrdinalIgnoreCase)); var seriesTimer = seriesTimerList.FirstOrDefault(i => string.Equals(i.SeriesId, externalSeriesId, StringComparison.OrdinalIgnoreCase));
if (seriesTimer != null) if (seriesTimer is not null)
{ {
program.SeriesTimerId = _tvDtoService.GetInternalSeriesTimerId(seriesTimer.Id) program.SeriesTimerId = _tvDtoService.GetInternalSeriesTimerId(seriesTimer.Id)
.ToString("N", CultureInfo.InvariantCulture); .ToString("N", CultureInfo.InvariantCulture);
@ -1086,7 +1086,7 @@ namespace Emby.Server.Implementations.LiveTv
var coreService = _services.OfType<EmbyTV.EmbyTV>().FirstOrDefault(); var coreService = _services.OfType<EmbyTV.EmbyTV>().FirstOrDefault();
if (coreService != null) if (coreService is not null)
{ {
await coreService.RefreshSeriesTimers(cancellationToken).ConfigureAwait(false); await coreService.RefreshSeriesTimers(cancellationToken).ConfigureAwait(false);
await coreService.RefreshTimers(cancellationToken).ConfigureAwait(false); await coreService.RefreshTimers(cancellationToken).ConfigureAwait(false);
@ -1280,7 +1280,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var item = _libraryManager.GetItemById(itemId); var item = _libraryManager.GetItemById(itemId);
if (item != null) if (item is not null)
{ {
_libraryManager.DeleteItem( _libraryManager.DeleteItem(
item, item,
@ -1377,7 +1377,7 @@ namespace Emby.Server.Implementations.LiveTv
limit = null; limit = null;
// var allActivePaths = EmbyTV.EmbyTV.Current.GetAllActiveRecordings().Select(i => i.Path).ToArray(); // var allActivePaths = EmbyTV.EmbyTV.Current.GetAllActiveRecordings().Select(i => i.Path).ToArray();
// var items = allActivePaths.Select(i => _libraryManager.FindByPath(i, false)).Where(i => i != null).ToArray(); // var items = allActivePaths.Select(i => _libraryManager.FindByPath(i, false)).Where(i => i is not null).ToArray();
// return new QueryResult<BaseItem> // return new QueryResult<BaseItem>
// { // {
@ -1517,7 +1517,7 @@ namespace Emby.Server.Implementations.LiveTv
dto.CompletionPercentage = pct; dto.CompletionPercentage = pct;
} }
if (channel != null) if (channel is not null)
{ {
dto.ChannelName = channel.Name; dto.ChannelName = channel.Name;
@ -1887,7 +1887,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var currentProgram = programs.FirstOrDefault(i => channel.Id.Equals(i.ChannelId)); var currentProgram = programs.FirstOrDefault(i => channel.Id.Equals(i.ChannelId));
if (currentProgram != null) if (currentProgram is not null)
{ {
currentProgramsList.Add(currentProgram); currentProgramsList.Add(currentProgram);
} }
@ -1913,7 +1913,7 @@ namespace Emby.Server.Implementations.LiveTv
ILiveTvService service = null; ILiveTvService service = null;
ProgramInfo programInfo = null; ProgramInfo programInfo = null;
if (program != null) if (program is not null)
{ {
service = GetService(program); service = GetService(program);
@ -2317,7 +2317,7 @@ namespace Emby.Server.Implementations.LiveTv
var providerChannel = EmbyTV.EmbyTV.Current.GetEpgChannelFromTunerChannel(mappings, tunerChannel, providerChannels); var providerChannel = EmbyTV.EmbyTV.Current.GetEpgChannelFromTunerChannel(mappings, tunerChannel, providerChannels);
if (providerChannel != null) if (providerChannel is not null)
{ {
result.ProviderChannelName = providerChannel.Name; result.ProviderChannelName = providerChannel.Name;
result.ProviderChannelId = providerChannel.Id; result.ProviderChannelId = providerChannel.Id;
@ -2390,7 +2390,7 @@ namespace Emby.Server.Implementations.LiveTv
.SelectMany(i => i.Locations) .SelectMany(i => i.Locations)
.Distinct(StringComparer.OrdinalIgnoreCase) .Distinct(StringComparer.OrdinalIgnoreCase)
.Select(i => _libraryManager.FindByPath(i, true)) .Select(i => _libraryManager.FindByPath(i, true))
.Where(i => i != null && i.IsVisibleStandalone(user)) .Where(i => i is not null && i.IsVisibleStandalone(user))
.SelectMany(i => _libraryManager.GetCollectionFolders(i)) .SelectMany(i => _libraryManager.GetCollectionFolders(i))
.GroupBy(x => x.Id) .GroupBy(x => x.Id)
.Select(x => x.First()) .Select(x => x.First())

@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
var activeRecordingInfo = _liveTvManager.GetActiveRecordingInfo(item.Path); var activeRecordingInfo = _liveTvManager.GetActiveRecordingInfo(item.Path);
if (string.IsNullOrEmpty(item.Path) || activeRecordingInfo != null) if (string.IsNullOrEmpty(item.Path) || activeRecordingInfo is not null)
{ {
return GetMediaSourcesInternal(item, activeRecordingInfo, cancellationToken); return GetMediaSourcesInternal(item, activeRecordingInfo, cancellationToken);
} }
@ -59,7 +59,7 @@ namespace Emby.Server.Implementations.LiveTv
try try
{ {
if (activeRecordingInfo != null) if (activeRecordingInfo is not null)
{ {
sources = await EmbyTV.EmbyTV.Current.GetRecordingStreamMediaSources(activeRecordingInfo, cancellationToken) sources = await EmbyTV.EmbyTV.Current.GetRecordingStreamMediaSources(activeRecordingInfo, cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);

@ -147,7 +147,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var channels = await GetChannels(host, true, cancellationToken).ConfigureAwait(false); var channels = await GetChannels(host, true, cancellationToken).ConfigureAwait(false);
var channelInfo = channels.FirstOrDefault(i => string.Equals(i.Id, channelId, StringComparison.OrdinalIgnoreCase)); var channelInfo = channels.FirstOrDefault(i => string.Equals(i.Id, channelId, StringComparison.OrdinalIgnoreCase));
if (channelInfo != null) if (channelInfo is not null)
{ {
return await GetChannelStreamMediaSources(host, channelInfo, cancellationToken).ConfigureAwait(false); return await GetChannelStreamMediaSources(host, channelInfo, cancellationToken).ConfigureAwait(false);
} }
@ -187,7 +187,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var channels = await GetChannels(host, true, cancellationToken).ConfigureAwait(false); var channels = await GetChannels(host, true, cancellationToken).ConfigureAwait(false);
var channelInfo = channels.FirstOrDefault(i => string.Equals(i.Id, channelId, StringComparison.OrdinalIgnoreCase)); var channelInfo = channels.FirstOrDefault(i => string.Equals(i.Id, channelId, StringComparison.OrdinalIgnoreCase));
if (channelInfo != null) if (channelInfo is not null)
{ {
hostsWithChannel.Add(new Tuple<TunerHostInfo, ChannelInfo>(host, channelInfo)); hostsWithChannel.Add(new Tuple<TunerHostInfo, ChannelInfo>(host, channelInfo));
} }

@ -503,7 +503,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{ {
var modelInfo = await GetModelInfo(tuner, false, cancellationToken).ConfigureAwait(false); var modelInfo = await GetModelInfo(tuner, false, cancellationToken).ConfigureAwait(false);
if (modelInfo != null && modelInfo.SupportsTranscoding) if (modelInfo is not null && modelInfo.SupportsTranscoding)
{ {
if (tuner.AllowHWTranscoding) if (tuner.AllowHWTranscoding)
{ {
@ -560,7 +560,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var mediaSource = GetMediaSource(tunerHost, hdhrId, channel, profile); var mediaSource = GetMediaSource(tunerHost, hdhrId, channel, profile);
if (hdhomerunChannel != null && hdhomerunChannel.IsLegacyTuner) if (hdhomerunChannel is not null && hdhomerunChannel.IsLegacyTuner)
{ {
return new HdHomerunUdpStream( return new HdHomerunUdpStream(
mediaSource, mediaSource,
@ -674,7 +674,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var info = await TryGetTunerHostInfo(deviceAddress, cancellationToken).ConfigureAwait(false); var info = await TryGetTunerHostInfo(deviceAddress, cancellationToken).ConfigureAwait(false);
if (info != null) if (info is not null)
{ {
list.Add(info); list.Add(info);
} }

@ -37,7 +37,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{ {
using (var socket = _tcpClient) using (var socket = _tcpClient)
{ {
if (socket != null) if (socket is not null)
{ {
_tcpClient = null; _tcpClient = null;

@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
EnableStreamSharing = true; EnableStreamSharing = true;
UniqueId = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture); UniqueId = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
if (tuner != null) if (tuner is not null)
{ {
TunerHostId = tuner.Id; TunerHostId = tuner.Id;
} }

@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.MediaEncoder
} }
var libraryOptions = _libraryManager.GetLibraryOptions(video); var libraryOptions = _libraryManager.GetLibraryOptions(video);
if (libraryOptions != null) if (libraryOptions is not null)
{ {
if (!libraryOptions.EnableChapterImageExtraction) if (!libraryOptions.EnableChapterImageExtraction)
{ {

@ -74,7 +74,7 @@ namespace Emby.Server.Implementations.Net
private void OnReceiveSocketAsyncEventArgsCompleted(object sender, SocketAsyncEventArgs e) private void OnReceiveSocketAsyncEventArgsCompleted(object sender, SocketAsyncEventArgs e)
{ {
var tcs = _currentReceiveTaskCompletionSource; var tcs = _currentReceiveTaskCompletionSource;
if (tcs != null) if (tcs is not null)
{ {
_currentReceiveTaskCompletionSource = null; _currentReceiveTaskCompletionSource = null;
@ -98,7 +98,7 @@ namespace Emby.Server.Implementations.Net
private void OnSendSocketAsyncEventArgsCompleted(object sender, SocketAsyncEventArgs e) private void OnSendSocketAsyncEventArgsCompleted(object sender, SocketAsyncEventArgs e)
{ {
var tcs = _currentSendTaskCompletionSource; var tcs = _currentSendTaskCompletionSource;
if (tcs != null) if (tcs is not null)
{ {
_currentSendTaskCompletionSource = null; _currentSendTaskCompletionSource = null;

@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Playlists
private List<BaseItem> GetPlaylistItems(IEnumerable<Guid> itemIds, string playlistMediaType, User user, DtoOptions options) private List<BaseItem> GetPlaylistItems(IEnumerable<Guid> itemIds, string playlistMediaType, User user, DtoOptions options)
{ {
var items = itemIds.Select(i => _libraryManager.GetItemById(i)).Where(i => i != null); var items = itemIds.Select(i => _libraryManager.GetItemById(i)).Where(i => i is not null);
return Playlist.GetPlaylistItems(playlistMediaType, items, user, options); return Playlist.GetPlaylistItems(playlistMediaType, items, user, options);
} }

@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Plugins
// If no version is given, return the current instance. // If no version is given, return the current instance.
var plugins = _plugins.Where(p => p.Id.Equals(id)).ToList(); var plugins = _plugins.Where(p => p.Id.Equals(id)).ToList();
plugin = plugins.FirstOrDefault(p => p.Instance != null) ?? plugins.OrderByDescending(p => p.Version).FirstOrDefault(); plugin = plugins.FirstOrDefault(p => p.Instance is not null) ?? plugins.OrderByDescending(p => p.Version).FirstOrDefault();
} }
else else
{ {
@ -500,7 +500,7 @@ namespace Emby.Server.Implementations.Plugins
#pragma warning restore CA1031 // Do not catch general exception types #pragma warning restore CA1031 // Do not catch general exception types
{ {
_logger.LogError(ex, "Error creating {Type}", type.FullName); _logger.LogError(ex, "Error creating {Type}", type.FullName);
if (plugin != null) if (plugin is not null)
{ {
if (ChangePluginState(plugin, PluginStatus.Malfunctioned)) if (ChangePluginState(plugin, PluginStatus.Malfunctioned))
{ {
@ -523,7 +523,7 @@ namespace Emby.Server.Implementations.Plugins
var predecessor = _plugins.OrderByDescending(p => p.Version) var predecessor = _plugins.OrderByDescending(p => p.Version)
.FirstOrDefault(p => p.Id.Equals(plugin.Id) && p.IsEnabledAndSupported && p.Version != plugin.Version); .FirstOrDefault(p => p.Id.Equals(plugin.Id) && p.IsEnabledAndSupported && p.Version != plugin.Version);
if (predecessor != null) if (predecessor is not null)
{ {
return; return;
} }
@ -577,7 +577,7 @@ namespace Emby.Server.Implementations.Plugins
_logger.LogError(ex, "Error deserializing {Json}.", Encoding.UTF8.GetString(data!)); _logger.LogError(ex, "Error deserializing {Json}.", Encoding.UTF8.GetString(data!));
} }
if (manifest != null) if (manifest is not null)
{ {
if (!Version.TryParse(manifest.TargetAbi, out var targetAbi)) if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
{ {

@ -211,7 +211,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{ {
get get
{ {
if (CurrentCancellationTokenSource != null) if (CurrentCancellationTokenSource is not null)
{ {
return CurrentCancellationTokenSource.IsCancellationRequested return CurrentCancellationTokenSource.IsCancellationRequested
? TaskState.Cancelling ? TaskState.Cancelling
@ -240,7 +240,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
ArgumentNullException.ThrowIfNull(value); ArgumentNullException.ThrowIfNull(value);
// Cleanup current triggers // Cleanup current triggers
if (_triggers != null) if (_triggers is not null)
{ {
DisposeTriggers(); DisposeTriggers();
} }
@ -269,7 +269,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
ArgumentNullException.ThrowIfNull(value); ArgumentNullException.ThrowIfNull(value);
// This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly // This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly
var triggerList = value.Where(i => i != null).ToArray(); var triggerList = value.Where(i => i is not null).ToArray();
SaveTriggers(triggerList); SaveTriggers(triggerList);
@ -369,7 +369,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
private async Task ExecuteInternal(TaskOptions options) private async Task ExecuteInternal(TaskOptions options)
{ {
// Cancel the current execution, if any // Cancel the current execution, if any
if (CurrentCancellationTokenSource != null) if (CurrentCancellationTokenSource is not null)
{ {
throw new InvalidOperationException("Cannot execute a Task that is already running"); throw new InvalidOperationException("Cannot execute a Task that is already running");
} }
@ -391,7 +391,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
try try
{ {
if (options != null && options.MaxRuntimeTicks.HasValue) if (options is not null && options.MaxRuntimeTicks.HasValue)
{ {
CurrentCancellationTokenSource.CancelAfter(TimeSpan.FromTicks(options.MaxRuntimeTicks.Value)); CurrentCancellationTokenSource.CancelAfter(TimeSpan.FromTicks(options.MaxRuntimeTicks.Value));
} }
@ -507,7 +507,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
private Tuple<TaskTriggerInfo, ITaskTrigger>[] LoadTriggers() private Tuple<TaskTriggerInfo, ITaskTrigger>[] LoadTriggers()
{ {
// This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly // This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly
var settings = LoadTriggerSettings().Where(i => i != null).ToArray(); var settings = LoadTriggerSettings().Where(i => i is not null).ToArray();
return settings.Select(i => new Tuple<TaskTriggerInfo, ITaskTrigger>(i, GetTrigger(i))).ToArray(); return settings.Select(i => new Tuple<TaskTriggerInfo, ITaskTrigger>(i, GetTrigger(i))).ToArray();
} }
@ -583,7 +583,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
result.Key = ScheduledTask.Key; result.Key = ScheduledTask.Key;
if (ex != null) if (ex is not null)
{ {
result.ErrorMessage = ex.Message; result.ErrorMessage = ex.Message;
result.LongErrorMessage = ex.StackTrace; result.LongErrorMessage = ex.StackTrace;
@ -617,7 +617,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
var startTime = CurrentExecutionStartTime; var startTime = CurrentExecutionStartTime;
var token = CurrentCancellationTokenSource; var token = CurrentCancellationTokenSource;
if (token != null) if (token is not null)
{ {
try try
{ {
@ -631,7 +631,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
} }
var task = _currentTask; var task = _currentTask;
if (task != null) if (task is not null)
{ {
try try
{ {
@ -653,7 +653,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
} }
} }
if (token != null) if (token is not null)
{ {
try try
{ {

@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
previouslyFailedImages.Add(key); previouslyFailedImages.Add(key);
var parentPath = Path.GetDirectoryName(failHistoryPath); var parentPath = Path.GetDirectoryName(failHistoryPath);
if (parentPath != null) if (parentPath is not null)
{ {
Directory.CreateDirectory(parentPath); Directory.CreateDirectory(parentPath);
} }

@ -100,7 +100,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Triggers
{ {
DisposeTimer(); DisposeTimer();
if (Triggered != null) if (Triggered is not null)
{ {
_lastStartDate = DateTime.UtcNow; _lastStartDate = DateTime.UtcNow;
Triggered(this, EventArgs.Empty); Triggered(this, EventArgs.Empty);

@ -200,7 +200,7 @@ namespace Emby.Server.Implementations.Session
{ {
var capabilities = _deviceManager.GetCapabilities(info.DeviceId); var capabilities = _deviceManager.GetCapabilities(info.DeviceId);
if (capabilities != null) if (capabilities is not null)
{ {
ReportCapabilities(info, capabilities, false); ReportCapabilities(info, capabilities, false);
} }
@ -238,7 +238,7 @@ namespace Emby.Server.Implementations.Session
public void UpdateDeviceName(string sessionId, string reportedDeviceName) public void UpdateDeviceName(string sessionId, string reportedDeviceName)
{ {
var session = GetSession(sessionId); var session = GetSession(sessionId);
if (session != null) if (session is not null)
{ {
session.DeviceName = reportedDeviceName; session.DeviceName = reportedDeviceName;
} }
@ -284,7 +284,7 @@ namespace Emby.Server.Implementations.Session
var lastActivityDate = session.LastActivityDate; var lastActivityDate = session.LastActivityDate;
session.LastActivityDate = activityDate; session.LastActivityDate = activityDate;
if (user != null) if (user is not null)
{ {
var userLastActivityDate = user.LastActivityDate ?? DateTime.MinValue; var userLastActivityDate = user.LastActivityDate ?? DateTime.MinValue;
@ -351,7 +351,7 @@ namespace Emby.Server.Implementations.Session
CheckDisposed(); CheckDisposed();
var session = GetSession(sessionId, false); var session = GetSession(sessionId, false);
if (session != null) if (session is not null)
{ {
var key = GetSessionKey(session.Client, session.DeviceId); var key = GetSessionKey(session.Client, session.DeviceId);
@ -377,7 +377,7 @@ namespace Emby.Server.Implementations.Session
info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture); info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture);
} }
if (!info.ItemId.Equals(default) && info.Item is null && libraryItem != null) if (!info.ItemId.Equals(default) && info.Item is null && libraryItem is not null)
{ {
var current = session.NowPlayingItem; var current = session.NowPlayingItem;
@ -390,7 +390,7 @@ namespace Emby.Server.Implementations.Session
{ {
mediaSource = await GetMediaSource(libraryItem, info.MediaSourceId, info.LiveStreamId).ConfigureAwait(false); mediaSource = await GetMediaSource(libraryItem, info.MediaSourceId, info.LiveStreamId).ConfigureAwait(false);
if (mediaSource != null) if (mediaSource is not null)
{ {
runtimeTicks = mediaSource.RunTimeTicks; runtimeTicks = mediaSource.RunTimeTicks;
} }
@ -579,7 +579,7 @@ namespace Emby.Server.Implementations.Session
users.AddRange(session.AdditionalUsers users.AddRange(session.AdditionalUsers
.Select(i => _userManager.GetUserById(i.UserId)) .Select(i => _userManager.GetUserById(i.UserId))
.Where(i => i != null)); .Where(i => i is not null));
return users; return users;
} }
@ -591,7 +591,7 @@ namespace Emby.Server.Implementations.Session
private void StopIdleCheckTimer() private void StopIdleCheckTimer()
{ {
if (_idleTimer != null) if (_idleTimer is not null)
{ {
_idleTimer.Dispose(); _idleTimer.Dispose();
_idleTimer = null; _idleTimer = null;
@ -600,7 +600,7 @@ namespace Emby.Server.Implementations.Session
private async void CheckForIdlePlayback(object state) private async void CheckForIdlePlayback(object state)
{ {
var playingSessions = Sessions.Where(i => i.NowPlayingItem != null) var playingSessions = Sessions.Where(i => i.NowPlayingItem is not null)
.ToList(); .ToList();
if (playingSessions.Count > 0) if (playingSessions.Count > 0)
@ -630,7 +630,7 @@ namespace Emby.Server.Implementations.Session
} }
} }
playingSessions = Sessions.Where(i => i.NowPlayingItem != null) playingSessions = Sessions.Where(i => i.NowPlayingItem is not null)
.ToList(); .ToList();
} }
@ -643,7 +643,7 @@ namespace Emby.Server.Implementations.Session
private BaseItem GetNowPlayingItem(SessionInfo session, Guid itemId) private BaseItem GetNowPlayingItem(SessionInfo session, Guid itemId)
{ {
var item = session.FullNowPlayingItem; var item = session.FullNowPlayingItem;
if (item != null && item.Id.Equals(itemId)) if (item is not null && item.Id.Equals(itemId))
{ {
return item; return item;
} }
@ -684,7 +684,7 @@ namespace Emby.Server.Implementations.Session
var users = GetUsers(session); var users = GetUsers(session);
if (libraryItem != null) if (libraryItem is not null)
{ {
foreach (var user in users) foreach (var user in users)
{ {
@ -777,7 +777,7 @@ namespace Emby.Server.Implementations.Session
var users = GetUsers(session); var users = GetUsers(session);
// only update saved user data on actual check-ins, not automated ones // only update saved user data on actual check-ins, not automated ones
if (libraryItem != null && !isAutomated) if (libraryItem is not null && !isAutomated)
{ {
foreach (var user in users) foreach (var user in users)
{ {
@ -912,7 +912,7 @@ namespace Emby.Server.Implementations.Session
info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture); info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture);
} }
if (!info.ItemId.Equals(default) && info.Item is null && libraryItem != null) if (!info.ItemId.Equals(default) && info.Item is null && libraryItem is not null)
{ {
var current = session.NowPlayingItem; var current = session.NowPlayingItem;
@ -933,7 +933,7 @@ namespace Emby.Server.Implementations.Session
} }
} }
if (info.Item != null) if (info.Item is not null)
{ {
var msString = info.PositionTicks.HasValue ? (info.PositionTicks.Value / 10000).ToString(CultureInfo.InvariantCulture) : "unknown"; var msString = info.PositionTicks.HasValue ? (info.PositionTicks.Value / 10000).ToString(CultureInfo.InvariantCulture) : "unknown";
@ -945,7 +945,7 @@ namespace Emby.Server.Implementations.Session
msString); msString);
} }
if (info.NowPlayingQueue != null) if (info.NowPlayingQueue is not null)
{ {
session.NowPlayingQueue = info.NowPlayingQueue; session.NowPlayingQueue = info.NowPlayingQueue;
} }
@ -957,7 +957,7 @@ namespace Emby.Server.Implementations.Session
var users = GetUsers(session); var users = GetUsers(session);
var playedToCompletion = false; var playedToCompletion = false;
if (libraryItem != null) if (libraryItem is not null)
{ {
foreach (var user in users) foreach (var user in users)
{ {
@ -1164,7 +1164,7 @@ namespace Emby.Server.Implementations.Session
command.ItemIds = items.Select(i => i.Id).ToArray(); command.ItemIds = items.Select(i => i.Id).ToArray();
if (user != null) if (user is not null)
{ {
if (items.Any(i => i.GetPlayAccess(user) != PlayAccess.Full)) if (items.Any(i => i.GetPlayAccess(user) != PlayAccess.Full))
{ {
@ -1173,13 +1173,13 @@ namespace Emby.Server.Implementations.Session
} }
} }
if (user != null if (user is not null
&& command.ItemIds.Length == 1 && command.ItemIds.Length == 1
&& user.EnableNextEpisodeAutoPlay && user.EnableNextEpisodeAutoPlay
&& _libraryManager.GetItemById(command.ItemIds[0]) is Episode episode) && _libraryManager.GetItemById(command.ItemIds[0]) is Episode episode)
{ {
var series = episode.Series; var series = episode.Series;
if (series != null) if (series is not null)
{ {
var episodes = series.GetEpisodes( var episodes = series.GetEpisodes(
user, user,
@ -1429,7 +1429,7 @@ namespace Emby.Server.Implementations.Session
var user = session.AdditionalUsers.FirstOrDefault(i => i.UserId.Equals(userId)); var user = session.AdditionalUsers.FirstOrDefault(i => i.UserId.Equals(userId));
if (user != null) if (user is not null)
{ {
var list = session.AdditionalUsers.ToList(); var list = session.AdditionalUsers.ToList();
list.Remove(user); list.Remove(user);
@ -1554,7 +1554,7 @@ namespace Emby.Server.Implementations.Session
} }
} }
if (existing != null) if (existing is not null)
{ {
_logger.LogInformation("Reissuing access token: {Token}", existing.AccessToken); _logger.LogInformation("Reissuing access token: {Token}", existing.AccessToken);
return existing.AccessToken; return existing.AccessToken;
@ -1720,7 +1720,7 @@ namespace Emby.Server.Implementations.Session
var info = _dtoService.GetBaseItemDto(item, dtoOptions); var info = _dtoService.GetBaseItemDto(item, dtoOptions);
if (mediaSource != null) if (mediaSource is not null)
{ {
info.MediaStreams = mediaSource.MediaStreams.ToArray(); info.MediaStreams = mediaSource.MediaStreams.ToArray();
} }
@ -1761,7 +1761,7 @@ namespace Emby.Server.Implementations.Session
var session = Sessions.FirstOrDefault(i => var session = Sessions.FirstOrDefault(i =>
string.Equals(i.DeviceId, deviceId, StringComparison.OrdinalIgnoreCase)); string.Equals(i.DeviceId, deviceId, StringComparison.OrdinalIgnoreCase));
if (session != null) if (session is not null)
{ {
session.TranscodingInfo = info; session.TranscodingInfo = info;
} }

@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.Session
public async Task ProcessWebSocketConnectedAsync(IWebSocketConnection connection, HttpContext httpContext) public async Task ProcessWebSocketConnectedAsync(IWebSocketConnection connection, HttpContext httpContext)
{ {
var session = await GetSession(httpContext, connection.RemoteEndPoint?.ToString()).ConfigureAwait(false); var session = await GetSession(httpContext, connection.RemoteEndPoint?.ToString()).ConfigureAwait(false);
if (session != null) if (session is not null)
{ {
EnsureController(session, connection); EnsureController(session, connection);
await KeepAliveWebSocket(connection).ConfigureAwait(false); await KeepAliveWebSocket(connection).ConfigureAwait(false);
@ -221,7 +221,7 @@ namespace Emby.Server.Implementations.Session
{ {
lock (_keepAliveLock) lock (_keepAliveLock)
{ {
if (_keepAliveCancellationToken != null) if (_keepAliveCancellationToken is not null)
{ {
_keepAliveCancellationToken.Cancel(); _keepAliveCancellationToken.Cancel();
_keepAliveCancellationToken.Dispose(); _keepAliveCancellationToken.Dispose();

@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.Sorting
{ {
var userdata = UserDataRepository.GetUserData(User, x); var userdata = UserDataRepository.GetUserData(User, x);
if (userdata != null && userdata.LastPlayedDate.HasValue) if (userdata is not null && userdata.LastPlayedDate.HasValue)
{ {
return userdata.LastPlayedDate.Value; return userdata.LastPlayedDate.Value;
} }

@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.SyncPlay
GroupName = request.GroupName; GroupName = request.GroupName;
AddSession(session); AddSession(session);
var sessionIsPlayingAnItem = session.FullNowPlayingItem != null; var sessionIsPlayingAnItem = session.FullNowPlayingItem is not null;
RestartCurrentItem(); RestartCurrentItem();

@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.TV
{ {
var parent = _libraryManager.GetItemById(query.ParentId.Value); var parent = _libraryManager.GetItemById(query.ParentId.Value);
if (parent != null) if (parent is not null)
{ {
parents = new[] { parent }; parents = new[] { parent };
} }
@ -168,7 +168,7 @@ namespace Emby.Server.Implementations.TV
return !anyFound && i.LastWatchedDate == DateTime.MinValue; return !anyFound && i.LastWatchedDate == DateTime.MinValue;
}) })
.Select(i => i.GetEpisodeFunction()) .Select(i => i.GetEpisodeFunction())
.Where(i => i != null); .Where(i => i is not null);
} }
private static string GetUniqueSeriesKey(Episode episode) private static string GetUniqueSeriesKey(Episode episode)
@ -247,23 +247,23 @@ namespace Emby.Server.Implementations.TV
DtoOptions = dtoOptions DtoOptions = dtoOptions
}) })
.Cast<Episode>() .Cast<Episode>()
.Where(episode => episode.AirsBeforeSeasonNumber != null || episode.AirsAfterSeasonNumber != null) .Where(episode => episode.AirsBeforeSeasonNumber is not null || episode.AirsAfterSeasonNumber is not null)
.ToList(); .ToList();
if (lastWatchedEpisode != null) if (lastWatchedEpisode is not null)
{ {
// Last watched episode is added, because there could be specials that aired before the last watched episode // Last watched episode is added, because there could be specials that aired before the last watched episode
consideredEpisodes.Add(lastWatchedEpisode); consideredEpisodes.Add(lastWatchedEpisode);
} }
if (nextEpisode != null) if (nextEpisode is not null)
{ {
consideredEpisodes.Add(nextEpisode); consideredEpisodes.Add(nextEpisode);
} }
var sortedConsideredEpisodes = _libraryManager.Sort(consideredEpisodes, user, new[] { (ItemSortBy.AiredEpisodeOrder, SortOrder.Ascending) }) var sortedConsideredEpisodes = _libraryManager.Sort(consideredEpisodes, user, new[] { (ItemSortBy.AiredEpisodeOrder, SortOrder.Ascending) })
.Cast<Episode>(); .Cast<Episode>();
if (lastWatchedEpisode != null) if (lastWatchedEpisode is not null)
{ {
sortedConsideredEpisodes = sortedConsideredEpisodes.SkipWhile(episode => !episode.Id.Equals(lastWatchedEpisode.Id)).Skip(1); sortedConsideredEpisodes = sortedConsideredEpisodes.SkipWhile(episode => !episode.Id.Equals(lastWatchedEpisode.Id)).Skip(1);
} }
@ -271,7 +271,7 @@ namespace Emby.Server.Implementations.TV
nextEpisode = sortedConsideredEpisodes.FirstOrDefault(); nextEpisode = sortedConsideredEpisodes.FirstOrDefault();
} }
if (nextEpisode != null) if (nextEpisode is not null)
{ {
var userData = _userDataManager.GetUserData(user, nextEpisode); var userData = _userDataManager.GetUserData(user, nextEpisode);
@ -284,7 +284,7 @@ namespace Emby.Server.Implementations.TV
return nextEpisode; return nextEpisode;
} }
if (lastWatchedEpisode != null) if (lastWatchedEpisode is not null)
{ {
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode); var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);

@ -168,7 +168,7 @@ namespace Emby.Server.Implementations.Updates
var result = new List<PackageInfo>(); var result = new List<PackageInfo>();
foreach (RepositoryInfo repository in _config.Configuration.PluginRepositories) foreach (RepositoryInfo repository in _config.Configuration.PluginRepositories)
{ {
if (repository.Enabled && repository.Url != null) if (repository.Enabled && repository.Url is not null)
{ {
// Where repositories have the same content, the details from the first is taken. // Where repositories have the same content, the details from the first is taken.
foreach (var package in await GetPackages(repository.Name ?? "Unnamed Repo", repository.Url, true, cancellationToken).ConfigureAwait(true)) foreach (var package in await GetPackages(repository.Name ?? "Unnamed Repo", repository.Url, true, cancellationToken).ConfigureAwait(true))
@ -181,7 +181,7 @@ namespace Emby.Server.Implementations.Updates
var version = package.Versions[i]; var version = package.Versions[i];
var plugin = _pluginManager.GetPlugin(package.Id, version.VersionNumber); var plugin = _pluginManager.GetPlugin(package.Id, version.VersionNumber);
if (plugin != null) if (plugin is not null)
{ {
await _pluginManager.GenerateManifest(package, version.VersionNumber, plugin.Path, plugin.Manifest.Status).ConfigureAwait(false); await _pluginManager.GenerateManifest(package, version.VersionNumber, plugin.Path, plugin.Manifest.Status).ConfigureAwait(false);
} }
@ -199,7 +199,7 @@ namespace Emby.Server.Implementations.Updates
continue; continue;
} }
if (existing != null) if (existing is not null)
{ {
// Assumption is both lists are ordered, so slot these into the correct place. // Assumption is both lists are ordered, so slot these into the correct place.
MergeSortedList(existing.Versions, package.Versions); MergeSortedList(existing.Versions, package.Versions);
@ -222,7 +222,7 @@ namespace Emby.Server.Implementations.Updates
Guid id = default, Guid id = default,
Version? specificVersion = null) Version? specificVersion = null)
{ {
if (name != null) if (name is not null)
{ {
availablePackages = availablePackages.Where(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); availablePackages = availablePackages.Where(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
} }
@ -232,7 +232,7 @@ namespace Emby.Server.Implementations.Updates
availablePackages = availablePackages.Where(x => x.Id.Equals(id)); availablePackages = availablePackages.Where(x => x.Id.Equals(id));
} }
if (specificVersion != null) if (specificVersion is not null)
{ {
availablePackages = availablePackages.Where(x => x.Versions.Any(y => y.VersionNumber.Equals(specificVersion))); availablePackages = availablePackages.Where(x => x.Versions.Any(y => y.VersionNumber.Equals(specificVersion)));
} }
@ -260,11 +260,11 @@ namespace Emby.Server.Implementations.Updates
var availableVersions = package.Versions var availableVersions = package.Versions
.Where(x => string.IsNullOrEmpty(x.TargetAbi) || Version.Parse(x.TargetAbi) <= appVer); .Where(x => string.IsNullOrEmpty(x.TargetAbi) || Version.Parse(x.TargetAbi) <= appVer);
if (specificVersion != null) if (specificVersion is not null)
{ {
availableVersions = availableVersions.Where(x => x.VersionNumber.Equals(specificVersion)); availableVersions = availableVersions.Where(x => x.VersionNumber.Equals(specificVersion));
} }
else if (minVersion != null) else if (minVersion is not null)
{ {
availableVersions = availableVersions.Where(x => x.VersionNumber >= minVersion); availableVersions = availableVersions.Where(x => x.VersionNumber >= minVersion);
} }
@ -495,7 +495,7 @@ namespace Emby.Server.Implementations.Updates
var compatibleVersions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, minVersion: plugin.Version); var compatibleVersions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, minVersion: plugin.Version);
var version = compatibleVersions.FirstOrDefault(y => y.Version > plugin.Version); var version = compatibleVersions.FirstOrDefault(y => y.Version > plugin.Version);
if (version != null && CompletedInstallations.All(x => !x.Id.Equals(version.Id))) if (version is not null && CompletedInstallations.All(x => !x.Id.Equals(version.Id)))
{ {
yield return version; yield return version;
} }
@ -567,7 +567,7 @@ namespace Emby.Server.Implementations.Updates
await PerformPackageInstallation(package, plugin?.Manifest.Status ?? PluginStatus.Active, cancellationToken).ConfigureAwait(false); await PerformPackageInstallation(package, plugin?.Manifest.Status ?? PluginStatus.Active, cancellationToken).ConfigureAwait(false);
_logger.LogInformation("Plugin {Action}: {PluginName} {PluginVersion}", plugin is null ? "installed" : "updated", package.Name, package.Version); _logger.LogInformation("Plugin {Action}: {PluginName} {PluginVersion}", plugin is null ? "installed" : "updated", package.Name, package.Version);
return plugin != null; return plugin is not null;
} }
} }
} }

@ -78,7 +78,7 @@ namespace Jellyfin.Api.Auth
return false; return false;
} }
var isInLocalNetwork = _httpContextAccessor.HttpContext != null var isInLocalNetwork = _httpContextAccessor.HttpContext is not null
&& _networkManager.IsInLocalNetwork(_httpContextAccessor.HttpContext.GetNormalizedRemoteIp()); && _networkManager.IsInLocalNetwork(_httpContextAccessor.HttpContext.GetNormalizedRemoteIp());
// User cannot access remotely and user is remote // User cannot access remotely and user is remote

@ -183,7 +183,7 @@ namespace Jellyfin.Api.Controllers
{ {
return null; return null;
} }
}).Where(i => i != null).Select(i => i!.Id).ToArray(); }).Where(i => i is not null).Select(i => i!.Id).ToArray();
} }
foreach (var filter in filters) foreach (var filter in filters)
@ -386,7 +386,7 @@ namespace Jellyfin.Api.Controllers
{ {
return null; return null;
} }
}).Where(i => i != null).Select(i => i!.Id).ToArray(); }).Where(i => i is not null).Select(i => i!.Id).ToArray();
} }
foreach (var filter in filters) foreach (var filter in filters)

@ -341,7 +341,7 @@ namespace Jellyfin.Api.Controllers
job ??= _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType); job ??= _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
if (job != null) if (job is not null)
{ {
_transcodingJobHelper.OnTranscodeEndRequest(job); _transcodingJobHelper.OnTranscodeEndRequest(job);
} }
@ -1533,7 +1533,7 @@ namespace Jellyfin.Api.Controllers
else else
{ {
job = _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType); job = _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
if (job?.TranscodingThrottler != null) if (job?.TranscodingThrottler is not null)
{ {
await job.TranscodingThrottler.UnpauseTranscoding().ConfigureAwait(false); await job.TranscodingThrottler.UnpauseTranscoding().ConfigureAwait(false);
} }
@ -1806,7 +1806,7 @@ namespace Jellyfin.Api.Controllers
if (EncodingHelper.IsCopyCodec(codec)) if (EncodingHelper.IsCopyCodec(codec))
{ {
// If h264_mp4toannexb is ever added, do not use it for live tv. // If h264_mp4toannexb is ever added, do not use it for live tv.
if (state.VideoStream != null && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase)) if (state.VideoStream is not null && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{ {
string bitStreamArgs = EncodingHelper.GetBitStreamArgs(state.VideoStream); string bitStreamArgs = EncodingHelper.GetBitStreamArgs(state.VideoStream);
if (!string.IsNullOrEmpty(bitStreamArgs)) if (!string.IsNullOrEmpty(bitStreamArgs))
@ -1837,7 +1837,7 @@ namespace Jellyfin.Api.Controllers
// -start_at_zero is necessary to use with -ss when seeking, // -start_at_zero is necessary to use with -ss when seeking,
// otherwise the target position cannot be determined. // otherwise the target position cannot be determined.
if (state.SubtitleStream != null) if (state.SubtitleStream is not null)
{ {
// Disable start_at_zero for external graphical subs // Disable start_at_zero for external graphical subs
if (!(state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)) if (!(state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream))
@ -1883,7 +1883,7 @@ namespace Jellyfin.Api.Controllers
var segmentExists = System.IO.File.Exists(segmentPath); var segmentExists = System.IO.File.Exists(segmentPath);
if (segmentExists) if (segmentExists)
{ {
if (transcodingJob != null && transcodingJob.HasExited) if (transcodingJob is not null && transcodingJob.HasExited)
{ {
// Transcoding job is over, so assume all existing files are ready // Transcoding job is over, so assume all existing files are ready
_logger.LogDebug("serving up {0} as transcode is over", segmentPath); _logger.LogDebug("serving up {0} as transcode is over", segmentPath);
@ -1901,7 +1901,7 @@ namespace Jellyfin.Api.Controllers
} }
var nextSegmentPath = GetSegmentPath(state, playlistPath, segmentIndex + 1); var nextSegmentPath = GetSegmentPath(state, playlistPath, segmentIndex + 1);
if (transcodingJob != null) if (transcodingJob is not null)
{ {
while (!cancellationToken.IsCancellationRequested && !transcodingJob.HasExited) while (!cancellationToken.IsCancellationRequested && !transcodingJob.HasExited)
{ {
@ -1953,7 +1953,7 @@ namespace Jellyfin.Api.Controllers
Response.OnCompleted(() => Response.OnCompleted(() =>
{ {
_logger.LogDebug("Finished serving {SegmentPath}", segmentPath); _logger.LogDebug("Finished serving {SegmentPath}", segmentPath);
if (transcodingJob != null) if (transcodingJob is not null)
{ {
transcodingJob.DownloadPositionTicks = Math.Max(transcodingJob.DownloadPositionTicks ?? segmentEndingPositionTicks, segmentEndingPositionTicks); transcodingJob.DownloadPositionTicks = Math.Max(transcodingJob.DownloadPositionTicks ?? segmentEndingPositionTicks, segmentEndingPositionTicks);
_transcodingJobHelper.OnTranscodeEndRequest(transcodingJob); _transcodingJobHelper.OnTranscodeEndRequest(transcodingJob);
@ -2011,7 +2011,7 @@ namespace Jellyfin.Api.Controllers
{ {
var file = GetLastTranscodingFile(playlistPath, segmentExtension, _fileSystem); var file = GetLastTranscodingFile(playlistPath, segmentExtension, _fileSystem);
if (file != null) if (file is not null)
{ {
DeleteFile(file.FullName, retryCount); DeleteFile(file.FullName, retryCount);
} }

@ -178,7 +178,7 @@ namespace Jellyfin.Api.Controllers
Response.OnCompleted(() => Response.OnCompleted(() =>
{ {
if (transcodingJob != null) if (transcodingJob is not null)
{ {
_transcodingJobHelper.OnTranscodeEndRequest(transcodingJob); _transcodingJobHelper.OnTranscodeEndRequest(transcodingJob);
} }

@ -110,7 +110,7 @@ namespace Jellyfin.Api.Controllers
// Handle image/png; charset=utf-8 // Handle image/png; charset=utf-8
var mimeType = Request.ContentType?.Split(';').FirstOrDefault(); var mimeType = Request.ContentType?.Split(';').FirstOrDefault();
var userDataPath = Path.Combine(_serverConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username); var userDataPath = Path.Combine(_serverConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username);
if (user.ProfileImage != null) if (user.ProfileImage is not null)
{ {
await _userManager.ClearProfileImageAsync(user).ConfigureAwait(false); await _userManager.ClearProfileImageAsync(user).ConfigureAwait(false);
} }
@ -157,7 +157,7 @@ namespace Jellyfin.Api.Controllers
// Handle image/png; charset=utf-8 // Handle image/png; charset=utf-8
var mimeType = Request.ContentType?.Split(';').FirstOrDefault(); var mimeType = Request.ContentType?.Split(';').FirstOrDefault();
var userDataPath = Path.Combine(_serverConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username); var userDataPath = Path.Combine(_serverConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username);
if (user.ProfileImage != null) if (user.ProfileImage is not null)
{ {
await _userManager.ClearProfileImageAsync(user).ConfigureAwait(false); await _userManager.ClearProfileImageAsync(user).ConfigureAwait(false);
} }
@ -452,7 +452,7 @@ namespace Jellyfin.Api.Controllers
{ {
var info = GetImageInfo(item, image, null); var info = GetImageInfo(item, image, null);
if (info != null) if (info is not null)
{ {
list.Add(info); list.Add(info);
} }
@ -470,7 +470,7 @@ namespace Jellyfin.Api.Controllers
{ {
var info = GetImageInfo(item, image, index); var info = GetImageInfo(item, image, index);
if (info != null) if (info is not null)
{ {
list.Add(info); list.Add(info);
} }
@ -1968,7 +1968,7 @@ namespace Jellyfin.Api.Controllers
{ "realTimeInfo.dlna.org", "DLNA.ORG_TLAG=*" } { "realTimeInfo.dlna.org", "DLNA.ORG_TLAG=*" }
}; };
if (!imageInfo.IsLocalFile && item != null) if (!imageInfo.IsLocalFile && item is not null)
{ {
imageInfo = await _libraryManager.ConvertImageToLocal(item, imageInfo, imageIndex ?? 0).ConfigureAwait(false); imageInfo = await _libraryManager.ConvertImageToLocal(item, imageInfo, imageIndex ?? 0).ConfigureAwait(false);
} }

@ -80,13 +80,13 @@ namespace Jellyfin.Api.Controllers
var isLockedChanged = item.IsLocked != newLockData; var isLockedChanged = item.IsLocked != newLockData;
var series = item as Series; var series = item as Series;
var displayOrderChanged = series != null && !string.Equals( var displayOrderChanged = series is not null && !string.Equals(
series.DisplayOrder ?? string.Empty, series.DisplayOrder ?? string.Empty,
request.DisplayOrder ?? string.Empty, request.DisplayOrder ?? string.Empty,
StringComparison.OrdinalIgnoreCase); StringComparison.OrdinalIgnoreCase);
// Do this first so that metadata savers can pull the updates from the database. // Do this first so that metadata savers can pull the updates from the database.
if (request.People != null) if (request.People is not null)
{ {
_libraryManager.UpdatePeople( _libraryManager.UpdatePeople(
item, item,
@ -248,12 +248,12 @@ namespace Jellyfin.Api.Controllers
item.Tags = request.Tags; item.Tags = request.Tags;
if (request.Taglines != null) if (request.Taglines is not null)
{ {
item.Tagline = request.Taglines.FirstOrDefault(); item.Tagline = request.Taglines.FirstOrDefault();
} }
if (request.Studios != null) if (request.Studios is not null)
{ {
item.Studios = request.Studios.Select(x => x.Name).ToArray(); item.Studios = request.Studios.Select(x => x.Name).ToArray();
} }
@ -269,7 +269,7 @@ namespace Jellyfin.Api.Controllers
item.OfficialRating = string.IsNullOrWhiteSpace(request.OfficialRating) ? null : request.OfficialRating; item.OfficialRating = string.IsNullOrWhiteSpace(request.OfficialRating) ? null : request.OfficialRating;
item.CustomRating = request.CustomRating; item.CustomRating = request.CustomRating;
if (request.ProductionLocations != null) if (request.ProductionLocations is not null)
{ {
item.ProductionLocations = request.ProductionLocations; item.ProductionLocations = request.ProductionLocations;
} }
@ -289,7 +289,7 @@ namespace Jellyfin.Api.Controllers
item.IsLocked = request.LockData ?? false; item.IsLocked = request.LockData ?? false;
if (request.LockedFields != null) if (request.LockedFields is not null)
{ {
item.LockedFields = request.LockedFields; item.LockedFields = request.LockedFields;
} }
@ -315,7 +315,7 @@ namespace Jellyfin.Api.Controllers
video.Video3DFormat = request.Video3DFormat; video.Video3DFormat = request.Video3DFormat;
} }
if (request.AlbumArtists != null) if (request.AlbumArtists is not null)
{ {
if (item is IHasAlbumArtist hasAlbumArtists) if (item is IHasAlbumArtist hasAlbumArtists)
{ {
@ -326,7 +326,7 @@ namespace Jellyfin.Api.Controllers
} }
} }
if (request.ArtistItems != null) if (request.ArtistItems is not null)
{ {
if (item is IHasArtist hasArtists) if (item is IHasArtist hasArtists)
{ {
@ -349,7 +349,7 @@ namespace Jellyfin.Api.Controllers
{ {
series.Status = GetSeriesStatus(request); series.Status = GetSeriesStatus(request);
if (request.AirDays != null) if (request.AirDays is not null)
{ {
series.AirDays = request.AirDays; series.AirDays = request.AirDays;
series.AirTime = request.AirTime; series.AirTime = request.AirTime;

@ -447,7 +447,7 @@ namespace Jellyfin.Api.Controllers
{ {
return null; return null;
} }
}).Where(i => i != null).Select(i => i!.Id).ToArray(); }).Where(i => i is not null).Select(i => i!.Id).ToArray();
} }
// ExcludeArtistIds // ExcludeArtistIds
@ -483,7 +483,7 @@ namespace Jellyfin.Api.Controllers
{ {
return null; return null;
} }
}).Where(i => i != null).Select(i => i!.Id).ToArray(); }).Where(i => i is not null).Select(i => i!.Id).ToArray();
} }
// Apply default sorting if none requested // Apply default sorting if none requested
@ -837,7 +837,7 @@ namespace Jellyfin.Api.Controllers
if (excludeActiveSessions) if (excludeActiveSessions)
{ {
excludeItemIds = _sessionManager.Sessions excludeItemIds = _sessionManager.Sessions
.Where(s => s.UserId.Equals(userId) && s.NowPlayingItem != null) .Where(s => s.UserId.Equals(userId) && s.NowPlayingItem is not null)
.Select(s => s.NowPlayingItem.Id) .Select(s => s.NowPlayingItem.Id)
.ToArray(); .ToArray();
} }

@ -449,9 +449,9 @@ namespace Jellyfin.Api.Controllers
var dtoOptions = new DtoOptions().AddClientFields(User); var dtoOptions = new DtoOptions().AddClientFields(User);
BaseItem? parent = item.GetParent(); BaseItem? parent = item.GetParent();
while (parent != null) while (parent is not null)
{ {
if (user != null) if (user is not null)
{ {
parent = TranslateParentItem(parent, user); parent = TranslateParentItem(parent, user);
} }
@ -617,7 +617,7 @@ namespace Jellyfin.Api.Controllers
var user = _userManager.GetUserById(User.GetUserId()); var user = _userManager.GetUserById(User.GetUserId());
if (user != null) if (user is not null)
{ {
if (!item.CanDownload(user)) if (!item.CanDownload(user))
{ {
@ -632,7 +632,7 @@ namespace Jellyfin.Api.Controllers
} }
} }
if (user != null) if (user is not null)
{ {
await LogDownloadAsync(item, user).ConfigureAwait(false); await LogDownloadAsync(item, user).ConfigureAwait(false);
} }
@ -686,8 +686,8 @@ namespace Jellyfin.Api.Controllers
.AddClientFields(User); .AddClientFields(User);
var program = item as IHasProgramAttributes; var program = item as IHasProgramAttributes;
bool? isMovie = item is Movie || (program != null && program.IsMovie) || item is Trailer; bool? isMovie = item is Movie || (program is not null && program.IsMovie) || item is Trailer;
bool? isSeries = item is Series || (program != null && program.IsSeries); bool? isSeries = item is Series || (program is not null && program.IsSeries);
var includeItemTypes = new List<BaseItemKind>(); var includeItemTypes = new List<BaseItemKind>();
if (isMovie.Value) if (isMovie.Value)

@ -82,7 +82,7 @@ namespace Jellyfin.Api.Controllers
{ {
var libraryOptions = libraryOptionsDto?.LibraryOptions ?? new LibraryOptions(); var libraryOptions = libraryOptionsDto?.LibraryOptions ?? new LibraryOptions();
if (paths != null && paths.Length > 0) if (paths is not null && paths.Length > 0)
{ {
libraryOptions.PathInfos = paths.Select(i => new MediaPathInfo(i)).ToArray(); libraryOptions.PathInfos = paths.Select(i => new MediaPathInfo(i)).ToArray();
} }

@ -124,7 +124,7 @@ namespace Jellyfin.Api.Controllers
if (profile is null) if (profile is null)
{ {
var caps = _deviceManager.GetCapabilities(User.GetDeviceId()); var caps = _deviceManager.GetCapabilities(User.GetDeviceId());
if (caps != null) if (caps is not null)
{ {
profile = caps.DeviceProfile; profile = caps.DeviceProfile;
} }
@ -154,12 +154,12 @@ namespace Jellyfin.Api.Controllers
liveStreamId) liveStreamId)
.ConfigureAwait(false); .ConfigureAwait(false);
if (info.ErrorCode != null) if (info.ErrorCode is not null)
{ {
return info; return info;
} }
if (profile != null) if (profile is not null)
{ {
// set device specific data // set device specific data
var item = _libraryManager.GetItemById(itemId); var item = _libraryManager.GetItemById(itemId);
@ -194,7 +194,7 @@ namespace Jellyfin.Api.Controllers
{ {
var mediaSource = string.IsNullOrWhiteSpace(mediaSourceId) ? info.MediaSources[0] : info.MediaSources.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.Ordinal)); var mediaSource = string.IsNullOrWhiteSpace(mediaSourceId) ? info.MediaSources[0] : info.MediaSources.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.Ordinal));
if (mediaSource != null && mediaSource.RequiresOpening && string.IsNullOrWhiteSpace(mediaSource.LiveStreamId)) if (mediaSource is not null && mediaSource.RequiresOpening && string.IsNullOrWhiteSpace(mediaSource.LiveStreamId))
{ {
var openStreamResult = await _mediaInfoHelper.OpenMediaSource( var openStreamResult = await _mediaInfoHelper.OpenMediaSource(
HttpContext, HttpContext,

@ -148,7 +148,7 @@ namespace Jellyfin.Api.Controllers
// Select the un-instanced one first. // Select the un-instanced one first.
var plugin = plugins.FirstOrDefault(p => p.Instance is null) ?? plugins.OrderBy(p => p.Manifest.Status).FirstOrDefault(); var plugin = plugins.FirstOrDefault(p => p.Instance is null) ?? plugins.OrderBy(p => p.Manifest.Status).FirstOrDefault();
if (plugin != null) if (plugin is not null)
{ {
_installationManager.UninstallPlugin(plugin); _installationManager.UninstallPlugin(plugin);
return NoContent(); return NoContent();
@ -202,7 +202,7 @@ namespace Jellyfin.Api.Controllers
var configuration = (BasePluginConfiguration?)await JsonSerializer.DeserializeAsync(Request.Body, configPlugin.ConfigurationType, _serializerOptions) var configuration = (BasePluginConfiguration?)await JsonSerializer.DeserializeAsync(Request.Body, configPlugin.ConfigurationType, _serializerOptions)
.ConfigureAwait(false); .ConfigureAwait(false);
if (configuration != null) if (configuration is not null)
{ {
configPlugin.UpdateConfiguration(configuration); configPlugin.UpdateConfiguration(configuration);
} }
@ -254,7 +254,7 @@ namespace Jellyfin.Api.Controllers
{ {
var plugin = _pluginManager.GetPlugin(pluginId); var plugin = _pluginManager.GetPlugin(pluginId);
if (plugin != null) if (plugin is not null)
{ {
return plugin.Manifest; return plugin.Manifest;
} }

@ -161,7 +161,7 @@ namespace Jellyfin.Api.Controllers
var primaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary); var primaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary);
if (primaryImageTag != null) if (primaryImageTag is not null)
{ {
result.PrimaryImageTag = primaryImageTag; result.PrimaryImageTag = primaryImageTag;
result.PrimaryImageAspectRatio = _dtoService.GetPrimaryImageAspectRatio(item); result.PrimaryImageAspectRatio = _dtoService.GetPrimaryImageAspectRatio(item);
@ -195,7 +195,7 @@ namespace Jellyfin.Api.Controllers
MusicAlbum musicAlbum = song.AlbumEntity; MusicAlbum musicAlbum = song.AlbumEntity;
if (musicAlbum != null) if (musicAlbum is not null)
{ {
result.Album = musicAlbum.Name; result.Album = musicAlbum.Name;
result.AlbumId = musicAlbum.Id; result.AlbumId = musicAlbum.Id;
@ -228,11 +228,11 @@ namespace Jellyfin.Api.Controllers
itemWithImage ??= GetParentWithImage<BaseItem>(item, ImageType.Thumb); itemWithImage ??= GetParentWithImage<BaseItem>(item, ImageType.Thumb);
if (itemWithImage != null) if (itemWithImage is not null)
{ {
var tag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Thumb); var tag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Thumb);
if (tag != null) if (tag is not null)
{ {
hint.ThumbImageTag = tag; hint.ThumbImageTag = tag;
hint.ThumbImageItemId = itemWithImage.Id.ToString("N", CultureInfo.InvariantCulture); hint.ThumbImageItemId = itemWithImage.Id.ToString("N", CultureInfo.InvariantCulture);
@ -245,11 +245,11 @@ namespace Jellyfin.Api.Controllers
var itemWithImage = (item.HasImage(ImageType.Backdrop) ? item : null) var itemWithImage = (item.HasImage(ImageType.Backdrop) ? item : null)
?? GetParentWithImage<BaseItem>(item, ImageType.Backdrop); ?? GetParentWithImage<BaseItem>(item, ImageType.Backdrop);
if (itemWithImage != null) if (itemWithImage is not null)
{ {
var tag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Backdrop); var tag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Backdrop);
if (tag != null) if (tag is not null)
{ {
hint.BackdropImageTag = tag; hint.BackdropImageTag = tag;
hint.BackdropImageItemId = itemWithImage.Id.ToString("N", CultureInfo.InvariantCulture); hint.BackdropImageItemId = itemWithImage.Id.ToString("N", CultureInfo.InvariantCulture);

@ -132,7 +132,7 @@ namespace Jellyfin.Api.Controllers
{ {
var user = _userManager.Users.First(); var user = _userManager.Users.First();
if (startupUserDto.Name != null) if (startupUserDto.Name is not null)
{ {
user.Username = startupUserDto.Name; user.Username = startupUserDto.Name;
} }

@ -522,7 +522,7 @@ namespace Jellyfin.Api.Controllers
.First(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)); .First(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
var fileSize = fontFile?.Length; var fileSize = fontFile?.Length;
if (fontFile != null && fileSize != null && fileSize > 0) if (fontFile is not null && fileSize is not null && fileSize > 0)
{ {
_logger.LogDebug("Fallback font size is {FileSize} Bytes", fileSize); _logger.LogDebug("Fallback font size is {FileSize} Bytes", fileSize);
return PhysicalFile(fontFile.FullName, MimeTypes.GetMimeType(fontFile.FullName)); return PhysicalFile(fontFile.FullName, MimeTypes.GetMimeType(fontFile.FullName));

@ -477,7 +477,7 @@ namespace Jellyfin.Api.Controllers
var newUser = await _userManager.CreateUserAsync(request.Name).ConfigureAwait(false); var newUser = await _userManager.CreateUserAsync(request.Name).ConfigureAwait(false);
// no need to authenticate password for new user // no need to authenticate password for new user
if (request.Password != null) if (request.Password is not null)
{ {
await _userManager.ChangePassword(newUser, request.Password).ConfigureAwait(false); await _userManager.ChangePassword(newUser, request.Password).ConfigureAwait(false);
} }

@ -306,7 +306,7 @@ namespace Jellyfin.Api.Controllers
var item = i.Item2[0]; var item = i.Item2[0];
var childCount = 0; var childCount = 0;
if (i.Item1 != null && (i.Item2.Count > 1 || i.Item1 is MusicAlbum)) if (i.Item1 is not null && (i.Item2.Count > 1 || i.Item1 is MusicAlbum))
{ {
item = i.Item1; item = i.Item1;
childCount = i.Item2.Count; childCount = i.Item2.Count;

@ -439,7 +439,7 @@ namespace Jellyfin.Api.Controllers
cancellationTokenSource.Token) cancellationTokenSource.Token)
.ConfigureAwait(false); .ConfigureAwait(false);
if (@static.HasValue && @static.Value && state.DirectStreamProvider != null) if (@static.HasValue && @static.Value && state.DirectStreamProvider is not null)
{ {
StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, state.Request.StartTimeTicks, Request, _dlnaManager); StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, state.Request.StartTimeTicks, Request, _dlnaManager);
@ -472,7 +472,7 @@ namespace Jellyfin.Api.Controllers
var outputPathExists = System.IO.File.Exists(outputPath); var outputPathExists = System.IO.File.Exists(outputPath);
var transcodingJob = _transcodingJobHelper.GetTranscodingJob(outputPath, TranscodingJobType.Progressive); var transcodingJob = _transcodingJobHelper.GetTranscodingJob(outputPath, TranscodingJobType.Progressive);
var isTranscodeCached = outputPathExists && transcodingJob != null; var isTranscodeCached = outputPathExists && transcodingJob is not null;
StreamingHelpers.AddDlnaHeaders(state, Response.Headers, (@static.HasValue && @static.Value) || isTranscodeCached, state.Request.StartTimeTicks, Request, _dlnaManager); StreamingHelpers.AddDlnaHeaders(state, Response.Headers, (@static.HasValue && @static.Value) || isTranscodeCached, state.Request.StartTimeTicks, Request, _dlnaManager);

@ -152,7 +152,7 @@ namespace Jellyfin.Api.Controllers
var result = new QueryResult<BaseItemDto>( var result = new QueryResult<BaseItemDto>(
startIndex, startIndex,
ibnItemsArray.Count, ibnItemsArray.Count,
dtos.Where(i => i != null).ToArray()); dtos.Where(i => i is not null).ToArray());
return result; return result;
} }

@ -111,7 +111,7 @@ namespace Jellyfin.Api.Helpers
cancellationTokenSource.Token) cancellationTokenSource.Token)
.ConfigureAwait(false); .ConfigureAwait(false);
if (streamingRequest.Static && state.DirectStreamProvider != null) if (streamingRequest.Static && state.DirectStreamProvider is not null)
{ {
StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, true, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager); StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, true, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager);
@ -144,7 +144,7 @@ namespace Jellyfin.Api.Helpers
var outputPathExists = File.Exists(outputPath); var outputPathExists = File.Exists(outputPath);
var transcodingJob = _transcodingJobHelper.GetTranscodingJob(outputPath, TranscodingJobType.Progressive); var transcodingJob = _transcodingJobHelper.GetTranscodingJob(outputPath, TranscodingJobType.Progressive);
var isTranscodeCached = outputPathExists && transcodingJob != null; var isTranscodeCached = outputPathExists && transcodingJob is not null;
StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, streamingRequest.Static || isTranscodeCached, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager); StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, streamingRequest.Static || isTranscodeCached, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save