aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Api/Controllers')
-rw-r--r--Jellyfin.Api/Controllers/ArtistsController.cs4
-rw-r--r--Jellyfin.Api/Controllers/ConfigurationController.cs2
-rw-r--r--Jellyfin.Api/Controllers/DashboardController.cs4
-rw-r--r--Jellyfin.Api/Controllers/DevicesController.cs6
-rw-r--r--Jellyfin.Api/Controllers/DisplayPreferencesController.cs2
-rw-r--r--Jellyfin.Api/Controllers/DlnaController.cs6
-rw-r--r--Jellyfin.Api/Controllers/DlnaServerController.cs2
-rw-r--r--Jellyfin.Api/Controllers/DynamicHlsController.cs26
-rw-r--r--Jellyfin.Api/Controllers/EnvironmentController.cs2
-rw-r--r--Jellyfin.Api/Controllers/FilterController.cs10
-rw-r--r--Jellyfin.Api/Controllers/HlsSegmentController.cs4
-rw-r--r--Jellyfin.Api/Controllers/ImageByNameController.cs252
-rw-r--r--Jellyfin.Api/Controllers/ImageController.cs69
-rw-r--r--Jellyfin.Api/Controllers/ItemLookupController.cs2
-rw-r--r--Jellyfin.Api/Controllers/ItemRefreshController.cs2
-rw-r--r--Jellyfin.Api/Controllers/ItemUpdateController.cs22
-rw-r--r--Jellyfin.Api/Controllers/ItemsController.cs6
-rw-r--r--Jellyfin.Api/Controllers/LibraryController.cs59
-rw-r--r--Jellyfin.Api/Controllers/LibraryStructureController.cs2
-rw-r--r--Jellyfin.Api/Controllers/LiveTvController.cs6
-rw-r--r--Jellyfin.Api/Controllers/MediaInfoController.cs10
-rw-r--r--Jellyfin.Api/Controllers/MoviesController.cs6
-rw-r--r--Jellyfin.Api/Controllers/NotificationsController.cs87
-rw-r--r--Jellyfin.Api/Controllers/PackageController.cs4
-rw-r--r--Jellyfin.Api/Controllers/PersonsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/PlaylistsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/PlaystateController.cs2
-rw-r--r--Jellyfin.Api/Controllers/PluginsController.cs18
-rw-r--r--Jellyfin.Api/Controllers/QuickConnectController.cs26
-rw-r--r--Jellyfin.Api/Controllers/RemoteImageController.cs6
-rw-r--r--Jellyfin.Api/Controllers/ScheduledTasksController.cs8
-rw-r--r--Jellyfin.Api/Controllers/SearchController.cs14
-rw-r--r--Jellyfin.Api/Controllers/SessionController.cs5
-rw-r--r--Jellyfin.Api/Controllers/StartupController.cs2
-rw-r--r--Jellyfin.Api/Controllers/SubtitleController.cs4
-rw-r--r--Jellyfin.Api/Controllers/TvShowsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/UserController.cs24
-rw-r--r--Jellyfin.Api/Controllers/UserLibraryController.cs6
-rw-r--r--Jellyfin.Api/Controllers/UserViewsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/VideoAttachmentsController.cs2
-rw-r--r--Jellyfin.Api/Controllers/VideosController.cs10
-rw-r--r--Jellyfin.Api/Controllers/YearsController.cs4
42 files changed, 195 insertions, 539 deletions
diff --git a/Jellyfin.Api/Controllers/ArtistsController.cs b/Jellyfin.Api/Controllers/ArtistsController.cs
index c059cb198a..c8ac2ed526 100644
--- a/Jellyfin.Api/Controllers/ArtistsController.cs
+++ b/Jellyfin.Api/Controllers/ArtistsController.cs
@@ -183,7 +183,7 @@ namespace Jellyfin.Api.Controllers
{
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)
@@ -386,7 +386,7 @@ namespace Jellyfin.Api.Controllers
{
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)
diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs
index bbe1633120..a00ac1b0af 100644
--- a/Jellyfin.Api/Controllers/ConfigurationController.cs
+++ b/Jellyfin.Api/Controllers/ConfigurationController.cs
@@ -96,7 +96,7 @@ namespace Jellyfin.Api.Controllers
var configurationType = _configurationManager.GetConfigurationType(key);
var deserializedConfiguration = configuration.Deserialize(configurationType, _serializerOptions);
- if (deserializedConfiguration == null)
+ if (deserializedConfiguration is null)
{
throw new ArgumentException("Body doesn't contain a valid configuration");
}
diff --git a/Jellyfin.Api/Controllers/DashboardController.cs b/Jellyfin.Api/Controllers/DashboardController.cs
index c8411f44ba..3894e6c5fc 100644
--- a/Jellyfin.Api/Controllers/DashboardController.cs
+++ b/Jellyfin.Api/Controllers/DashboardController.cs
@@ -76,7 +76,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult GetDashboardConfigurationPage([FromQuery] string? name)
{
var altPage = GetPluginPages().FirstOrDefault(p => string.Equals(p.Item1.Name, name, StringComparison.OrdinalIgnoreCase));
- if (altPage == null)
+ if (altPage is null)
{
return NotFound();
}
@@ -84,7 +84,7 @@ namespace Jellyfin.Api.Controllers
IPlugin plugin = altPage.Item2;
string resourcePath = altPage.Item1.EmbeddedResourcePath;
Stream? stream = plugin.GetType().Assembly.GetManifestResourceStream(resourcePath);
- if (stream == null)
+ if (stream is null)
{
_logger.LogError("Failed to get resource {Resource} from plugin {Plugin}", resourcePath, plugin.Name);
return NotFound();
diff --git a/Jellyfin.Api/Controllers/DevicesController.cs b/Jellyfin.Api/Controllers/DevicesController.cs
index 8292cf83b5..aad60cf5cc 100644
--- a/Jellyfin.Api/Controllers/DevicesController.cs
+++ b/Jellyfin.Api/Controllers/DevicesController.cs
@@ -64,7 +64,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult<DeviceInfo>> GetDeviceInfo([FromQuery, Required] string id)
{
var deviceInfo = await _deviceManager.GetDevice(id).ConfigureAwait(false);
- if (deviceInfo == null)
+ if (deviceInfo is null)
{
return NotFound();
}
@@ -85,7 +85,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult<DeviceOptions>> GetDeviceOptions([FromQuery, Required] string id)
{
var deviceInfo = await _deviceManager.GetDeviceOptions(id).ConfigureAwait(false);
- if (deviceInfo == null)
+ if (deviceInfo is null)
{
return NotFound();
}
@@ -123,7 +123,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult> DeleteDevice([FromQuery, Required] string id)
{
var existingDevice = await _deviceManager.GetDevice(id).ConfigureAwait(false);
- if (existingDevice == null)
+ if (existingDevice is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
index 64ee5680ce..67cceb4a8c 100644
--- a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
+++ b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
@@ -178,7 +178,7 @@ namespace Jellyfin.Api.Controllers
foreach (var key in displayPreferences.CustomPrefs.Keys.Where(key => key.StartsWith("homesection", StringComparison.OrdinalIgnoreCase)))
{
- var order = int.Parse(key.AsSpan().Slice("homesection".Length));
+ var order = int.Parse(key.AsSpan().Slice("homesection".Length), CultureInfo.InvariantCulture);
if (!Enum.TryParse<HomeSectionType>(displayPreferences.CustomPrefs[key], true, out var type))
{
type = order < 8 ? defaults[order] : HomeSectionType.None;
diff --git a/Jellyfin.Api/Controllers/DlnaController.cs b/Jellyfin.Api/Controllers/DlnaController.cs
index 35c3a3d922..07e0590a10 100644
--- a/Jellyfin.Api/Controllers/DlnaController.cs
+++ b/Jellyfin.Api/Controllers/DlnaController.cs
@@ -63,7 +63,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<DeviceProfile> GetProfile([FromRoute, Required] string profileId)
{
var profile = _dlnaManager.GetProfile(profileId);
- if (profile == null)
+ if (profile is null)
{
return NotFound();
}
@@ -84,7 +84,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult DeleteProfile([FromRoute, Required] string profileId)
{
var existingDeviceProfile = _dlnaManager.GetProfile(profileId);
- if (existingDeviceProfile == null)
+ if (existingDeviceProfile is null)
{
return NotFound();
}
@@ -121,7 +121,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult UpdateProfile([FromRoute, Required] string profileId, [FromBody] DeviceProfile deviceProfile)
{
var existingDeviceProfile = _dlnaManager.GetProfile(profileId);
- if (existingDeviceProfile == null)
+ if (existingDeviceProfile is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/DlnaServerController.cs b/Jellyfin.Api/Controllers/DlnaServerController.cs
index 8859d60207..96c492b3ec 100644
--- a/Jellyfin.Api/Controllers/DlnaServerController.cs
+++ b/Jellyfin.Api/Controllers/DlnaServerController.cs
@@ -274,7 +274,7 @@ namespace Jellyfin.Api.Controllers
private ActionResult GetIconInternal(string fileName)
{
var icon = _dlnaManager.GetIcon(fileName);
- if (icon == null)
+ if (icon is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs
index 0f4d3c1ebc..af43bb578e 100644
--- a/Jellyfin.Api/Controllers/DynamicHlsController.cs
+++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs
@@ -341,7 +341,7 @@ namespace Jellyfin.Api.Controllers
job ??= _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
- if (job != null)
+ if (job is not null)
{
_transcodingJobHelper.OnTranscodeEndRequest(job);
}
@@ -1482,7 +1482,7 @@ namespace Jellyfin.Api.Controllers
startTranscoding = true;
segmentId = 0;
}
- else if (currentTranscodingIndex == null)
+ else if (currentTranscodingIndex is null)
{
_logger.LogDebug("Starting transcoding because currentTranscodingIndex=null");
startTranscoding = true;
@@ -1533,7 +1533,7 @@ namespace Jellyfin.Api.Controllers
else
{
job = _transcodingJobHelper.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
- if (job?.TranscodingThrottler != null)
+ if (job?.TranscodingThrottler is not null)
{
await job.TranscodingThrottler.UnpauseTranscoding().ConfigureAwait(false);
}
@@ -1665,7 +1665,7 @@ namespace Jellyfin.Api.Controllers
/// <returns>The command line arguments for audio transcoding.</returns>
private string GetAudioArguments(StreamState state)
{
- if (state.AudioStream == null)
+ if (state.AudioStream is null)
{
return string.Empty;
}
@@ -1762,7 +1762,7 @@ namespace Jellyfin.Api.Controllers
/// <returns>The command line arguments for video transcoding.</returns>
private string GetVideoArguments(StreamState state, int startNumber, bool isEventPlaylist)
{
- if (state.VideoStream == null)
+ if (state.VideoStream is null)
{
return string.Empty;
}
@@ -1806,7 +1806,7 @@ namespace Jellyfin.Api.Controllers
if (EncodingHelper.IsCopyCodec(codec))
{
// 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);
if (!string.IsNullOrEmpty(bitStreamArgs))
@@ -1837,7 +1837,7 @@ namespace Jellyfin.Api.Controllers
// -start_at_zero is necessary to use with -ss when seeking,
// 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
if (!(state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream))
@@ -1883,7 +1883,7 @@ namespace Jellyfin.Api.Controllers
var segmentExists = System.IO.File.Exists(segmentPath);
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
_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);
- if (transcodingJob != null)
+ if (transcodingJob is not null)
{
while (!cancellationToken.IsCancellationRequested && !transcodingJob.HasExited)
{
@@ -1953,7 +1953,7 @@ namespace Jellyfin.Api.Controllers
Response.OnCompleted(() =>
{
_logger.LogDebug("Finished serving {SegmentPath}", segmentPath);
- if (transcodingJob != null)
+ if (transcodingJob is not null)
{
transcodingJob.DownloadPositionTicks = Math.Max(transcodingJob.DownloadPositionTicks ?? segmentEndingPositionTicks, segmentEndingPositionTicks);
_transcodingJobHelper.OnTranscodeEndRequest(transcodingJob);
@@ -1969,14 +1969,14 @@ namespace Jellyfin.Api.Controllers
{
var job = _transcodingJobHelper.GetTranscodingJob(playlist, TranscodingJobType);
- if (job == null || job.HasExited)
+ if (job is null || job.HasExited)
{
return null;
}
var file = GetLastTranscodingFile(playlist, segmentExtension, _fileSystem);
- if (file == null)
+ if (file is null)
{
return null;
}
@@ -2011,7 +2011,7 @@ namespace Jellyfin.Api.Controllers
{
var file = GetLastTranscodingFile(playlistPath, segmentExtension, _fileSystem);
- if (file != null)
+ if (file is not null)
{
DeleteFile(file.FullName, retryCount);
}
diff --git a/Jellyfin.Api/Controllers/EnvironmentController.cs b/Jellyfin.Api/Controllers/EnvironmentController.cs
index b0b4b5af51..6c78a79875 100644
--- a/Jellyfin.Api/Controllers/EnvironmentController.cs
+++ b/Jellyfin.Api/Controllers/EnvironmentController.cs
@@ -104,7 +104,7 @@ namespace Jellyfin.Api.Controllers
if (validatePathDto.ValidateWritable)
{
- if (validatePathDto.Path == null)
+ if (validatePathDto.Path is null)
{
throw new ResourceNotFoundException(nameof(validatePathDto.Path));
}
diff --git a/Jellyfin.Api/Controllers/FilterController.cs b/Jellyfin.Api/Controllers/FilterController.cs
index 11808b1b82..17d136384e 100644
--- a/Jellyfin.Api/Controllers/FilterController.cs
+++ b/Jellyfin.Api/Controllers/FilterController.cs
@@ -92,25 +92,25 @@ namespace Jellyfin.Api.Controllers
Years = itemList.Select(i => i.ProductionYear ?? -1)
.Where(i => i > 0)
.Distinct()
- .OrderBy(i => i)
+ .Order()
.ToArray(),
Genres = itemList.SelectMany(i => i.Genres)
.DistinctNames()
- .OrderBy(i => i)
+ .Order()
.ToArray(),
Tags = itemList
.SelectMany(i => i.Tags)
.Distinct(StringComparer.OrdinalIgnoreCase)
- .OrderBy(i => i)
+ .Order()
.ToArray(),
OfficialRatings = itemList
.Select(i => i.OfficialRating)
.Where(i => !string.IsNullOrWhiteSpace(i))
.Distinct(StringComparer.OrdinalIgnoreCase)
- .OrderBy(i => i)
+ .Order()
.ToArray()
};
}
@@ -182,7 +182,7 @@ namespace Jellyfin.Api.Controllers
if ((recursive ?? true) || parentItem is UserView || parentItem is ICollectionFolder)
{
- genreQuery.AncestorIds = parentItem == null ? Array.Empty<Guid>() : new[] { parentItem.Id };
+ genreQuery.AncestorIds = parentItem is null ? Array.Empty<Guid>() : new[] { parentItem.Id };
}
else
{
diff --git a/Jellyfin.Api/Controllers/HlsSegmentController.cs b/Jellyfin.Api/Controllers/HlsSegmentController.cs
index 78634f0bfc..50fee233a8 100644
--- a/Jellyfin.Api/Controllers/HlsSegmentController.cs
+++ b/Jellyfin.Api/Controllers/HlsSegmentController.cs
@@ -167,7 +167,7 @@ namespace Jellyfin.Api.Controllers
}
}
- return playlistPath == null
+ return playlistPath is null
? NotFound("Hls segment not found.")
: GetFileResult(file, playlistPath);
}
@@ -178,7 +178,7 @@ namespace Jellyfin.Api.Controllers
Response.OnCompleted(() =>
{
- if (transcodingJob != null)
+ if (transcodingJob is not null)
{
_transcodingJobHelper.OnTranscodeEndRequest(transcodingJob);
}
diff --git a/Jellyfin.Api/Controllers/ImageByNameController.cs b/Jellyfin.Api/Controllers/ImageByNameController.cs
deleted file mode 100644
index 89bbf22c96..0000000000
--- a/Jellyfin.Api/Controllers/ImageByNameController.cs
+++ /dev/null
@@ -1,252 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.IO;
-using System.Linq;
-using System.Net.Mime;
-using Jellyfin.Api.Attributes;
-using Jellyfin.Api.Constants;
-using MediaBrowser.Controller;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Net;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Jellyfin.Api.Controllers
-{
- /// <summary>
- /// Images By Name Controller.
- /// </summary>
- [Route("Images")]
- public class ImageByNameController : BaseJellyfinApiController
- {
- private readonly IServerApplicationPaths _applicationPaths;
- private readonly IFileSystem _fileSystem;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ImageByNameController" /> class.
- /// </summary>
- /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager" /> interface.</param>
- /// <param name="fileSystem">Instance of the <see cref="IFileSystem" /> interface.</param>
- public ImageByNameController(
- IServerConfigurationManager serverConfigurationManager,
- IFileSystem fileSystem)
- {
- _applicationPaths = serverConfigurationManager.ApplicationPaths;
- _fileSystem = fileSystem;
- }
-
- /// <summary>
- /// Get all general images.
- /// </summary>
- /// <response code="200">Retrieved list of images.</response>
- /// <returns>An <see cref="OkResult"/> containing the list of images.</returns>
- [HttpGet("General")]
- [Authorize(Policy = Policies.DefaultAuthorization)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult<IEnumerable<ImageByNameInfo>> GetGeneralImages()
- {
- return GetImageList(_applicationPaths.GeneralPath, false);
- }
-
- /// <summary>
- /// Get General Image.
- /// </summary>
- /// <param name="name">The name of the image.</param>
- /// <param name="type">Image Type (primary, backdrop, logo, etc).</param>
- /// <response code="200">Image stream retrieved.</response>
- /// <response code="404">Image not found.</response>
- /// <returns>A <see cref="FileStreamResult"/> containing the image contents on success, or a <see cref="NotFoundResult"/> if the image could not be found.</returns>
- [HttpGet("General/{name}/{type}")]
- [AllowAnonymous]
- [Produces(MediaTypeNames.Application.Octet)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [ProducesImageFile]
- public ActionResult GetGeneralImage([FromRoute, Required] string name, [FromRoute, Required] string type)
- {
- var filename = string.Equals(type, "primary", StringComparison.OrdinalIgnoreCase)
- ? "folder"
- : type;
-
- var path = BaseItem.SupportedImageExtensions
- .Select(i => Path.GetFullPath(Path.Combine(_applicationPaths.GeneralPath, name, filename + i)))
- .FirstOrDefault(System.IO.File.Exists);
-
- if (path == null)
- {
- return NotFound();
- }
-
- if (!path.StartsWith(_applicationPaths.GeneralPath, StringComparison.InvariantCulture))
- {
- return BadRequest("Invalid image path.");
- }
-
- var contentType = MimeTypes.GetMimeType(path);
- return File(AsyncFile.OpenRead(path), contentType);
- }
-
- /// <summary>
- /// Get all general images.
- /// </summary>
- /// <response code="200">Retrieved list of images.</response>
- /// <returns>An <see cref="OkResult"/> containing the list of images.</returns>
- [HttpGet("Ratings")]
- [Authorize(Policy = Policies.DefaultAuthorization)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult<IEnumerable<ImageByNameInfo>> GetRatingImages()
- {
- return GetImageList(_applicationPaths.RatingsPath, false);
- }
-
- /// <summary>
- /// Get rating image.
- /// </summary>
- /// <param name="theme">The theme to get the image from.</param>
- /// <param name="name">The name of the image.</param>
- /// <response code="200">Image stream retrieved.</response>
- /// <response code="404">Image not found.</response>
- /// <returns>A <see cref="FileStreamResult"/> containing the image contents on success, or a <see cref="NotFoundResult"/> if the image could not be found.</returns>
- [HttpGet("Ratings/{theme}/{name}")]
- [AllowAnonymous]
- [Produces(MediaTypeNames.Application.Octet)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [ProducesImageFile]
- public ActionResult GetRatingImage(
- [FromRoute, Required] string theme,
- [FromRoute, Required] string name)
- {
- return GetImageFile(_applicationPaths.RatingsPath, theme, name);
- }
-
- /// <summary>
- /// Get all media info images.
- /// </summary>
- /// <response code="200">Image list retrieved.</response>
- /// <returns>An <see cref="OkResult"/> containing the list of images.</returns>
- [HttpGet("MediaInfo")]
- [Authorize(Policy = Policies.DefaultAuthorization)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult<IEnumerable<ImageByNameInfo>> GetMediaInfoImages()
- {
- return GetImageList(_applicationPaths.MediaInfoImagesPath, false);
- }
-
- /// <summary>
- /// Get media info image.
- /// </summary>
- /// <param name="theme">The theme to get the image from.</param>
- /// <param name="name">The name of the image.</param>
- /// <response code="200">Image stream retrieved.</response>
- /// <response code="404">Image not found.</response>
- /// <returns>A <see cref="FileStreamResult"/> containing the image contents on success, or a <see cref="NotFoundResult"/> if the image could not be found.</returns>
- [HttpGet("MediaInfo/{theme}/{name}")]
- [AllowAnonymous]
- [Produces(MediaTypeNames.Application.Octet)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- [ProducesImageFile]
- public ActionResult GetMediaInfoImage(
- [FromRoute, Required] string theme,
- [FromRoute, Required] string name)
- {
- return GetImageFile(_applicationPaths.MediaInfoImagesPath, theme, name);
- }
-
- /// <summary>
- /// Internal FileHelper.
- /// </summary>
- /// <param name="basePath">Path to begin search.</param>
- /// <param name="theme">Theme to search.</param>
- /// <param name="name">File name to search for.</param>
- /// <returns>A <see cref="FileStreamResult"/> containing the image contents on success, or a <see cref="NotFoundResult"/> if the image could not be found.</returns>
- private ActionResult GetImageFile(string basePath, string theme, string? name)
- {
- var themeFolder = Path.GetFullPath(Path.Combine(basePath, theme));
-
- if (Directory.Exists(themeFolder))
- {
- var path = BaseItem.SupportedImageExtensions.Select(i => Path.Combine(themeFolder, name + i))
- .FirstOrDefault(System.IO.File.Exists);
-
- if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path))
- {
- if (!path.StartsWith(basePath, StringComparison.InvariantCulture))
- {
- return BadRequest("Invalid image path.");
- }
-
- var contentType = MimeTypes.GetMimeType(path);
-
- return PhysicalFile(path, contentType);
- }
- }
-
- var allFolder = Path.GetFullPath(Path.Combine(basePath, "all"));
- if (Directory.Exists(allFolder))
- {
- var path = BaseItem.SupportedImageExtensions.Select(i => Path.Combine(allFolder, name + i))
- .FirstOrDefault(System.IO.File.Exists);
-
- if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path))
- {
- if (!path.StartsWith(basePath, StringComparison.InvariantCulture))
- {
- return BadRequest("Invalid image path.");
- }
-
- var contentType = MimeTypes.GetMimeType(path);
- return PhysicalFile(path, contentType);
- }
- }
-
- return NotFound();
- }
-
- private List<ImageByNameInfo> GetImageList(string path, bool supportsThemes)
- {
- try
- {
- return _fileSystem.GetFiles(path, BaseItem.SupportedImageExtensions, false, true)
- .Select(i => new ImageByNameInfo
- {
- Name = _fileSystem.GetFileNameWithoutExtension(i),
- FileLength = i.Length,
-
- // For themeable images, use the Theme property
- // For general images, the same object structure is fine,
- // but it's not owned by a theme, so call it Context
- Theme = supportsThemes ? GetThemeName(i.FullName, path) : null,
- Context = supportsThemes ? null : GetThemeName(i.FullName, path),
- Format = i.Extension.ToLowerInvariant().TrimStart('.')
- })
- .OrderBy(i => i.Name)
- .ToList();
- }
- catch (IOException)
- {
- return new List<ImageByNameInfo>();
- }
- }
-
- private string? GetThemeName(string path, string rootImagePath)
- {
- var parentName = Path.GetDirectoryName(path);
-
- if (string.Equals(parentName, rootImagePath, StringComparison.OrdinalIgnoreCase))
- {
- return null;
- }
-
- parentName = Path.GetFileName(parentName);
-
- return string.Equals(parentName, "all", StringComparison.OrdinalIgnoreCase) ? null : parentName;
- }
- }
-}
diff --git a/Jellyfin.Api/Controllers/ImageController.cs b/Jellyfin.Api/Controllers/ImageController.cs
index f092bd8820..49342ad5ce 100644
--- a/Jellyfin.Api/Controllers/ImageController.cs
+++ b/Jellyfin.Api/Controllers/ImageController.cs
@@ -28,6 +28,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
namespace Jellyfin.Api.Controllers
@@ -110,7 +111,7 @@ namespace Jellyfin.Api.Controllers
// Handle image/png; charset=utf-8
var mimeType = Request.ContentType?.Split(';').FirstOrDefault();
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);
}
@@ -157,7 +158,7 @@ namespace Jellyfin.Api.Controllers
// Handle image/png; charset=utf-8
var mimeType = Request.ContentType?.Split(';').FirstOrDefault();
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);
}
@@ -198,7 +199,7 @@ namespace Jellyfin.Api.Controllers
}
var user = _userManager.GetUserById(userId);
- if (user?.ProfileImage == null)
+ if (user?.ProfileImage is null)
{
return NoContent();
}
@@ -242,7 +243,7 @@ namespace Jellyfin.Api.Controllers
}
var user = _userManager.GetUserById(userId);
- if (user?.ProfileImage == null)
+ if (user?.ProfileImage is null)
{
return NoContent();
}
@@ -279,7 +280,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -307,7 +308,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute] int imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -335,7 +336,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute, Required] ImageType imageType)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -371,7 +372,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute] int imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -407,7 +408,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery, Required] int newIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -430,7 +431,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult<IEnumerable<ImageInfo>>> GetItemImageInfos([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -452,7 +453,7 @@ namespace Jellyfin.Api.Controllers
{
var info = GetImageInfo(item, image, null);
- if (info != null)
+ if (info is not null)
{
list.Add(info);
}
@@ -470,7 +471,7 @@ namespace Jellyfin.Api.Controllers
{
var info = GetImageInfo(item, image, index);
- if (info != null)
+ if (info is not null)
{
list.Add(info);
}
@@ -537,7 +538,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -620,7 +621,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -703,7 +704,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute, Required] int imageIndex)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -786,7 +787,7 @@ namespace Jellyfin.Api.Controllers
[FromRoute, Required] int imageIndex)
{
var item = _libraryManager.GetArtist(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -869,7 +870,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetGenre(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -952,7 +953,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetGenre(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1035,7 +1036,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetMusicGenre(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1118,7 +1119,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetMusicGenre(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1201,7 +1202,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetPerson(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1284,7 +1285,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetPerson(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1367,7 +1368,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var item = _libraryManager.GetStudio(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1450,7 +1451,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var item = _libraryManager.GetStudio(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -1533,7 +1534,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? imageIndex)
{
var user = _userManager.GetUserById(userId);
- if (user?.ProfileImage == null)
+ if (user?.ProfileImage is null)
{
return NotFound();
}
@@ -1634,7 +1635,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? foregroundLayer)
{
var user = _userManager.GetUserById(userId);
- if (user?.ProfileImage == null)
+ if (user?.ProfileImage is null)
{
return NotFound();
}
@@ -1944,10 +1945,10 @@ namespace Jellyfin.Api.Controllers
unplayedCount = null;
}
- if (imageInfo == null)
+ if (imageInfo is null)
{
imageInfo = item?.GetImageInfo(imageType, imageIndex ?? 0);
- if (imageInfo == null)
+ if (imageInfo is null)
{
return NotFound(string.Format(NumberFormatInfo.InvariantInfo, "{0} does not have an image of type {1}", item?.Name, imageType));
}
@@ -1968,7 +1969,7 @@ namespace Jellyfin.Api.Controllers
{ "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);
}
@@ -2026,8 +2027,13 @@ namespace Jellyfin.Api.Controllers
}
var acceptParam = Request.Query[HeaderNames.Accept];
+ if (StringValues.IsNullOrEmpty(acceptParam))
+ {
+ return Array.Empty<ImageFormat>();
+ }
- var supportsWebP = SupportsFormat(supportedFormats, acceptParam, ImageFormat.Webp, false);
+ // Can't be null, checked above
+ var supportsWebP = SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Webp, false);
if (!supportsWebP)
{
@@ -2049,7 +2055,8 @@ namespace Jellyfin.Api.Controllers
formats.Add(ImageFormat.Jpg);
formats.Add(ImageFormat.Png);
- if (SupportsFormat(supportedFormats, acceptParam, ImageFormat.Gif, true))
+ // Can't be null, checked above
+ if (SupportsFormat(supportedFormats, acceptParam!, ImageFormat.Gif, true))
{
formats.Add(ImageFormat.Gif);
}
diff --git a/Jellyfin.Api/Controllers/ItemLookupController.cs b/Jellyfin.Api/Controllers/ItemLookupController.cs
index c49f856169..34893d682d 100644
--- a/Jellyfin.Api/Controllers/ItemLookupController.cs
+++ b/Jellyfin.Api/Controllers/ItemLookupController.cs
@@ -65,7 +65,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<IEnumerable<ExternalIdInfo>> GetExternalIdInfos([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/ItemRefreshController.cs b/Jellyfin.Api/Controllers/ItemRefreshController.cs
index 9340737b50..0dc3fbd05a 100644
--- a/Jellyfin.Api/Controllers/ItemRefreshController.cs
+++ b/Jellyfin.Api/Controllers/ItemRefreshController.cs
@@ -61,7 +61,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] bool replaceAllImages = false)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/ItemUpdateController.cs b/Jellyfin.Api/Controllers/ItemUpdateController.cs
index fd137f98f1..af3d779f56 100644
--- a/Jellyfin.Api/Controllers/ItemUpdateController.cs
+++ b/Jellyfin.Api/Controllers/ItemUpdateController.cs
@@ -71,7 +71,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult> UpdateItem([FromRoute, Required] Guid itemId, [FromBody, Required] BaseItemDto request)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -80,13 +80,13 @@ namespace Jellyfin.Api.Controllers
var isLockedChanged = item.IsLocked != newLockData;
var series = item as Series;
- var displayOrderChanged = series != null && !string.Equals(
+ var displayOrderChanged = series is not null && !string.Equals(
series.DisplayOrder ?? string.Empty,
request.DisplayOrder ?? string.Empty,
StringComparison.OrdinalIgnoreCase);
// 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(
item,
@@ -198,7 +198,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult UpdateItemContentType([FromRoute, Required] Guid itemId, [FromQuery] string? contentType)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -248,12 +248,12 @@ namespace Jellyfin.Api.Controllers
item.Tags = request.Tags;
- if (request.Taglines != null)
+ if (request.Taglines is not null)
{
item.Tagline = request.Taglines.FirstOrDefault();
}
- if (request.Studios != null)
+ if (request.Studios is not null)
{
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.CustomRating = request.CustomRating;
- if (request.ProductionLocations != null)
+ if (request.ProductionLocations is not null)
{
item.ProductionLocations = request.ProductionLocations;
}
@@ -289,7 +289,7 @@ namespace Jellyfin.Api.Controllers
item.IsLocked = request.LockData ?? false;
- if (request.LockedFields != null)
+ if (request.LockedFields is not null)
{
item.LockedFields = request.LockedFields;
}
@@ -315,7 +315,7 @@ namespace Jellyfin.Api.Controllers
video.Video3DFormat = request.Video3DFormat;
}
- if (request.AlbumArtists != null)
+ if (request.AlbumArtists is not null)
{
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)
{
@@ -349,7 +349,7 @@ namespace Jellyfin.Api.Controllers
{
series.Status = GetSeriesStatus(request);
- if (request.AirDays != null)
+ if (request.AirDays is not null)
{
series.AirDays = request.AirDays;
series.AirTime = request.AirTime;
diff --git a/Jellyfin.Api/Controllers/ItemsController.cs b/Jellyfin.Api/Controllers/ItemsController.cs
index 3ee5b8d737..717ddc32b3 100644
--- a/Jellyfin.Api/Controllers/ItemsController.cs
+++ b/Jellyfin.Api/Controllers/ItemsController.cs
@@ -447,7 +447,7 @@ namespace Jellyfin.Api.Controllers
{
return null;
}
- }).Where(i => i != null).Select(i => i!.Id).ToArray();
+ }).Where(i => i is not null).Select(i => i!.Id).ToArray();
}
// ExcludeArtistIds
@@ -483,7 +483,7 @@ namespace Jellyfin.Api.Controllers
{
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
@@ -837,7 +837,7 @@ namespace Jellyfin.Api.Controllers
if (excludeActiveSessions)
{
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)
.ToArray();
}
diff --git a/Jellyfin.Api/Controllers/LibraryController.cs b/Jellyfin.Api/Controllers/LibraryController.cs
index 7a57bf1a21..196d509fbc 100644
--- a/Jellyfin.Api/Controllers/LibraryController.cs
+++ b/Jellyfin.Api/Controllers/LibraryController.cs
@@ -104,7 +104,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult GetFile([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -154,7 +154,7 @@ namespace Jellyfin.Api.Controllers
: _libraryManager.GetUserRootFolder())
: _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound("Item not found.");
}
@@ -171,7 +171,7 @@ namespace Jellyfin.Api.Controllers
}
var parent = item.GetParent();
- if (parent == null)
+ if (parent is null)
{
break;
}
@@ -220,7 +220,7 @@ namespace Jellyfin.Api.Controllers
: _libraryManager.GetUserRootFolder())
: _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound("Item not found.");
}
@@ -237,7 +237,7 @@ namespace Jellyfin.Api.Controllers
}
var parent = item.GetParent();
- if (parent == null)
+ if (parent is null)
{
break;
}
@@ -435,7 +435,7 @@ namespace Jellyfin.Api.Controllers
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound("Item not found");
}
@@ -449,9 +449,9 @@ namespace Jellyfin.Api.Controllers
var dtoOptions = new DtoOptions().AddClientFields(User);
BaseItem? parent = item.GetParent();
- while (parent != null)
+ while (parent is not null)
{
- if (user != null)
+ if (user is not null)
{
parent = TranslateParentItem(parent, user);
}
@@ -610,14 +610,14 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult> GetDownload([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
var user = _userManager.GetUserById(User.GetUserId());
- if (user != null)
+ if (user is not null)
{
if (!item.CanDownload(user))
{
@@ -632,27 +632,15 @@ namespace Jellyfin.Api.Controllers
}
}
- if (user != null)
+ if (user is not null)
{
await LogDownloadAsync(item, user).ConfigureAwait(false);
}
- var path = item.Path;
+ // Quotes are valid in linux. They'll possibly cause issues here.
+ var filename = Path.GetFileName(item.Path)?.Replace("\"", string.Empty, StringComparison.Ordinal);
- // Quotes are valid in linux. They'll possibly cause issues here
- var filename = (Path.GetFileName(path) ?? string.Empty).Replace("\"", string.Empty, StringComparison.Ordinal);
- if (!string.IsNullOrWhiteSpace(filename))
- {
- // Kestrel doesn't support non-ASCII characters in headers
- if (Regex.IsMatch(filename, @"[^\p{IsBasicLatin}]"))
- {
- // Manually encoding non-ASCII characters, following https://tools.ietf.org/html/rfc5987#section-3.2.2
- filename = WebUtility.UrlEncode(filename);
- }
- }
-
- // TODO determine non-ASCII validity.
- return PhysicalFile(path, MimeTypes.GetMimeType(path), filename, true);
+ return PhysicalFile(item.Path, MimeTypes.GetMimeType(item.Path), filename, true);
}
/// <summary>
@@ -698,8 +686,8 @@ namespace Jellyfin.Api.Controllers
.AddClientFields(User);
var program = item as IHasProgramAttributes;
- bool? isMovie = item is Movie || (program != null && program.IsMovie) || item is Trailer;
- bool? isSeries = item is Series || (program != null && program.IsSeries);
+ bool? isMovie = item is Movie || (program is not null && program.IsMovie) || item is Trailer;
+ bool? isSeries = item is Series || (program is not null && program.IsSeries);
var includeItemTypes = new List<BaseItemKind>();
if (isMovie.Value)
@@ -782,8 +770,7 @@ namespace Jellyfin.Api.Controllers
Name = i.Name,
DefaultEnabled = IsSaverEnabledByDefault(i.Name, types, isNewLibrary)
})
- .GroupBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
- .Select(x => x.First())
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToArray();
result.MetadataReaders = plugins
@@ -793,8 +780,7 @@ namespace Jellyfin.Api.Controllers
Name = i.Name,
DefaultEnabled = true
})
- .GroupBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
- .Select(x => x.First())
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToArray();
result.SubtitleFetchers = plugins
@@ -804,8 +790,7 @@ namespace Jellyfin.Api.Controllers
Name = i.Name,
DefaultEnabled = true
})
- .GroupBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
- .Select(x => x.First())
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToArray();
var typeOptions = new List<LibraryTypeOptionsDto>();
@@ -826,8 +811,7 @@ namespace Jellyfin.Api.Controllers
Name = i.Name,
DefaultEnabled = IsMetadataFetcherEnabledByDefault(i.Name, type, isNewLibrary)
})
- .GroupBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
- .Select(x => x.First())
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToArray(),
ImageFetchers = plugins
@@ -838,8 +822,7 @@ namespace Jellyfin.Api.Controllers
Name = i.Name,
DefaultEnabled = IsImageFetcherEnabledByDefault(i.Name, type, isNewLibrary)
})
- .GroupBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
- .Select(x => x.First())
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToArray(),
SupportedImageTypes = plugins
diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.cs
index ec1170411c..1c23940556 100644
--- a/Jellyfin.Api/Controllers/LibraryStructureController.cs
+++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs
@@ -82,7 +82,7 @@ namespace Jellyfin.Api.Controllers
{
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();
}
diff --git a/Jellyfin.Api/Controllers/LiveTvController.cs b/Jellyfin.Api/Controllers/LiveTvController.cs
index 394df0f58b..94710d78f2 100644
--- a/Jellyfin.Api/Controllers/LiveTvController.cs
+++ b/Jellyfin.Api/Controllers/LiveTvController.cs
@@ -763,7 +763,7 @@ namespace Jellyfin.Api.Controllers
await AssertUserCanManageLiveTv().ConfigureAwait(false);
var item = _libraryManager.GetItemById(recordingId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -840,7 +840,7 @@ namespace Jellyfin.Api.Controllers
public async Task<ActionResult<SeriesTimerInfoDto>> GetSeriesTimer([FromRoute, Required] string timerId)
{
var timer = await _liveTvManager.GetSeriesTimer(timerId, CancellationToken.None).ConfigureAwait(false);
- if (timer == null)
+ if (timer is null)
{
return NotFound();
}
@@ -1201,7 +1201,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult GetLiveStreamFile([FromRoute, Required] string streamId, [FromRoute, Required] string container)
{
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfoByUniqueId(streamId);
- if (liveStreamInfo == null)
+ if (liveStreamInfo is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/MediaInfoController.cs b/Jellyfin.Api/Controllers/MediaInfoController.cs
index c111e92186..8115c35852 100644
--- a/Jellyfin.Api/Controllers/MediaInfoController.cs
+++ b/Jellyfin.Api/Controllers/MediaInfoController.cs
@@ -121,10 +121,10 @@ namespace Jellyfin.Api.Controllers
var profile = playbackInfoDto?.DeviceProfile;
_logger.LogDebug("GetPostedPlaybackInfo profile: {@Profile}", profile);
- if (profile == null)
+ if (profile is null)
{
var caps = _deviceManager.GetCapabilities(User.GetDeviceId());
- if (caps != null)
+ if (caps is not null)
{
profile = caps.DeviceProfile;
}
@@ -154,12 +154,12 @@ namespace Jellyfin.Api.Controllers
liveStreamId)
.ConfigureAwait(false);
- if (info.ErrorCode != null)
+ if (info.ErrorCode is not null)
{
return info;
}
- if (profile != null)
+ if (profile is not null)
{
// set device specific data
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));
- 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(
HttpContext,
diff --git a/Jellyfin.Api/Controllers/MoviesController.cs b/Jellyfin.Api/Controllers/MoviesController.cs
index 03f864b4a7..3cf079362b 100644
--- a/Jellyfin.Api/Controllers/MoviesController.cs
+++ b/Jellyfin.Api/Controllers/MoviesController.cs
@@ -200,8 +200,7 @@ namespace Jellyfin.Api.Controllers
IsMovie = true,
EnableGroupByMetadataKey = true,
DtoOptions = dtoOptions
- }).GroupBy(i => i.GetProviderId(MediaBrowser.Model.Entities.MetadataProvider.Imdb) ?? Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture))
- .Select(x => x.First())
+ }).DistinctBy(i => i.GetProviderId(MediaBrowser.Model.Entities.MetadataProvider.Imdb) ?? Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture))
.Take(itemLimit)
.ToList();
@@ -240,8 +239,7 @@ namespace Jellyfin.Api.Controllers
IsMovie = true,
EnableGroupByMetadataKey = true,
DtoOptions = dtoOptions
- }).GroupBy(i => i.GetProviderId(MediaBrowser.Model.Entities.MetadataProvider.Imdb) ?? Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture))
- .Select(x => x.First())
+ }).DistinctBy(i => i.GetProviderId(MediaBrowser.Model.Entities.MetadataProvider.Imdb) ?? Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture))
.Take(itemLimit)
.ToList();
diff --git a/Jellyfin.Api/Controllers/NotificationsController.cs b/Jellyfin.Api/Controllers/NotificationsController.cs
index 420630cdf4..a285564760 100644
--- a/Jellyfin.Api/Controllers/NotificationsController.cs
+++ b/Jellyfin.Api/Controllers/NotificationsController.cs
@@ -1,12 +1,5 @@
-using System;
using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Threading;
using Jellyfin.Api.Constants;
-using Jellyfin.Api.Models.NotificationDtos;
-using Jellyfin.Data.Enums;
-using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Notifications;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Notifications;
@@ -23,41 +16,14 @@ namespace Jellyfin.Api.Controllers
public class NotificationsController : BaseJellyfinApiController
{
private readonly INotificationManager _notificationManager;
- private readonly IUserManager _userManager;
/// <summary>
/// Initializes a new instance of the <see cref="NotificationsController" /> class.
/// </summary>
/// <param name="notificationManager">The notification manager.</param>
- /// <param name="userManager">The user manager.</param>
- public NotificationsController(INotificationManager notificationManager, IUserManager userManager)
+ public NotificationsController(INotificationManager notificationManager)
{
_notificationManager = notificationManager;
- _userManager = userManager;
- }
-
- /// <summary>
- /// Gets a user's notifications.
- /// </summary>
- /// <response code="200">Notifications returned.</response>
- /// <returns>An <see cref="OkResult"/> containing a list of notifications.</returns>
- [HttpGet("{userId}")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult<NotificationResultDto> GetNotifications()
- {
- return new NotificationResultDto();
- }
-
- /// <summary>
- /// Gets a user's notification summary.
- /// </summary>
- /// <response code="200">Summary of user's notifications returned.</response>
- /// <returns>An <cref see="OkResult"/> containing a summary of the users notifications.</returns>
- [HttpGet("{userId}/Summary")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult<NotificationsSummaryDto> GetNotificationsSummary()
- {
- return new NotificationsSummaryDto();
}
/// <summary>
@@ -83,56 +49,5 @@ namespace Jellyfin.Api.Controllers
{
return _notificationManager.GetNotificationServices();
}
-
- /// <summary>
- /// Sends a notification to all admins.
- /// </summary>
- /// <param name="notificationDto">The notification request.</param>
- /// <response code="204">Notification sent.</response>
- /// <returns>A <cref see="NoContentResult"/>.</returns>
- [HttpPost("Admin")]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
- public ActionResult CreateAdminNotification([FromBody, Required] AdminNotificationDto notificationDto)
- {
- var notification = new NotificationRequest
- {
- Name = notificationDto.Name,
- Description = notificationDto.Description,
- Url = notificationDto.Url,
- Level = notificationDto.NotificationLevel ?? NotificationLevel.Normal,
- UserIds = _userManager.Users
- .Where(user => user.HasPermission(PermissionKind.IsAdministrator))
- .Select(user => user.Id)
- .ToArray(),
- Date = DateTime.UtcNow,
- };
-
- _notificationManager.SendNotification(notification, CancellationToken.None);
- return NoContent();
- }
-
- /// <summary>
- /// Sets notifications as read.
- /// </summary>
- /// <response code="204">Notifications set as read.</response>
- /// <returns>A <cref see="NoContentResult"/>.</returns>
- [HttpPost("{userId}/Read")]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
- public ActionResult SetRead()
- {
- return NoContent();
- }
-
- /// <summary>
- /// Sets notifications as unread.
- /// </summary>
- /// <response code="204">Notifications set as unread.</response>
- /// <returns>A <cref see="NoContentResult"/>.</returns>
- [HttpPost("{userId}/Unread")]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
- public ActionResult SetUnread()
- {
- return NoContent();
- }
}
}
diff --git a/Jellyfin.Api/Controllers/PackageController.cs b/Jellyfin.Api/Controllers/PackageController.cs
index 9690aead0c..0aa7c2ac9e 100644
--- a/Jellyfin.Api/Controllers/PackageController.cs
+++ b/Jellyfin.Api/Controllers/PackageController.cs
@@ -54,7 +54,7 @@ namespace Jellyfin.Api.Controllers
assemblyGuid ?? default)
.FirstOrDefault();
- if (result == null)
+ if (result is null)
{
return NotFound();
}
@@ -110,7 +110,7 @@ namespace Jellyfin.Api.Controllers
specificVersion: string.IsNullOrEmpty(version) ? null : Version.Parse(version))
.FirstOrDefault();
- if (package == null)
+ if (package is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/PersonsController.cs b/Jellyfin.Api/Controllers/PersonsController.cs
index 42be969b29..09f7281ecb 100644
--- a/Jellyfin.Api/Controllers/PersonsController.cs
+++ b/Jellyfin.Api/Controllers/PersonsController.cs
@@ -122,7 +122,7 @@ namespace Jellyfin.Api.Controllers
.AddClientFields(User);
var item = _libraryManager.GetPerson(name);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/PlaylistsController.cs b/Jellyfin.Api/Controllers/PlaylistsController.cs
index fb045f891e..e0c565da18 100644
--- a/Jellyfin.Api/Controllers/PlaylistsController.cs
+++ b/Jellyfin.Api/Controllers/PlaylistsController.cs
@@ -176,7 +176,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
{
var playlist = (Playlist)_libraryManager.GetItemById(playlistId);
- if (playlist == null)
+ if (playlist is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/PlaystateController.cs b/Jellyfin.Api/Controllers/PlaystateController.cs
index 3a2ba033ea..58f9b7d356 100644
--- a/Jellyfin.Api/Controllers/PlaystateController.cs
+++ b/Jellyfin.Api/Controllers/PlaystateController.cs
@@ -353,7 +353,7 @@ namespace Jellyfin.Api.Controllers
if (method == PlayMethod.Transcode)
{
var job = string.IsNullOrWhiteSpace(playSessionId) ? null : _transcodingJobHelper.GetTranscodingJob(playSessionId);
- if (job == null)
+ if (job is null)
{
return PlayMethod.DirectPlay;
}
diff --git a/Jellyfin.Api/Controllers/PluginsController.cs b/Jellyfin.Api/Controllers/PluginsController.cs
index b227dba2df..6a729b2373 100644
--- a/Jellyfin.Api/Controllers/PluginsController.cs
+++ b/Jellyfin.Api/Controllers/PluginsController.cs
@@ -71,7 +71,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult EnablePlugin([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version)
{
var plugin = _pluginManager.GetPlugin(pluginId, version);
- if (plugin == null)
+ if (plugin is null)
{
return NotFound();
}
@@ -95,7 +95,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult DisablePlugin([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version)
{
var plugin = _pluginManager.GetPlugin(pluginId, version);
- if (plugin == null)
+ if (plugin is null)
{
return NotFound();
}
@@ -119,7 +119,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult UninstallPluginByVersion([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version)
{
var plugin = _pluginManager.GetPlugin(pluginId, version);
- if (plugin == null)
+ if (plugin is null)
{
return NotFound();
}
@@ -146,9 +146,9 @@ namespace Jellyfin.Api.Controllers
var plugins = _pluginManager.Plugins.Where(p => p.Id.Equals(pluginId));
// Select the un-instanced one first.
- var plugin = plugins.FirstOrDefault(p => p.Instance == 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);
return NoContent();
@@ -202,7 +202,7 @@ namespace Jellyfin.Api.Controllers
var configuration = (BasePluginConfiguration?)await JsonSerializer.DeserializeAsync(Request.Body, configPlugin.ConfigurationType, _serializerOptions)
.ConfigureAwait(false);
- if (configuration != null)
+ if (configuration is not null)
{
configPlugin.UpdateConfiguration(configuration);
}
@@ -225,13 +225,13 @@ namespace Jellyfin.Api.Controllers
public ActionResult GetPluginImage([FromRoute, Required] Guid pluginId, [FromRoute, Required] Version version)
{
var plugin = _pluginManager.GetPlugin(pluginId, version);
- if (plugin == null)
+ if (plugin is null)
{
return NotFound();
}
var imagePath = Path.Combine(plugin.Path, plugin.Manifest.ImagePath ?? string.Empty);
- if (plugin.Manifest.ImagePath == null || !System.IO.File.Exists(imagePath))
+ if (plugin.Manifest.ImagePath is null || !System.IO.File.Exists(imagePath))
{
return NotFound();
}
@@ -254,7 +254,7 @@ namespace Jellyfin.Api.Controllers
{
var plugin = _pluginManager.GetPlugin(pluginId);
- if (plugin != null)
+ if (plugin is not null)
{
return plugin.Manifest;
}
diff --git a/Jellyfin.Api/Controllers/QuickConnectController.cs b/Jellyfin.Api/Controllers/QuickConnectController.cs
index 77d88475ff..6dbcdae228 100644
--- a/Jellyfin.Api/Controllers/QuickConnectController.cs
+++ b/Jellyfin.Api/Controllers/QuickConnectController.cs
@@ -1,3 +1,4 @@
+using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Jellyfin.Api.Constants;
@@ -51,7 +52,7 @@ namespace Jellyfin.Api.Controllers
/// <response code="200">Quick connect request successfully created.</response>
/// <response code="401">Quick connect is not active on this server.</response>
/// <returns>A <see cref="QuickConnectResult"/> with a secret and code for future use or an error message.</returns>
- [HttpGet("Initiate")]
+ [HttpPost("Initiate")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<QuickConnectResult>> InitiateQuickConnect()
{
@@ -67,6 +68,16 @@ namespace Jellyfin.Api.Controllers
}
/// <summary>
+ /// Old version of <see cref="InitiateQuickConnect" /> using a GET method.
+ /// Still available to avoid breaking compatibility.
+ /// </summary>
+ /// <returns>The result of <see cref="InitiateQuickConnect" />.</returns>
+ [Obsolete("Use POST request instead")]
+ [HttpGet("Initiate")]
+ [ApiExplorerSettings(IgnoreApi = true)]
+ public Task<ActionResult<QuickConnectResult>> InitiateQuickConnectLegacy() => InitiateQuickConnect();
+
+ /// <summary>
/// Attempts to retrieve authentication information.
/// </summary>
/// <param name="secret">Secret previously returned from the Initiate endpoint.</param>
@@ -96,6 +107,7 @@ namespace Jellyfin.Api.Controllers
/// Authorizes a pending quick connect request.
/// </summary>
/// <param name="code">Quick connect code to authorize.</param>
+ /// <param name="userId">The user the authorize. Access to the requested user is required.</param>
/// <response code="200">Quick connect result authorized successfully.</response>
/// <response code="403">Unknown user id.</response>
/// <returns>Boolean indicating if the authorization was successful.</returns>
@@ -103,17 +115,19 @@ namespace Jellyfin.Api.Controllers
[Authorize(Policy = Policies.DefaultAuthorization)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
- public async Task<ActionResult<bool>> AuthorizeQuickConnect([FromQuery, Required] string code)
+ public async Task<ActionResult<bool>> AuthorizeQuickConnect([FromQuery, Required] string code, [FromQuery] Guid? userId = null)
{
- var userId = User.GetUserId();
- if (userId.Equals(default))
+ var currentUserId = User.GetUserId();
+ var actualUserId = userId ?? currentUserId;
+
+ if (actualUserId.Equals(default) || (!userId.Equals(currentUserId) && !User.IsInRole(UserRoles.Administrator)))
{
- return StatusCode(StatusCodes.Status403Forbidden, "Unknown user id");
+ return Forbid("Unknown user id");
}
try
{
- return await _quickConnect.AuthorizeRequest(userId, code).ConfigureAwait(false);
+ return await _quickConnect.AuthorizeRequest(actualUserId, code).ConfigureAwait(false);
}
catch (AuthenticationException)
{
diff --git a/Jellyfin.Api/Controllers/RemoteImageController.cs b/Jellyfin.Api/Controllers/RemoteImageController.cs
index dbee56e140..da9e8cf90d 100644
--- a/Jellyfin.Api/Controllers/RemoteImageController.cs
+++ b/Jellyfin.Api/Controllers/RemoteImageController.cs
@@ -68,7 +68,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] bool includeAllLanguages = false)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -127,7 +127,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<IEnumerable<ImageProviderInfo>> GetRemoteImageProviders([FromRoute, Required] Guid itemId)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -154,7 +154,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] string? imageUrl)
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/ScheduledTasksController.cs b/Jellyfin.Api/Controllers/ScheduledTasksController.cs
index 68e4f0586f..832e145050 100644
--- a/Jellyfin.Api/Controllers/ScheduledTasksController.cs
+++ b/Jellyfin.Api/Controllers/ScheduledTasksController.cs
@@ -76,7 +76,7 @@ namespace Jellyfin.Api.Controllers
var task = _taskManager.ScheduledTasks.FirstOrDefault(i =>
string.Equals(i.Id, taskId, StringComparison.OrdinalIgnoreCase));
- if (task == null)
+ if (task is null)
{
return NotFound();
}
@@ -99,7 +99,7 @@ namespace Jellyfin.Api.Controllers
var task = _taskManager.ScheduledTasks.FirstOrDefault(o =>
o.Id.Equals(taskId, StringComparison.OrdinalIgnoreCase));
- if (task == null)
+ if (task is null)
{
return NotFound();
}
@@ -123,7 +123,7 @@ namespace Jellyfin.Api.Controllers
var task = _taskManager.ScheduledTasks.FirstOrDefault(o =>
o.Id.Equals(taskId, StringComparison.OrdinalIgnoreCase));
- if (task == null)
+ if (task is null)
{
return NotFound();
}
@@ -149,7 +149,7 @@ namespace Jellyfin.Api.Controllers
{
var task = _taskManager.ScheduledTasks.FirstOrDefault(o =>
o.Id.Equals(taskId, StringComparison.OrdinalIgnoreCase));
- if (task == null)
+ if (task is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/SearchController.cs b/Jellyfin.Api/Controllers/SearchController.cs
index aeed0c0d61..3b7719f373 100644
--- a/Jellyfin.Api/Controllers/SearchController.cs
+++ b/Jellyfin.Api/Controllers/SearchController.cs
@@ -161,7 +161,7 @@ namespace Jellyfin.Api.Controllers
var primaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary);
- if (primaryImageTag != null)
+ if (primaryImageTag is not null)
{
result.PrimaryImageTag = primaryImageTag;
result.PrimaryImageAspectRatio = _dtoService.GetPrimaryImageAspectRatio(item);
@@ -195,7 +195,7 @@ namespace Jellyfin.Api.Controllers
MusicAlbum musicAlbum = song.AlbumEntity;
- if (musicAlbum != null)
+ if (musicAlbum is not null)
{
result.Album = musicAlbum.Name;
result.AlbumId = musicAlbum.Id;
@@ -221,18 +221,18 @@ namespace Jellyfin.Api.Controllers
{
var itemWithImage = item.HasImage(ImageType.Thumb) ? item : null;
- if (itemWithImage == null && item is Episode)
+ if (itemWithImage is null && item is Episode)
{
itemWithImage = GetParentWithImage<Series>(item, ImageType.Thumb);
}
itemWithImage ??= GetParentWithImage<BaseItem>(item, ImageType.Thumb);
- if (itemWithImage != null)
+ if (itemWithImage is not null)
{
var tag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Thumb);
- if (tag != null)
+ if (tag is not null)
{
hint.ThumbImageTag = tag;
hint.ThumbImageItemId = itemWithImage.Id.ToString("N", CultureInfo.InvariantCulture);
@@ -245,11 +245,11 @@ namespace Jellyfin.Api.Controllers
var itemWithImage = (item.HasImage(ImageType.Backdrop) ? item : null)
?? GetParentWithImage<BaseItem>(item, ImageType.Backdrop);
- if (itemWithImage != null)
+ if (itemWithImage is not null)
{
var tag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Backdrop);
- if (tag != null)
+ if (tag is not null)
{
hint.BackdropImageTag = tag;
hint.BackdropImageItemId = itemWithImage.Id.ToString("N", CultureInfo.InvariantCulture);
diff --git a/Jellyfin.Api/Controllers/SessionController.cs b/Jellyfin.Api/Controllers/SessionController.cs
index 31b95162d4..25f9301351 100644
--- a/Jellyfin.Api/Controllers/SessionController.cs
+++ b/Jellyfin.Api/Controllers/SessionController.cs
@@ -294,10 +294,7 @@ namespace Jellyfin.Api.Controllers
{
var currentSession = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);
- if (command == null)
- {
- throw new ArgumentException("Request body may not be null");
- }
+ ArgumentNullException.ThrowIfNull(command);
command.ControllingUserId = currentSession.UserId;
diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs
index c49bde93f1..eec5779e64 100644
--- a/Jellyfin.Api/Controllers/StartupController.cs
+++ b/Jellyfin.Api/Controllers/StartupController.cs
@@ -132,7 +132,7 @@ namespace Jellyfin.Api.Controllers
{
var user = _userManager.Users.First();
- if (startupUserDto.Name != null)
+ if (startupUserDto.Name is not null)
{
user.Username = startupUserDto.Name;
}
diff --git a/Jellyfin.Api/Controllers/SubtitleController.cs b/Jellyfin.Api/Controllers/SubtitleController.cs
index 1258a9876b..ff9bd095b5 100644
--- a/Jellyfin.Api/Controllers/SubtitleController.cs
+++ b/Jellyfin.Api/Controllers/SubtitleController.cs
@@ -96,7 +96,7 @@ namespace Jellyfin.Api.Controllers
{
var item = _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
@@ -522,7 +522,7 @@ namespace Jellyfin.Api.Controllers
.First(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
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);
return PhysicalFile(fontFile.FullName, MimeTypes.GetMimeType(fontFile.FullName));
diff --git a/Jellyfin.Api/Controllers/TvShowsController.cs b/Jellyfin.Api/Controllers/TvShowsController.cs
index ea13ceb91c..7f4f4d0776 100644
--- a/Jellyfin.Api/Controllers/TvShowsController.cs
+++ b/Jellyfin.Api/Controllers/TvShowsController.cs
@@ -247,7 +247,7 @@ namespace Jellyfin.Api.Controllers
.GetSeasons(user, dtoOptions)
.FirstOrDefault(i => i.IndexNumber == season.Value);
- episodes = seasonItem == null ?
+ episodes = seasonItem is null ?
new List<BaseItem>()
: ((Season)seasonItem).GetEpisodes(user, dtoOptions);
}
diff --git a/Jellyfin.Api/Controllers/UserController.cs b/Jellyfin.Api/Controllers/UserController.cs
index ff653fe6bb..568224a424 100644
--- a/Jellyfin.Api/Controllers/UserController.cs
+++ b/Jellyfin.Api/Controllers/UserController.cs
@@ -124,7 +124,7 @@ namespace Jellyfin.Api.Controllers
{
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound("User not found");
}
@@ -157,7 +157,6 @@ namespace Jellyfin.Api.Controllers
/// </summary>
/// <param name="userId">The user id.</param>
/// <param name="pw">The password as plain text.</param>
- /// <param name="password">The password sha1-hash.</param>
/// <response code="200">User authenticated.</response>
/// <response code="403">Sha1-hashed password only is not allowed.</response>
/// <response code="404">User not found.</response>
@@ -166,23 +165,18 @@ namespace Jellyfin.Api.Controllers
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
+ [Obsolete("Authenticate with username instead")]
public async Task<ActionResult<AuthenticationResult>> AuthenticateUser(
[FromRoute, Required] Guid userId,
- [FromQuery, Required] string pw,
- [FromQuery] string? password)
+ [FromQuery, Required] string pw)
{
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound("User not found");
}
- if (!string.IsNullOrEmpty(password) && string.IsNullOrEmpty(pw))
- {
- return StatusCode(StatusCodes.Status403Forbidden, "Only sha1 password is not allowed.");
- }
-
AuthenticateUserByName request = new AuthenticateUserByName
{
Username = user.Username,
@@ -272,7 +266,7 @@ namespace Jellyfin.Api.Controllers
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound("User not found");
}
@@ -292,7 +286,7 @@ namespace Jellyfin.Api.Controllers
HttpContext.GetNormalizedRemoteIp().ToString(),
false).ConfigureAwait(false);
- if (success == null)
+ if (success is null)
{
return StatusCode(StatusCodes.Status403Forbidden, "Invalid user or password entered.");
}
@@ -333,7 +327,7 @@ namespace Jellyfin.Api.Controllers
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound("User not found");
}
@@ -477,7 +471,7 @@ namespace Jellyfin.Api.Controllers
var newUser = await _userManager.CreateUserAsync(request.Name).ConfigureAwait(false);
// 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);
}
@@ -544,7 +538,7 @@ namespace Jellyfin.Api.Controllers
}
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return BadRequest();
}
diff --git a/Jellyfin.Api/Controllers/UserLibraryController.cs b/Jellyfin.Api/Controllers/UserLibraryController.cs
index 8a2d5a27d9..c18fa29af6 100644
--- a/Jellyfin.Api/Controllers/UserLibraryController.cs
+++ b/Jellyfin.Api/Controllers/UserLibraryController.cs
@@ -306,7 +306,7 @@ namespace Jellyfin.Api.Controllers
var item = i.Item2[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;
childCount = i.Item2.Count;
@@ -402,7 +402,7 @@ namespace Jellyfin.Api.Controllers
{
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound();
}
@@ -411,7 +411,7 @@ namespace Jellyfin.Api.Controllers
? _libraryManager.GetUserRootFolder()
: _libraryManager.GetItemById(itemId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/UserViewsController.cs b/Jellyfin.Api/Controllers/UserViewsController.cs
index 85d154cac2..3aeb444dfa 100644
--- a/Jellyfin.Api/Controllers/UserViewsController.cs
+++ b/Jellyfin.Api/Controllers/UserViewsController.cs
@@ -117,7 +117,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<IEnumerable<SpecialViewOptionDto>> GetGroupingOptions([FromRoute, Required] Guid userId)
{
var user = _userManager.GetUserById(userId);
- if (user == null)
+ if (user is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/VideoAttachmentsController.cs b/Jellyfin.Api/Controllers/VideoAttachmentsController.cs
index c2bb0dfffe..bb31626142 100644
--- a/Jellyfin.Api/Controllers/VideoAttachmentsController.cs
+++ b/Jellyfin.Api/Controllers/VideoAttachmentsController.cs
@@ -55,7 +55,7 @@ namespace Jellyfin.Api.Controllers
try
{
var item = _libraryManager.GetItemById(videoId);
- if (item == null)
+ if (item is null)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/VideosController.cs b/Jellyfin.Api/Controllers/VideosController.cs
index bf08ad376b..64d8fb498b 100644
--- a/Jellyfin.Api/Controllers/VideosController.cs
+++ b/Jellyfin.Api/Controllers/VideosController.cs
@@ -149,7 +149,7 @@ namespace Jellyfin.Api.Controllers
{
var video = (Video)_libraryManager.GetItemById(itemId);
- if (video == null)
+ if (video is null)
{
return NotFound("The video either does not exist or the id does not belong to a video.");
}
@@ -199,7 +199,7 @@ namespace Jellyfin.Api.Controllers
}
var primaryVersion = items.FirstOrDefault(i => i.MediaSourceCount > 1 && string.IsNullOrEmpty(i.PrimaryVersionId));
- if (primaryVersion == null)
+ if (primaryVersion is null)
{
primaryVersion = items
.OrderBy(i =>
@@ -439,12 +439,12 @@ namespace Jellyfin.Api.Controllers
cancellationTokenSource.Token)
.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);
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamingRequest.LiveStreamId);
- if (liveStreamInfo == null)
+ if (liveStreamInfo is null)
{
return NotFound();
}
@@ -472,7 +472,7 @@ namespace Jellyfin.Api.Controllers
var outputPathExists = System.IO.File.Exists(outputPath);
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);
diff --git a/Jellyfin.Api/Controllers/YearsController.cs b/Jellyfin.Api/Controllers/YearsController.cs
index b732bdff3c..cd85ba221b 100644
--- a/Jellyfin.Api/Controllers/YearsController.cs
+++ b/Jellyfin.Api/Controllers/YearsController.cs
@@ -152,7 +152,7 @@ namespace Jellyfin.Api.Controllers
var result = new QueryResult<BaseItemDto>(
startIndex,
ibnItemsArray.Count,
- dtos.Where(i => i != null).ToArray());
+ dtos.Where(i => i is not null).ToArray());
return result;
}
@@ -173,7 +173,7 @@ namespace Jellyfin.Api.Controllers
public ActionResult<BaseItemDto> GetYear([FromRoute, Required] int year, [FromQuery] Guid? userId)
{
var item = _libraryManager.GetYear(year);
- if (item == null)
+ if (item is null)
{
return NotFound();
}