Browse Source

Merge remote-tracking branch 'upstream/master' into no-scaling

Fernando Fernández 4 years ago
parent
commit
e21e00cad5
100 changed files with 1659 additions and 857 deletions
  1. 1 0
      CONTRIBUTORS.md
  2. 1 1
      Emby.Dlna/Common/Argument.cs
  3. 64 5
      Emby.Dlna/Configuration/DlnaOptions.cs
  4. 11 1
      Emby.Dlna/ConnectionManager/ConnectionManagerService.cs
  5. 79 66
      Emby.Dlna/ConnectionManager/ConnectionManagerXmlBuilder.cs
  6. 13 0
      Emby.Dlna/ConnectionManager/ControlHandler.cs
  7. 32 5
      Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs
  8. 1 1
      Emby.Dlna/ContentDirectory/ControlHandler.cs
  9. 2 2
      Emby.Dlna/DlnaManager.cs
  10. 4 4
      Emby.Dlna/PlayTo/Device.cs
  11. 4 1
      Emby.Dlna/PlayTo/PlayToController.cs
  12. 2 2
      Emby.Dlna/PlayTo/SsdpHttpClient.cs
  13. 12 3
      Emby.Naming/Audio/AlbumParser.cs
  14. 9 3
      Emby.Naming/Audio/AudioFileParser.cs
  15. 16 7
      Emby.Naming/AudioBook/AudioBookFileInfo.cs
  16. 12 5
      Emby.Naming/AudioBook/AudioBookFilePathParser.cs
  17. 9 5
      Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs
  18. 11 4
      Emby.Naming/AudioBook/AudioBookInfo.cs
  19. 117 12
      Emby.Naming/AudioBook/AudioBookListResolver.cs
  20. 67 0
      Emby.Naming/AudioBook/AudioBookNameParser.cs
  21. 18 0
      Emby.Naming/AudioBook/AudioBookNameParserResult.cs
  22. 20 19
      Emby.Naming/AudioBook/AudioBookResolver.cs
  23. 32 10
      Emby.Naming/Common/EpisodeExpression.cs
  24. 3 2
      Emby.Naming/Common/MediaType.cs
  25. 342 306
      Emby.Naming/Common/NamingOptions.cs
  26. 2 1
      Emby.Naming/Emby.Naming.csproj
  27. 17 3
      Emby.Naming/Subtitles/SubtitleInfo.cs
  28. 18 11
      Emby.Naming/Subtitles/SubtitleParser.cs
  29. 38 7
      Emby.Naming/TV/EpisodeInfo.cs
  30. 22 13
      Emby.Naming/TV/EpisodePathParser.cs
  31. 33 4
      Emby.Naming/TV/EpisodePathParserResult.cs
  32. 19 6
      Emby.Naming/TV/EpisodeResolver.cs
  33. 16 8
      Emby.Naming/TV/SeasonPathParser.cs
  34. 7 2
      Emby.Naming/TV/SeasonPathParserResult.cs
  35. 6 3
      Emby.Naming/Video/CleanDateTimeParser.cs
  36. 9 10
      Emby.Naming/Video/CleanDateTimeResult.cs
  37. 7 3
      Emby.Naming/Video/CleanStringParser.cs
  38. 12 6
      Emby.Naming/Video/ExtraResolver.cs
  39. 4 3
      Emby.Naming/Video/ExtraResult.cs
  40. 15 2
      Emby.Naming/Video/ExtraRule.cs
  41. 4 3
      Emby.Naming/Video/ExtraRuleType.cs
  42. 22 3
      Emby.Naming/Video/FileStack.cs
  43. 21 5
      Emby.Naming/Video/FlagParser.cs
  44. 20 10
      Emby.Naming/Video/Format3DParser.cs
  45. 7 3
      Emby.Naming/Video/Format3DResult.cs
  46. 17 5
      Emby.Naming/Video/Format3DRule.cs
  47. 48 18
      Emby.Naming/Video/StackResolver.cs
  48. 11 4
      Emby.Naming/Video/StubResolver.cs
  49. 0 19
      Emby.Naming/Video/StubResult.cs
  50. 14 2
      Emby.Naming/Video/StubTypeRule.cs
  51. 34 6
      Emby.Naming/Video/VideoFileInfo.cs
  52. 2 2
      Emby.Naming/Video/VideoInfo.cs
  53. 27 8
      Emby.Naming/Video/VideoListResolver.cs
  54. 45 21
      Emby.Naming/Video/VideoResolver.cs
  55. 3 4
      Emby.Server.Implementations/ApplicationHost.cs
  56. 0 14
      Emby.Server.Implementations/Data/SqliteExtensions.cs
  57. 1 1
      Emby.Server.Implementations/Emby.Server.Implementations.csproj
  58. 5 4
      Emby.Server.Implementations/Library/LibraryManager.cs
  59. 1 1
      Emby.Server.Implementations/Library/MediaStreamSelector.cs
  60. 4 3
      Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
  61. 10 10
      Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
  62. 1 1
      Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
  63. 3 3
      Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
  64. 2 2
      Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
  65. 1 1
      Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
  66. 4 1
      Emby.Server.Implementations/Localization/Core/de.json
  67. 6 1
      Emby.Server.Implementations/Localization/Core/es-AR.json
  68. 4 1
      Emby.Server.Implementations/Localization/Core/es.json
  69. 6 1
      Emby.Server.Implementations/Localization/Core/he.json
  70. 4 1
      Emby.Server.Implementations/Localization/Core/ta.json
  71. 4 1
      Emby.Server.Implementations/Localization/Core/vi.json
  72. 4 1
      Emby.Server.Implementations/Localization/Core/zh-CN.json
  73. 2 2
      Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
  74. 1 1
      Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
  75. 4 3
      Emby.Server.Implementations/Updates/InstallationManager.cs
  76. 3 3
      Jellyfin.Api/Controllers/AudioController.cs
  77. 11 11
      Jellyfin.Api/Controllers/DynamicHlsController.cs
  78. 1 1
      Jellyfin.Api/Controllers/EnvironmentController.cs
  79. 25 25
      Jellyfin.Api/Controllers/ItemsController.cs
  80. 3 2
      Jellyfin.Api/Controllers/LiveTvController.cs
  81. 21 21
      Jellyfin.Api/Controllers/TrailersController.cs
  82. 3 3
      Jellyfin.Api/Controllers/TvShowsController.cs
  83. 2 2
      Jellyfin.Api/Controllers/UserLibraryController.cs
  84. 2 2
      Jellyfin.Api/Controllers/VideoHlsController.cs
  85. 2 2
      Jellyfin.Api/Controllers/VideosController.cs
  86. 4 2
      Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs
  87. 2 2
      Jellyfin.Api/Helpers/TranscodingJobHelper.cs
  88. 2 2
      Jellyfin.Data/Entities/Libraries/CollectionItem.cs
  89. 1 1
      Jellyfin.Data/Entities/Libraries/ItemMetadata.cs
  90. 1 1
      Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs
  91. 2 0
      Jellyfin.Server/CoreAppHost.cs
  92. 1 1
      MediaBrowser.Common/MediaBrowser.Common.csproj
  93. 1 2
      MediaBrowser.Common/Net/DefaultHttpClientHandler.cs
  94. 2 2
      MediaBrowser.Common/Net/INetworkManager.cs
  95. 1 1
      MediaBrowser.Common/Plugins/BasePlugin.cs
  96. 86 0
      MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs
  97. 29 0
      MediaBrowser.Controller/BaseItemManager/IBaseItemManager.cs
  98. 1 55
      MediaBrowser.Controller/Entities/BaseItem.cs
  99. 1 1
      MediaBrowser.Controller/Entities/Folder.cs
  100. 3 3
      MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs

+ 1 - 0
CONTRIBUTORS.md

@@ -104,6 +104,7 @@
  - [sorinyo2004](https://github.com/sorinyo2004)
  - [sparky8251](https://github.com/sparky8251)
  - [spookbits](https://github.com/spookbits)
+ - [ssenart] (https://github.com/ssenart)
  - [stanionascu](https://github.com/stanionascu)
  - [stevehayles](https://github.com/stevehayles)
  - [SuperSandro2000](https://github.com/SuperSandro2000)

+ 1 - 1
Emby.Dlna/Common/Argument.cs

@@ -1,7 +1,7 @@
 namespace Emby.Dlna.Common
 {
     /// <summary>
-    /// DLNA Query parameter type, used when quering DLNA devices via SOAP.
+    /// DLNA Query parameter type, used when querying DLNA devices via SOAP.
     /// </summary>
     public class Argument
     {

+ 64 - 5
Emby.Dlna/Configuration/DlnaOptions.cs

@@ -2,8 +2,14 @@
 
 namespace Emby.Dlna.Configuration
 {
+    /// <summary>
+    /// The DlnaOptions class contains the user definable parameters for the dlna subsystems.
+    /// </summary>
     public class DlnaOptions
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="DlnaOptions"/> class.
+        /// </summary>
         public DlnaOptions()
         {
             EnablePlayTo = true;
@@ -11,23 +17,76 @@ namespace Emby.Dlna.Configuration
             BlastAliveMessages = true;
             SendOnlyMatchedHost = true;
             ClientDiscoveryIntervalSeconds = 60;
-            BlastAliveMessageIntervalSeconds = 1800;
+            AliveMessageIntervalSeconds = 1800;
         }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether gets or sets a value to indicate the status of the dlna playTo subsystem.
+        /// </summary>
         public bool EnablePlayTo { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether gets or sets a value to indicate the status of the dlna server subsystem.
+        /// </summary>
         public bool EnableServer { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether detailed dlna server logs are sent to the console/log.
+        /// If the setting "Emby.Dlna": "Debug" msut be set in logging.default.json for this property to work.
+        /// </summary>
         public bool EnableDebugLog { get; set; }
 
-        public bool BlastAliveMessages { get; set; }
-
-        public bool SendOnlyMatchedHost { get; set; }
+        /// <summary>
+        /// Gets or sets a value indicating whether whether detailed playTo debug logs are sent to the console/log.
+        /// If the setting "Emby.Dlna.PlayTo": "Debug" msut be set in logging.default.json for this property to work.
+        /// </summary>
+        public bool EnablePlayToTracing { get; set; }
 
+        /// <summary>
+        /// Gets or sets the ssdp client discovery interval time (in seconds).
+        /// This is the time after which the server will send a ssdp search request.
+        /// </summary>
         public int ClientDiscoveryIntervalSeconds { get; set; }
 
-        public int BlastAliveMessageIntervalSeconds { get; set; }
+        /// <summary>
+        /// Gets or sets the frequency at which ssdp alive notifications are transmitted.
+        /// </summary>
+        public int AliveMessageIntervalSeconds { get; set; }
+
+        /// <summary>
+        /// Gets or sets the frequency at which ssdp alive notifications are transmitted. MIGRATING - TO BE REMOVED ONCE WEB HAS BEEN ALTERED.
+        /// </summary>
+        public int BlastAliveMessageIntervalSeconds
+        {
+            get
+            {
+                return AliveMessageIntervalSeconds;
+            }
+
+            set
+            {
+                AliveMessageIntervalSeconds = value;
+            }
+        }
 
+        /// <summary>
+        /// Gets or sets the default user account that the dlna server uses.
+        /// </summary>
         public string DefaultUserId { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether playTo device profiles should be created.
+        /// </summary>
+        public bool AutoCreatePlayToProfiles { get; set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether to blast alive messages.
+        /// </summary>
+        public bool BlastAliveMessages { get; set; } = true;
+
+        /// <summary>
+        /// gets or sets a value indicating whether to send only matched host.
+        /// </summary>
+        public bool SendOnlyMatchedHost { get; set; } = true;
     }
 }

+ 11 - 1
Emby.Dlna/ConnectionManager/ConnectionManagerService.cs

@@ -9,11 +9,21 @@ using Microsoft.Extensions.Logging;
 
 namespace Emby.Dlna.ConnectionManager
 {
+    /// <summary>
+    /// Defines the <see cref="ConnectionManagerService" />.
+    /// </summary>
     public class ConnectionManagerService : BaseService, IConnectionManager
     {
         private readonly IDlnaManager _dlna;
         private readonly IServerConfigurationManager _config;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ConnectionManagerService"/> class.
+        /// </summary>
+        /// <param name="dlna">The <see cref="IDlnaManager"/> for use with the <see cref="ConnectionManagerService"/> instance.</param>
+        /// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ConnectionManagerService"/> instance.</param>
+        /// <param name="logger">The <see cref="ILogger{ConnectionManagerService}"/> for use with the <see cref="ConnectionManagerService"/> instance..</param>
+        /// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> for use with the <see cref="ConnectionManagerService"/> instance..</param>
         public ConnectionManagerService(
             IDlnaManager dlna,
             IServerConfigurationManager config,
@@ -28,7 +38,7 @@ namespace Emby.Dlna.ConnectionManager
         /// <inheritdoc />
         public string GetServiceXml()
         {
-            return new ConnectionManagerXmlBuilder().GetXml();
+            return ConnectionManagerXmlBuilder.GetXml();
         }
 
         /// <inheritdoc />

+ 79 - 66
Emby.Dlna/ConnectionManager/ConnectionManagerXmlBuilder.cs

@@ -6,45 +6,57 @@ using Emby.Dlna.Service;
 
 namespace Emby.Dlna.ConnectionManager
 {
-    public class ConnectionManagerXmlBuilder
+    /// <summary>
+    /// Defines the <see cref="ConnectionManagerXmlBuilder" />.
+    /// </summary>
+    public static class ConnectionManagerXmlBuilder
     {
-        public string GetXml()
+        /// <summary>
+        /// Gets the ConnectionManager:1 service template.
+        /// See http://upnp.org/specs/av/UPnP-av-ConnectionManager-v1-Service.pdf.
+        /// </summary>
+        /// <returns>An XML description of this service.</returns>
+        public static string GetXml()
         {
-            return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(), GetStateVariables());
+            return new ServiceXmlBuilder().GetXml(ServiceActionListBuilder.GetActions(), GetStateVariables());
         }
 
+        /// <summary>
+        /// Get the list of state variables for this invocation.
+        /// </summary>
+        /// <returns>The <see cref="IEnumerable{StateVariable}"/>.</returns>
         private static IEnumerable<StateVariable> GetStateVariables()
         {
-            var list = new List<StateVariable>();
-
-            list.Add(new StateVariable
+            var list = new List<StateVariable>
             {
-                Name = "SourceProtocolInfo",
-                DataType = "string",
-                SendsEvents = true
-            });
+                new StateVariable
+                {
+                    Name = "SourceProtocolInfo",
+                    DataType = "string",
+                    SendsEvents = true
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "SinkProtocolInfo",
-                DataType = "string",
-                SendsEvents = true
-            });
+                new StateVariable
+                {
+                    Name = "SinkProtocolInfo",
+                    DataType = "string",
+                    SendsEvents = true
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "CurrentConnectionIDs",
-                DataType = "string",
-                SendsEvents = true
-            });
+                new StateVariable
+                {
+                    Name = "CurrentConnectionIDs",
+                    DataType = "string",
+                    SendsEvents = true
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_ConnectionStatus",
-                DataType = "string",
-                SendsEvents = false,
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_ConnectionStatus",
+                    DataType = "string",
+                    SendsEvents = false,
 
-                AllowedValues = new[]
+                    AllowedValues = new[]
                 {
                     "OK",
                     "ContentFormatMismatch",
@@ -52,55 +64,56 @@ namespace Emby.Dlna.ConnectionManager
                     "UnreliableChannel",
                     "Unknown"
                 }
-            });
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_ConnectionManager",
-                DataType = "string",
-                SendsEvents = false
-            });
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_ConnectionManager",
+                    DataType = "string",
+                    SendsEvents = false
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_Direction",
-                DataType = "string",
-                SendsEvents = false,
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_Direction",
+                    DataType = "string",
+                    SendsEvents = false,
 
-                AllowedValues = new[]
+                    AllowedValues = new[]
                 {
                     "Output",
                     "Input"
                 }
-            });
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_ProtocolInfo",
-                DataType = "string",
-                SendsEvents = false
-            });
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_ProtocolInfo",
+                    DataType = "string",
+                    SendsEvents = false
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_ConnectionID",
-                DataType = "ui4",
-                SendsEvents = false
-            });
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_ConnectionID",
+                    DataType = "ui4",
+                    SendsEvents = false
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_AVTransportID",
-                DataType = "ui4",
-                SendsEvents = false
-            });
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_AVTransportID",
+                    DataType = "ui4",
+                    SendsEvents = false
+                },
 
-            list.Add(new StateVariable
-            {
-                Name = "A_ARG_TYPE_RcsID",
-                DataType = "ui4",
-                SendsEvents = false
-            });
+                new StateVariable
+                {
+                    Name = "A_ARG_TYPE_RcsID",
+                    DataType = "ui4",
+                    SendsEvents = false
+                }
+            };
 
             return list;
         }

+ 13 - 0
Emby.Dlna/ConnectionManager/ControlHandler.cs

@@ -11,10 +11,19 @@ using Microsoft.Extensions.Logging;
 
 namespace Emby.Dlna.ConnectionManager
 {
+    /// <summary>
+    /// Defines the <see cref="ControlHandler" />.
+    /// </summary>
     public class ControlHandler : BaseControlHandler
     {
         private readonly DeviceProfile _profile;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ControlHandler"/> class.
+        /// </summary>
+        /// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
+        /// <param name="logger">The <see cref="ILogger"/> for use with the <see cref="ControlHandler"/> instance.</param>
+        /// <param name="profile">The <see cref="DeviceProfile"/> for use with the <see cref="ControlHandler"/> instance.</param>
         public ControlHandler(IServerConfigurationManager config, ILogger logger, DeviceProfile profile)
             : base(config, logger)
         {
@@ -33,6 +42,10 @@ namespace Emby.Dlna.ConnectionManager
             throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
         }
 
+        /// <summary>
+        /// Builds the response to the GetProtocolInfo request.
+        /// </summary>
+        /// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
         private void HandleGetProtocolInfo(XmlWriter xmlWriter)
         {
             xmlWriter.WriteElementString("Source", _profile.ProtocolInfo);

+ 32 - 5
Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs

@@ -5,9 +5,16 @@ using Emby.Dlna.Common;
 
 namespace Emby.Dlna.ConnectionManager
 {
-    public class ServiceActionListBuilder
+    /// <summary>
+    /// Defines the <see cref="ServiceActionListBuilder" />.
+    /// </summary>
+    public static class ServiceActionListBuilder
     {
-        public IEnumerable<ServiceAction> GetActions()
+        /// <summary>
+        /// Returns an enumerable of the ConnectionManagar:1 DLNA actions.
+        /// </summary>
+        /// <returns>An <see cref="IEnumerable{ServiceAction}"/>.</returns>
+        public static IEnumerable<ServiceAction> GetActions()
         {
             var list = new List<ServiceAction>
             {
@@ -21,6 +28,10 @@ namespace Emby.Dlna.ConnectionManager
             return list;
         }
 
+        /// <summary>
+        /// Returns the action details for "PrepareForConnection".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
         private static ServiceAction PrepareForConnection()
         {
             var action = new ServiceAction
@@ -80,6 +91,10 @@ namespace Emby.Dlna.ConnectionManager
             return action;
         }
 
+        /// <summary>
+        /// Returns the action details for "GetCurrentConnectionInfo".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
         private static ServiceAction GetCurrentConnectionInfo()
         {
             var action = new ServiceAction
@@ -146,7 +161,11 @@ namespace Emby.Dlna.ConnectionManager
             return action;
         }
 
-        private ServiceAction GetProtocolInfo()
+        /// <summary>
+        /// Returns the action details for "GetProtocolInfo".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
+        private static ServiceAction GetProtocolInfo()
         {
             var action = new ServiceAction
             {
@@ -170,7 +189,11 @@ namespace Emby.Dlna.ConnectionManager
             return action;
         }
 
-        private ServiceAction GetCurrentConnectionIDs()
+        /// <summary>
+        /// Returns the action details for "GetCurrentConnectionIDs".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
+        private static ServiceAction GetCurrentConnectionIDs()
         {
             var action = new ServiceAction
             {
@@ -187,7 +210,11 @@ namespace Emby.Dlna.ConnectionManager
             return action;
         }
 
-        private ServiceAction ConnectionComplete()
+        /// <summary>
+        /// Returns the action details for "ConnectionComplete".
+        /// </summary>
+        /// <returns>The <see cref="ServiceAction"/>.</returns>
+        private static ServiceAction ConnectionComplete()
         {
             var action = new ServiceAction
             {

+ 1 - 1
Emby.Dlna/ContentDirectory/ControlHandler.cs

@@ -1674,7 +1674,7 @@ namespace Emby.Dlna.ContentDirectory
         }
 
         /// <summary>
-        /// Retreives the ServerItem id.
+        /// Retrieves the ServerItem id.
         /// </summary>
         /// <param name="id">The id<see cref="string"/>.</param>
         /// <returns>The <see cref="ServerItem"/>.</returns>

+ 2 - 2
Emby.Dlna/DlnaManager.cs

@@ -484,10 +484,10 @@ namespace Emby.Dlna
 
         /// <summary>
         /// Recreates the object using serialization, to ensure it's not a subclass.
-        /// If it's a subclass it may not serlialize properly to xml (different root element tag name).
+        /// If it's a subclass it may not serialize properly to xml (different root element tag name).
         /// </summary>
         /// <param name="profile">The device profile.</param>
-        /// <returns>The reserialized device profile.</returns>
+        /// <returns>The re-serialized device profile.</returns>
         private DeviceProfile ReserializeProfile(DeviceProfile profile)
         {
             if (profile.GetType() == typeof(DeviceProfile))

+ 4 - 4
Emby.Dlna/PlayTo/Device.cs

@@ -480,7 +480,7 @@ namespace Emby.Dlna.PlayTo
                         return;
                     }
 
-                    // If we're not playing anything make sure we don't get data more often than neccessry to keep the Session alive
+                    // If we're not playing anything make sure we don't get data more often than necessary to keep the Session alive
                     if (transportState.Value == TransportState.Stopped)
                     {
                         RestartTimerInactive();
@@ -775,7 +775,7 @@ namespace Emby.Dlna.PlayTo
 
             if (track == null)
             {
-                // If track is null, some vendors do this, use GetMediaInfo instead
+                // If track is null, some vendors do this, use GetMediaInfo instead.
                 return (true, null);
             }
 
@@ -812,7 +812,7 @@ namespace Emby.Dlna.PlayTo
 
         private XElement ParseResponse(string xml)
         {
-            // Handle different variations sent back by devices
+            // Handle different variations sent back by devices.
             try
             {
                 return XElement.Parse(xml);
@@ -821,7 +821,7 @@ namespace Emby.Dlna.PlayTo
             {
             }
 
-            // first try to add a root node with a dlna namesapce
+            // first try to add a root node with a dlna namespace.
             try
             {
                 return XElement.Parse("<data xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">" + xml + "</data>")

+ 4 - 1
Emby.Dlna/PlayTo/PlayToController.cs

@@ -945,7 +945,10 @@ namespace Emby.Dlna.PlayTo
                 request.DeviceId = values.GetValueOrDefault("DeviceId");
                 request.MediaSourceId = values.GetValueOrDefault("MediaSourceId");
                 request.LiveStreamId = values.GetValueOrDefault("LiveStreamId");
-                request.IsDirectStream = string.Equals("true", values.GetValueOrDefault("Static"), StringComparison.OrdinalIgnoreCase);
+
+                // Be careful, IsDirectStream==true by default (Static != false or not in query).
+                // See initialization of StreamingRequestDto in AudioController.GetAudioStream() method : Static = @static ?? true.
+                request.IsDirectStream = !string.Equals("false", values.GetValueOrDefault("Static"), StringComparison.OrdinalIgnoreCase);
 
                 request.AudioStreamIndex = GetIntValue(values, "AudioStreamIndex");
                 request.SubtitleStreamIndex = GetIntValue(values, "SubtitleStreamIndex");

+ 2 - 2
Emby.Dlna/PlayTo/SsdpHttpClient.cs

@@ -45,7 +45,7 @@ namespace Emby.Dlna.PlayTo
                     header,
                     cancellationToken)
                 .ConfigureAwait(false);
-            await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             using var reader = new StreamReader(stream, Encoding.UTF8);
             return XDocument.Parse(
                 await reader.ReadToEndAsync().ConfigureAwait(false),
@@ -94,7 +94,7 @@ namespace Emby.Dlna.PlayTo
             options.Headers.UserAgent.ParseAdd(USERAGENT);
             options.Headers.TryAddWithoutValidation("FriendlyName.DLNA.ORG", FriendlyName);
             using var response = await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(options, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
-            await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             using var reader = new StreamReader(stream, Encoding.UTF8);
             return XDocument.Parse(
                 await reader.ReadToEndAsync().ConfigureAwait(false),

+ 12 - 3
Emby.Naming/Audio/AlbumParser.cs

@@ -1,6 +1,3 @@
-#nullable enable
-#pragma warning disable CS1591
-
 using System;
 using System.Globalization;
 using System.IO;
@@ -9,15 +6,27 @@ using Emby.Naming.Common;
 
 namespace Emby.Naming.Audio
 {
+    /// <summary>
+    /// Helper class to determine if Album is multipart.
+    /// </summary>
     public class AlbumParser
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AlbumParser"/> class.
+        /// </summary>
+        /// <param name="options">Naming options containing AlbumStackingPrefixes.</param>
         public AlbumParser(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Function that determines if album is multipart.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <returns>True if album is multipart.</returns>
         public bool IsMultiPart(string path)
         {
             var filename = Path.GetFileName(path);

+ 9 - 3
Emby.Naming/Audio/AudioFileParser.cs

@@ -1,6 +1,3 @@
-#nullable enable
-#pragma warning disable CS1591
-
 using System;
 using System.IO;
 using System.Linq;
@@ -8,8 +5,17 @@ using Emby.Naming.Common;
 
 namespace Emby.Naming.Audio
 {
+    /// <summary>
+    /// Static helper class to determine if file at path is audio file.
+    /// </summary>
     public static class AudioFileParser
     {
+        /// <summary>
+        /// Static helper method to determine if file at path is audio file.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <param name="options"><see cref="NamingOptions"/> containing AudioFileExtensions.</param>
+        /// <returns>True if file at path is audio file.</returns>
         public static bool IsAudioFile(string path, NamingOptions options)
         {
             var extension = Path.GetExtension(path);

+ 16 - 7
Emby.Naming/AudioBook/AudioBookFileInfo.cs

@@ -7,6 +7,21 @@ namespace Emby.Naming.AudioBook
     /// </summary>
     public class AudioBookFileInfo : IComparable<AudioBookFileInfo>
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AudioBookFileInfo"/> class.
+        /// </summary>
+        /// <param name="path">Path to audiobook file.</param>
+        /// <param name="container">File type.</param>
+        /// <param name="partNumber">Number of part this file represents.</param>
+        /// <param name="chapterNumber">Number of chapter this file represents.</param>
+        public AudioBookFileInfo(string path, string container, int? partNumber = default, int? chapterNumber = default)
+        {
+            Path = path;
+            Container = container;
+            PartNumber = partNumber;
+            ChapterNumber = chapterNumber;
+        }
+
         /// <summary>
         /// Gets or sets the path.
         /// </summary>
@@ -31,14 +46,8 @@ namespace Emby.Naming.AudioBook
         /// <value>The chapter number.</value>
         public int? ChapterNumber { get; set; }
 
-        /// <summary>
-        /// Gets or sets a value indicating whether this instance is a directory.
-        /// </summary>
-        /// <value>The type.</value>
-        public bool IsDirectory { get; set; }
-
         /// <inheritdoc />
-        public int CompareTo(AudioBookFileInfo other)
+        public int CompareTo(AudioBookFileInfo? other)
         {
             if (ReferenceEquals(this, other))
             {

+ 12 - 5
Emby.Naming/AudioBook/AudioBookFilePathParser.cs

@@ -1,6 +1,3 @@
-#nullable enable
-#pragma warning disable CS1591
-
 using System.Globalization;
 using System.IO;
 using System.Text.RegularExpressions;
@@ -8,15 +5,27 @@ using Emby.Naming.Common;
 
 namespace Emby.Naming.AudioBook
 {
+    /// <summary>
+    /// Parser class to extract part and/or chapter number from audiobook filename.
+    /// </summary>
     public class AudioBookFilePathParser
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AudioBookFilePathParser"/> class.
+        /// </summary>
+        /// <param name="options">Naming options containing AudioBookPartsExpressions.</param>
         public AudioBookFilePathParser(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Based on regex determines if filename includes part/chapter number.
+        /// </summary>
+        /// <param name="path">Path to audiobook file.</param>
+        /// <returns>Returns <see cref="AudioBookFilePathParser"/> object.</returns>
         public AudioBookFilePathParserResult Parse(string path)
         {
             AudioBookFilePathParserResult result = default;
@@ -52,8 +61,6 @@ namespace Emby.Naming.AudioBook
                 }
             }
 
-            result.Success = result.ChapterNumber.HasValue || result.PartNumber.HasValue;
-
             return result;
         }
     }

+ 9 - 5
Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs

@@ -1,14 +1,18 @@
-#nullable enable
-#pragma warning disable CS1591
-
 namespace Emby.Naming.AudioBook
 {
+    /// <summary>
+    /// Data object for passing result of audiobook part/chapter extraction.
+    /// </summary>
     public struct AudioBookFilePathParserResult
     {
+        /// <summary>
+        /// Gets or sets optional number of path extracted from audiobook filename.
+        /// </summary>
         public int? PartNumber { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional number of chapter extracted from audiobook filename.
+        /// </summary>
         public int? ChapterNumber { get; set; }
-
-        public bool Success { get; set; }
     }
 }

+ 11 - 4
Emby.Naming/AudioBook/AudioBookInfo.cs

@@ -10,11 +10,18 @@ namespace Emby.Naming.AudioBook
         /// <summary>
         /// Initializes a new instance of the <see cref="AudioBookInfo" /> class.
         /// </summary>
-        public AudioBookInfo()
+        /// <param name="name">Name of audiobook.</param>
+        /// <param name="year">Year of audiobook release.</param>
+        /// <param name="files">List of files composing the actual audiobook.</param>
+        /// <param name="extras">List of extra files.</param>
+        /// <param name="alternateVersions">Alternative version of files.</param>
+        public AudioBookInfo(string name, int? year, List<AudioBookFileInfo>? files, List<AudioBookFileInfo>? extras, List<AudioBookFileInfo>? alternateVersions)
         {
-            Files = new List<AudioBookFileInfo>();
-            Extras = new List<AudioBookFileInfo>();
-            AlternateVersions = new List<AudioBookFileInfo>();
+            Name = name;
+            Year = year;
+            Files = files ?? new List<AudioBookFileInfo>();
+            Extras = extras ?? new List<AudioBookFileInfo>();
+            AlternateVersions = alternateVersions ?? new List<AudioBookFileInfo>();
         }
 
         /// <summary>

+ 117 - 12
Emby.Naming/AudioBook/AudioBookListResolver.cs

@@ -1,6 +1,6 @@
-#pragma warning disable CS1591
-
+using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using Emby.Naming.Common;
 using Emby.Naming.Video;
@@ -8,40 +8,145 @@ using MediaBrowser.Model.IO;
 
 namespace Emby.Naming.AudioBook
 {
+    /// <summary>
+    /// Class used to resolve Name, Year, alternative files and extras from stack of files.
+    /// </summary>
     public class AudioBookListResolver
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AudioBookListResolver"/> class.
+        /// </summary>
+        /// <param name="options">Naming options passed along to <see cref="AudioBookResolver"/> and <see cref="AudioBookNameParser"/>.</param>
         public AudioBookListResolver(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Resolves Name, Year and differentiate alternative files and extras from regular audiobook files.
+        /// </summary>
+        /// <param name="files">List of files related to audiobook.</param>
+        /// <returns>Returns IEnumerable of <see cref="AudioBookInfo"/>.</returns>
         public IEnumerable<AudioBookInfo> Resolve(IEnumerable<FileSystemMetadata> files)
         {
             var audioBookResolver = new AudioBookResolver(_options);
 
+            // File with empty fullname will be sorted out here.
             var audiobookFileInfos = files
-                .Select(i => audioBookResolver.Resolve(i.FullName, i.IsDirectory))
-                .Where(i => i != null)
+                .Select(i => audioBookResolver.Resolve(i.FullName))
+                .OfType<AudioBookFileInfo>()
                 .ToList();
 
-            // Filter out all extras, otherwise they could cause stacks to not be resolved
-            // See the unit test TestStackedWithTrailer
-            var metadata = audiobookFileInfos
-                .Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory });
-
             var stackResult = new StackResolver(_options)
-                .ResolveAudioBooks(metadata);
+                .ResolveAudioBooks(audiobookFileInfos);
 
             foreach (var stack in stackResult)
             {
-                var stackFiles = stack.Files.Select(i => audioBookResolver.Resolve(i, stack.IsDirectoryStack)).ToList();
+                var stackFiles = stack.Files
+                    .Select(i => audioBookResolver.Resolve(i))
+                    .OfType<AudioBookFileInfo>()
+                    .ToList();
+
                 stackFiles.Sort();
-                var info = new AudioBookInfo { Files = stackFiles, Name = stack.Name };
+
+                var nameParserResult = new AudioBookNameParser(_options).Parse(stack.Name);
+
+                FindExtraAndAlternativeFiles(ref stackFiles, out var extras, out var alternativeVersions, nameParserResult);
+
+                var info = new AudioBookInfo(
+                    nameParserResult.Name,
+                    nameParserResult.Year,
+                    stackFiles,
+                    extras,
+                    alternativeVersions);
 
                 yield return info;
             }
         }
+
+        private void FindExtraAndAlternativeFiles(ref List<AudioBookFileInfo> stackFiles, out List<AudioBookFileInfo> extras, out List<AudioBookFileInfo> alternativeVersions, AudioBookNameParserResult nameParserResult)
+        {
+            extras = new List<AudioBookFileInfo>();
+            alternativeVersions = new List<AudioBookFileInfo>();
+
+            var haveChaptersOrPages = stackFiles.Any(x => x.ChapterNumber != null || x.PartNumber != null);
+            var groupedBy = stackFiles.GroupBy(file => new { file.ChapterNumber, file.PartNumber });
+            var nameWithReplacedDots = nameParserResult.Name.Replace(" ", ".");
+
+            foreach (var group in groupedBy)
+            {
+                if (group.Key.ChapterNumber == null && group.Key.PartNumber == null)
+                {
+                    if (group.Count() > 1 || haveChaptersOrPages)
+                    {
+                        var ex = new List<AudioBookFileInfo>();
+                        var alt = new List<AudioBookFileInfo>();
+
+                        foreach (var audioFile in group)
+                        {
+                            var name = Path.GetFileNameWithoutExtension(audioFile.Path);
+                            if (name.Equals("audiobook") ||
+                                name.Contains(nameParserResult.Name, StringComparison.OrdinalIgnoreCase) ||
+                                name.Contains(nameWithReplacedDots, StringComparison.OrdinalIgnoreCase))
+                            {
+                                alt.Add(audioFile);
+                            }
+                            else
+                            {
+                                ex.Add(audioFile);
+                            }
+                        }
+
+                        if (ex.Count > 0)
+                        {
+                            var extra = ex
+                                .OrderBy(x => x.Container)
+                                .ThenBy(x => x.Path)
+                                .ToList();
+
+                            stackFiles = stackFiles.Except(extra).ToList();
+                            extras.AddRange(extra);
+                        }
+
+                        if (alt.Count > 0)
+                        {
+                            var alternatives = alt
+                                .OrderBy(x => x.Container)
+                                .ThenBy(x => x.Path)
+                                .ToList();
+
+                            var main = FindMainAudioBookFile(alternatives, nameParserResult.Name);
+                            alternatives.Remove(main);
+                            stackFiles = stackFiles.Except(alternatives).ToList();
+                            alternativeVersions.AddRange(alternatives);
+                        }
+                    }
+                }
+                else if (group.Count() > 1)
+                {
+                    var alternatives = group
+                        .OrderBy(x => x.Container)
+                        .ThenBy(x => x.Path)
+                        .Skip(1)
+                        .ToList();
+
+                    stackFiles = stackFiles.Except(alternatives).ToList();
+                    alternativeVersions.AddRange(alternatives);
+                }
+            }
+        }
+
+        private AudioBookFileInfo FindMainAudioBookFile(List<AudioBookFileInfo> files, string name)
+        {
+            var main = files.Find(x => Path.GetFileNameWithoutExtension(x.Path).Equals(name, StringComparison.OrdinalIgnoreCase));
+            main ??= files.FirstOrDefault(x => Path.GetFileNameWithoutExtension(x.Path).Equals("audiobook", StringComparison.OrdinalIgnoreCase));
+            main ??= files.OrderBy(x => x.Container)
+                .ThenBy(x => x.Path)
+                .First();
+
+            return main;
+        }
     }
 }

+ 67 - 0
Emby.Naming/AudioBook/AudioBookNameParser.cs

@@ -0,0 +1,67 @@
+using System.Globalization;
+using System.Text.RegularExpressions;
+using Emby.Naming.Common;
+
+namespace Emby.Naming.AudioBook
+{
+    /// <summary>
+    /// Helper class to retrieve name and year from audiobook previously retrieved name.
+    /// </summary>
+    public class AudioBookNameParser
+    {
+        private readonly NamingOptions _options;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AudioBookNameParser"/> class.
+        /// </summary>
+        /// <param name="options">Naming options containing AudioBookNamesExpressions.</param>
+        public AudioBookNameParser(NamingOptions options)
+        {
+            _options = options;
+        }
+
+        /// <summary>
+        /// Parse name and year from previously determined name of audiobook.
+        /// </summary>
+        /// <param name="name">Name of the audiobook.</param>
+        /// <returns>Returns <see cref="AudioBookNameParserResult"/> object.</returns>
+        public AudioBookNameParserResult Parse(string name)
+        {
+            AudioBookNameParserResult result = default;
+            foreach (var expression in _options.AudioBookNamesExpressions)
+            {
+                var match = new Regex(expression, RegexOptions.IgnoreCase).Match(name);
+                if (match.Success)
+                {
+                    if (result.Name == null)
+                    {
+                        var value = match.Groups["name"];
+                        if (value.Success)
+                        {
+                            result.Name = value.Value;
+                        }
+                    }
+
+                    if (!result.Year.HasValue)
+                    {
+                        var value = match.Groups["year"];
+                        if (value.Success)
+                        {
+                            if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intValue))
+                            {
+                                result.Year = intValue;
+                            }
+                        }
+                    }
+                }
+            }
+
+            if (string.IsNullOrEmpty(result.Name))
+            {
+                result.Name = name;
+            }
+
+            return result;
+        }
+    }
+}

+ 18 - 0
Emby.Naming/AudioBook/AudioBookNameParserResult.cs

@@ -0,0 +1,18 @@
+namespace Emby.Naming.AudioBook
+{
+    /// <summary>
+    /// Data object used to pass result of name and year parsing.
+    /// </summary>
+    public struct AudioBookNameParserResult
+    {
+        /// <summary>
+        /// Gets or sets name of audiobook.
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// Gets or sets optional year of release.
+        /// </summary>
+        public int? Year { get; set; }
+    }
+}

+ 20 - 19
Emby.Naming/AudioBook/AudioBookResolver.cs

@@ -1,6 +1,3 @@
-#nullable enable
-#pragma warning disable CS1591
-
 using System;
 using System.IO;
 using System.Linq;
@@ -8,25 +5,32 @@ using Emby.Naming.Common;
 
 namespace Emby.Naming.AudioBook
 {
+    /// <summary>
+    /// Resolve specifics (path, container, partNumber, chapterNumber) about audiobook file.
+    /// </summary>
     public class AudioBookResolver
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="AudioBookResolver"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> containing AudioFileExtensions and also used to pass to AudioBookFilePathParser.</param>
         public AudioBookResolver(NamingOptions options)
         {
             _options = options;
         }
 
-        public AudioBookFileInfo? Resolve(string path, bool isDirectory = false)
+        /// <summary>
+        /// Resolve specifics (path, container, partNumber, chapterNumber) about audiobook file.
+        /// </summary>
+        /// <param name="path">Path to audiobook file.</param>
+        /// <returns>Returns <see cref="AudioBookResolver"/> object.</returns>
+        public AudioBookFileInfo? Resolve(string path)
         {
-            if (path.Length == 0)
-            {
-                throw new ArgumentException("String can't be empty.", nameof(path));
-            }
-
-            // TODO
-            if (isDirectory)
+            if (path.Length == 0 || Path.GetFileNameWithoutExtension(path).Length == 0)
             {
+                // Return null to indicate this path will not be used, instead of stopping whole process with exception
                 return null;
             }
 
@@ -42,14 +46,11 @@ namespace Emby.Naming.AudioBook
 
             var parsingResult = new AudioBookFilePathParser(_options).Parse(path);
 
-            return new AudioBookFileInfo
-            {
-                Path = path,
-                Container = container,
-                ChapterNumber = parsingResult.ChapterNumber,
-                PartNumber = parsingResult.PartNumber,
-                IsDirectory = isDirectory
-            };
+            return new AudioBookFileInfo(
+                path,
+                container,
+                chapterNumber: parsingResult.ChapterNumber,
+                partNumber: parsingResult.PartNumber);
         }
     }
 }

+ 32 - 10
Emby.Naming/Common/EpisodeExpression.cs

@@ -1,28 +1,32 @@
-#pragma warning disable CS1591
-
 using System;
 using System.Text.RegularExpressions;
 
 namespace Emby.Naming.Common
 {
+    /// <summary>
+    /// Regular expressions for parsing TV Episodes.
+    /// </summary>
     public class EpisodeExpression
     {
         private string _expression;
-        private Regex _regex;
+        private Regex? _regex;
 
-        public EpisodeExpression(string expression, bool byDate)
+        /// <summary>
+        /// Initializes a new instance of the <see cref="EpisodeExpression"/> class.
+        /// </summary>
+        /// <param name="expression">Regular expressions.</param>
+        /// <param name="byDate">True if date is expected.</param>
+        public EpisodeExpression(string expression, bool byDate = false)
         {
-            Expression = expression;
+            _expression = expression;
             IsByDate = byDate;
             DateTimeFormats = Array.Empty<string>();
             SupportsAbsoluteEpisodeNumbers = true;
         }
 
-        public EpisodeExpression(string expression)
-            : this(expression, false)
-        {
-        }
-
+        /// <summary>
+        /// Gets or sets raw expressions string.
+        /// </summary>
         public string Expression
         {
             get => _expression;
@@ -33,16 +37,34 @@ namespace Emby.Naming.Common
             }
         }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether gets or sets property indicating if date can be find in expression.
+        /// </summary>
         public bool IsByDate { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether gets or sets property indicating if expression is optimistic.
+        /// </summary>
         public bool IsOptimistic { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether gets or sets property indicating if expression is named.
+        /// </summary>
         public bool IsNamed { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether gets or sets property indicating if expression supports episodes with absolute numbers.
+        /// </summary>
         public bool SupportsAbsoluteEpisodeNumbers { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional list of date formats used for date parsing.
+        /// </summary>
         public string[] DateTimeFormats { get; set; }
 
+        /// <summary>
+        /// Gets a <see cref="Regex"/> expressions objects (creates it if null).
+        /// </summary>
         public Regex Regex => _regex ??= new Regex(Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled);
     }
 }

+ 3 - 2
Emby.Naming/Common/MediaType.cs

@@ -1,7 +1,8 @@
-#pragma warning disable CS1591
-
 namespace Emby.Naming.Common
 {
+    /// <summary>
+    /// Type of audiovisual media.
+    /// </summary>
     public enum MediaType
     {
         /// <summary>

+ 342 - 306
Emby.Naming/Common/NamingOptions.cs

@@ -1,15 +1,21 @@
-#pragma warning disable CS1591
-
 using System;
 using System.Linq;
 using System.Text.RegularExpressions;
 using Emby.Naming.Video;
 using MediaBrowser.Model.Entities;
 
+// ReSharper disable StringLiteralTypo
+
 namespace Emby.Naming.Common
 {
+    /// <summary>
+    /// Big ugly class containing lot of different naming options that should be split and injected instead of passes everywhere.
+    /// </summary>
     public class NamingOptions
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="NamingOptions"/> class.
+        /// </summary>
         public NamingOptions()
         {
             VideoFileExtensions = new[]
@@ -75,63 +81,52 @@ namespace Emby.Naming.Common
 
             StubTypes = new[]
             {
-                new StubTypeRule
-                {
-                    StubType = "dvd",
-                    Token = "dvd"
-                },
-                new StubTypeRule
-                {
-                    StubType = "hddvd",
-                    Token = "hddvd"
-                },
-                new StubTypeRule
-                {
-                    StubType = "bluray",
-                    Token = "bluray"
-                },
-                new StubTypeRule
-                {
-                    StubType = "bluray",
-                    Token = "brrip"
-                },
-                new StubTypeRule
-                {
-                    StubType = "bluray",
-                    Token = "bd25"
-                },
-                new StubTypeRule
-                {
-                    StubType = "bluray",
-                    Token = "bd50"
-                },
-                new StubTypeRule
-                {
-                    StubType = "vhs",
-                    Token = "vhs"
-                },
-                new StubTypeRule
-                {
-                    StubType = "tv",
-                    Token = "HDTV"
-                },
-                new StubTypeRule
-                {
-                    StubType = "tv",
-                    Token = "PDTV"
-                },
-                new StubTypeRule
-                {
-                    StubType = "tv",
-                    Token = "DSR"
-                }
+                new StubTypeRule(
+                    stubType: "dvd",
+                    token: "dvd"),
+
+                new StubTypeRule(
+                    stubType: "hddvd",
+                    token: "hddvd"),
+
+                new StubTypeRule(
+                    stubType: "bluray",
+                    token: "bluray"),
+
+                new StubTypeRule(
+                    stubType: "bluray",
+                    token: "brrip"),
+
+                new StubTypeRule(
+                    stubType: "bluray",
+                    token: "bd25"),
+
+                new StubTypeRule(
+                    stubType: "bluray",
+                    token: "bd50"),
+
+                new StubTypeRule(
+                    stubType: "vhs",
+                    token: "vhs"),
+
+                new StubTypeRule(
+                    stubType: "tv",
+                    token: "HDTV"),
+
+                new StubTypeRule(
+                    stubType: "tv",
+                    token: "PDTV"),
+
+                new StubTypeRule(
+                    stubType: "tv",
+                    token: "DSR")
             };
 
             VideoFileStackingExpressions = new[]
             {
-                "(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(.*?)(\\.[^.]+)$",
-                "(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(.*?)(\\.[^.]+)$",
-                "(.*?)([ ._-]*[a-d])(.*?)(\\.[^.]+)$"
+                "(?<title>.*?)(?<volume>[ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(?<ignore>.*?)(?<extension>\\.[^.]+)$",
+                "(?<title>.*?)(?<volume>[ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(?<ignore>.*?)(?<extension>\\.[^.]+)$",
+                "(?<title>.*?)(?<volume>[ ._-]*[a-d])(?<ignore>.*?)(?<extension>\\.[^.]+)$"
             };
 
             CleanDateTimes = new[]
@@ -142,7 +137,7 @@ namespace Emby.Naming.Common
 
             CleanStrings = new[]
             {
-                @"[ _\,\.\(\)\[\]\-](3d|sbs|tab|hsbs|htab|mvc|HDR|HDC|UHD|UltraHD|4k|ac3|dts|custom|dc|divx|divx5|dsr|dsrip|dutch|dvd|dvdrip|dvdscr|dvdscreener|screener|dvdivx|cam|fragment|fs|hdtv|hdrip|hdtvrip|internal|limited|multisubs|ntsc|ogg|ogm|pal|pdtv|proper|repack|rerip|retail|cd[1-9]|r3|r5|bd5|bd|se|svcd|swedish|german|read.nfo|nfofix|unrated|ws|telesync|ts|telecine|tc|brrip|bdrip|480p|480i|576p|576i|720p|720i|1080p|1080i|2160p|hrhd|hrhdtv|hddvd|bluray|x264|h264|xvid|xvidvd|xxx|www.www|\[.*\])([ _\,\.\(\)\[\]\-]|$)",
+                @"[ _\,\.\(\)\[\]\-](3d|sbs|tab|hsbs|htab|mvc|HDR|HDC|UHD|UltraHD|4k|ac3|dts|custom|dc|divx|divx5|dsr|dsrip|dutch|dvd|dvdrip|dvdscr|dvdscreener|screener|dvdivx|cam|fragment|fs|hdtv|hdrip|hdtvrip|internal|limited|multisubs|ntsc|ogg|ogm|pal|pdtv|proper|repack|rerip|retail|cd[1-9]|r3|r5|bd5|bd|se|svcd|swedish|german|read.nfo|nfofix|unrated|ws|telesync|ts|telecine|tc|brrip|bdrip|480p|480i|576p|576i|720p|720i|1080p|1080i|2160p|hrhd|hrhdtv|hddvd|bluray|blu-ray|x264|x265|h264|xvid|xvidvd|xxx|www.www|AAC|DTS|\[.*\])([ _\,\.\(\)\[\]\-]|$)",
                 @"(\[.*\])"
             };
 
@@ -255,7 +250,7 @@ namespace Emby.Naming.Common
                 },
                 // <!-- foo.ep01, foo.EP_01 -->
                 new EpisodeExpression(@"[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$"),
-                new EpisodeExpression("([0-9]{4})[\\.-]([0-9]{2})[\\.-]([0-9]{2})", true)
+                new EpisodeExpression("(?<year>[0-9]{4})[\\.-](?<month>[0-9]{2})[\\.-](?<day>[0-9]{2})", true)
                 {
                     DateTimeFormats = new[]
                     {
@@ -264,7 +259,7 @@ namespace Emby.Naming.Common
                         "yyyy_MM_dd"
                     }
                 },
-                new EpisodeExpression("([0-9]{2})[\\.-]([0-9]{2})[\\.-]([0-9]{4})", true)
+                new EpisodeExpression(@"(?<day>[0-9]{2})[.-](?<month>[0-9]{2})[.-](?<year>[0-9]{4})", true)
                 {
                     DateTimeFormats = new[]
                     {
@@ -286,7 +281,12 @@ namespace Emby.Naming.Common
                 {
                     SupportsAbsoluteEpisodeNumbers = true
                 },
-                new EpisodeExpression(@"[\\\\/\\._ -](?<seriesname>(?![0-9]+[0-9][0-9])([^\\\/])*)[\\\\/\\._ -](?<seasonnumber>[0-9]+)(?<epnumber>[0-9][0-9](?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([\\._ -][^\\\\/]*)$")
+
+                // Case Closed (1996-2007)/Case Closed - 317.mkv
+                // /server/anything_102.mp4
+                // /server/james.corden.2017.04.20.anne.hathaway.720p.hdtv.x264-crooks.mkv
+                // /server/anything_1996.11.14.mp4
+                new EpisodeExpression(@"[\\/._ -](?<seriesname>(?![0-9]+[0-9][0-9])([^\\\/_])*)[\\\/._ -](?<seasonnumber>[0-9]+)(?<epnumber>[0-9][0-9](?:(?:[a-i]|\.[1-9])(?![0-9]))?)([._ -][^\\\/]*)$")
                 {
                     IsOptimistic = true,
                     IsNamed = true,
@@ -381,247 +381,193 @@ namespace Emby.Naming.Common
 
             VideoExtraRules = new[]
             {
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Trailer,
-                    RuleType = ExtraRuleType.Filename,
-                    Token = "trailer",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Trailer,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "-trailer",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Trailer,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = ".trailer",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Trailer,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "_trailer",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Trailer,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = " trailer",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Sample,
-                    RuleType = ExtraRuleType.Filename,
-                    Token = "sample",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Sample,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "-sample",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Sample,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = ".sample",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Sample,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "_sample",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Sample,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = " sample",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.ThemeSong,
-                    RuleType = ExtraRuleType.Filename,
-                    Token = "theme",
-                    MediaType = MediaType.Audio
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Scene,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "-scene",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Clip,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "-clip",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Interview,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "-interview",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.BehindTheScenes,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "-behindthescenes",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.DeletedScene,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "-deleted",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Clip,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "-featurette",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Clip,
-                    RuleType = ExtraRuleType.Suffix,
-                    Token = "-short",
-                    MediaType = MediaType.Video
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.BehindTheScenes,
-                    RuleType = ExtraRuleType.DirectoryName,
-                    Token = "behind the scenes",
-                    MediaType = MediaType.Video,
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.DeletedScene,
-                    RuleType = ExtraRuleType.DirectoryName,
-                    Token = "deleted scenes",
-                    MediaType = MediaType.Video,
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Interview,
-                    RuleType = ExtraRuleType.DirectoryName,
-                    Token = "interviews",
-                    MediaType = MediaType.Video,
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Scene,
-                    RuleType = ExtraRuleType.DirectoryName,
-                    Token = "scenes",
-                    MediaType = MediaType.Video,
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Sample,
-                    RuleType = ExtraRuleType.DirectoryName,
-                    Token = "samples",
-                    MediaType = MediaType.Video,
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Clip,
-                    RuleType = ExtraRuleType.DirectoryName,
-                    Token = "shorts",
-                    MediaType = MediaType.Video,
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Clip,
-                    RuleType = ExtraRuleType.DirectoryName,
-                    Token = "featurettes",
-                    MediaType = MediaType.Video,
-                },
-                new ExtraRule
-                {
-                    ExtraType = ExtraType.Unknown,
-                    RuleType = ExtraRuleType.DirectoryName,
-                    Token = "extras",
-                    MediaType = MediaType.Video,
-                },
+                new ExtraRule(
+                    ExtraType.Trailer,
+                    ExtraRuleType.Filename,
+                    "trailer",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Trailer,
+                    ExtraRuleType.Suffix,
+                    "-trailer",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Trailer,
+                    ExtraRuleType.Suffix,
+                    ".trailer",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Trailer,
+                    ExtraRuleType.Suffix,
+                    "_trailer",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Trailer,
+                    ExtraRuleType.Suffix,
+                    " trailer",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Sample,
+                    ExtraRuleType.Filename,
+                    "sample",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Sample,
+                    ExtraRuleType.Suffix,
+                    "-sample",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Sample,
+                    ExtraRuleType.Suffix,
+                    ".sample",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Sample,
+                    ExtraRuleType.Suffix,
+                    "_sample",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Sample,
+                    ExtraRuleType.Suffix,
+                    " sample",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.ThemeSong,
+                    ExtraRuleType.Filename,
+                    "theme",
+                    MediaType.Audio),
+
+                new ExtraRule(
+                    ExtraType.Scene,
+                    ExtraRuleType.Suffix,
+                    "-scene",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Clip,
+                    ExtraRuleType.Suffix,
+                    "-clip",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Interview,
+                    ExtraRuleType.Suffix,
+                    "-interview",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.BehindTheScenes,
+                    ExtraRuleType.Suffix,
+                    "-behindthescenes",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.DeletedScene,
+                    ExtraRuleType.Suffix,
+                    "-deleted",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Clip,
+                    ExtraRuleType.Suffix,
+                    "-featurette",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Clip,
+                    ExtraRuleType.Suffix,
+                    "-short",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.BehindTheScenes,
+                    ExtraRuleType.DirectoryName,
+                    "behind the scenes",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.DeletedScene,
+                    ExtraRuleType.DirectoryName,
+                    "deleted scenes",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Interview,
+                    ExtraRuleType.DirectoryName,
+                    "interviews",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Scene,
+                    ExtraRuleType.DirectoryName,
+                    "scenes",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Sample,
+                    ExtraRuleType.DirectoryName,
+                    "samples",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Clip,
+                    ExtraRuleType.DirectoryName,
+                    "shorts",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Clip,
+                    ExtraRuleType.DirectoryName,
+                    "featurettes",
+                    MediaType.Video),
+
+                new ExtraRule(
+                    ExtraType.Unknown,
+                    ExtraRuleType.DirectoryName,
+                    "extras",
+                    MediaType.Video),
             };
 
             Format3DRules = new[]
             {
                 // Kodi rules:
-                new Format3DRule
-                {
-                    PreceedingToken = "3d",
-                    Token = "hsbs"
-                },
-                new Format3DRule
-                {
-                    PreceedingToken = "3d",
-                    Token = "sbs"
-                },
-                new Format3DRule
-                {
-                    PreceedingToken = "3d",
-                    Token = "htab"
-                },
-                new Format3DRule
-                {
-                    PreceedingToken = "3d",
-                    Token = "tab"
-                },
-                                 // Media Browser rules:
-                new Format3DRule
-                {
-                    Token = "fsbs"
-                },
-                new Format3DRule
-                {
-                    Token = "hsbs"
-                },
-                new Format3DRule
-                {
-                    Token = "sbs"
-                },
-                new Format3DRule
-                {
-                    Token = "ftab"
-                },
-                new Format3DRule
-                {
-                    Token = "htab"
-                },
-                new Format3DRule
-                {
-                    Token = "tab"
-                },
-                new Format3DRule
-                {
-                    Token = "sbs3d"
-                },
-                new Format3DRule
-                {
-                    Token = "mvc"
-                }
+                new Format3DRule(
+                    precedingToken: "3d",
+                    token: "hsbs"),
+
+                new Format3DRule(
+                    precedingToken: "3d",
+                    token: "sbs"),
+
+                new Format3DRule(
+                    precedingToken: "3d",
+                    token: "htab"),
+
+                new Format3DRule(
+                    precedingToken: "3d",
+                    token: "tab"),
+
+                 // Media Browser rules:
+                new Format3DRule("fsbs"),
+                new Format3DRule("hsbs"),
+                new Format3DRule("sbs"),
+                new Format3DRule("ftab"),
+                new Format3DRule("htab"),
+                new Format3DRule("tab"),
+                new Format3DRule("sbs3d"),
+                new Format3DRule("mvc")
             };
+
             AudioBookPartsExpressions = new[]
             {
                 // Detect specified chapters, like CH 01
@@ -631,13 +577,20 @@ namespace Emby.Naming.Common
                 // Chapter is often beginning of filename
                 "^(?<chapter>[0-9]+)",
                 // Part if often ending of filename
-                "(?<part>[0-9]+)$",
+                @"(?<!ch(?:apter) )(?<part>[0-9]+)$",
                 // Sometimes named as 0001_005 (chapter_part)
                 "(?<chapter>[0-9]+)_(?<part>[0-9]+)",
                 // Some audiobooks are ripped from cd's, and will be named by disk number.
                 @"dis(?:c|k)[\s_-]?(?<chapter>[0-9]+)"
             };
 
+            AudioBookNamesExpressions = new[]
+            {
+                // Detect year usually in brackets after name Batman (2020)
+                @"^(?<name>.+?)\s*\(\s*(?<year>\d{4})\s*\)\s*$",
+                @"^\s*(?<name>[^ ].*?)\s*$"
+            };
+
             var extensions = VideoFileExtensions.ToList();
 
             extensions.AddRange(new[]
@@ -673,7 +626,7 @@ namespace Emby.Naming.Common
                 ".mxf"
             });
 
-            MultipleEpisodeExpressions = new string[]
+            MultipleEpisodeExpressions = new[]
             {
                 @".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})((-| - )[0-9]{1,4}[eExX](?<endingepnumber>[0-9]{1,3}))+[^\\\/]*$",
                 @".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})((-| - )[0-9]{1,4}[xX][eE](?<endingepnumber>[0-9]{1,3}))+[^\\\/]*$",
@@ -697,56 +650,139 @@ namespace Emby.Naming.Common
             Compile();
         }
 
+        /// <summary>
+        /// Gets or sets list of audio file extensions.
+        /// </summary>
         public string[] AudioFileExtensions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of album stacking prefixes.
+        /// </summary>
         public string[] AlbumStackingPrefixes { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of subtitle file extensions.
+        /// </summary>
         public string[] SubtitleFileExtensions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of subtitles flag delimiters.
+        /// </summary>
         public char[] SubtitleFlagDelimiters { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of subtitle forced flags.
+        /// </summary>
         public string[] SubtitleForcedFlags { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of subtitle default flags.
+        /// </summary>
         public string[] SubtitleDefaultFlags { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of episode regular expressions.
+        /// </summary>
         public EpisodeExpression[] EpisodeExpressions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of raw episode without season regular expressions strings.
+        /// </summary>
         public string[] EpisodeWithoutSeasonExpressions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of raw multi-part episodes regular expressions strings.
+        /// </summary>
         public string[] EpisodeMultiPartExpressions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of video file extensions.
+        /// </summary>
         public string[] VideoFileExtensions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of video stub file extensions.
+        /// </summary>
         public string[] StubFileExtensions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of raw audiobook parts regular expressions strings.
+        /// </summary>
         public string[] AudioBookPartsExpressions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of raw audiobook names regular expressions strings.
+        /// </summary>
+        public string[] AudioBookNamesExpressions { get; set; }
+
+        /// <summary>
+        /// Gets or sets list of stub type rules.
+        /// </summary>
         public StubTypeRule[] StubTypes { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of video flag delimiters.
+        /// </summary>
         public char[] VideoFlagDelimiters { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of 3D Format rules.
+        /// </summary>
         public Format3DRule[] Format3DRules { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of raw video file-stacking expressions strings.
+        /// </summary>
         public string[] VideoFileStackingExpressions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of raw clean DateTimes regular expressions strings.
+        /// </summary>
         public string[] CleanDateTimes { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of raw clean strings regular expressions strings.
+        /// </summary>
         public string[] CleanStrings { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of multi-episode regular expressions.
+        /// </summary>
         public EpisodeExpression[] MultipleEpisodeExpressions { get; set; }
 
+        /// <summary>
+        /// Gets or sets list of extra rules for videos.
+        /// </summary>
         public ExtraRule[] VideoExtraRules { get; set; }
 
-        public Regex[] VideoFileStackingRegexes { get; private set; }
-
-        public Regex[] CleanDateTimeRegexes { get; private set; }
-
-        public Regex[] CleanStringRegexes { get; private set; }
-
-        public Regex[] EpisodeWithoutSeasonRegexes { get; private set; }
-
-        public Regex[] EpisodeMultiPartRegexes { get; private set; }
-
+        /// <summary>
+        /// Gets list of video file-stack regular expressions.
+        /// </summary>
+        public Regex[] VideoFileStackingRegexes { get; private set; } = Array.Empty<Regex>();
+
+        /// <summary>
+        /// Gets list of clean datetime regular expressions.
+        /// </summary>
+        public Regex[] CleanDateTimeRegexes { get; private set; } = Array.Empty<Regex>();
+
+        /// <summary>
+        /// Gets list of clean string regular expressions.
+        /// </summary>
+        public Regex[] CleanStringRegexes { get; private set; } = Array.Empty<Regex>();
+
+        /// <summary>
+        /// Gets list of episode without season regular expressions.
+        /// </summary>
+        public Regex[] EpisodeWithoutSeasonRegexes { get; private set; } = Array.Empty<Regex>();
+
+        /// <summary>
+        /// Gets list of multi-part episode regular expressions.
+        /// </summary>
+        public Regex[] EpisodeMultiPartRegexes { get; private set; } = Array.Empty<Regex>();
+
+        /// <summary>
+        /// Compiles raw regex strings into regexes.
+        /// </summary>
         public void Compile()
         {
             VideoFileStackingRegexes = VideoFileStackingExpressions.Select(Compile).ToArray();

+ 2 - 1
Emby.Naming/Emby.Naming.csproj

@@ -14,6 +14,7 @@
     <EmbedUntrackedSources>true</EmbedUntrackedSources>
     <IncludeSymbols>true</IncludeSymbols>
     <SymbolPackageFormat>snupkg</SymbolPackageFormat>
+    <Nullable>enable</Nullable>
   </PropertyGroup>
 
   <PropertyGroup Condition=" '$(Stability)'=='Unstable'">
@@ -38,7 +39,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
+    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
   </ItemGroup>
 
   <!-- Code Analyzers-->

+ 17 - 3
Emby.Naming/Subtitles/SubtitleInfo.cs

@@ -1,9 +1,23 @@
-#pragma warning disable CS1591
-
 namespace Emby.Naming.Subtitles
 {
+    /// <summary>
+    /// Class holding information about subtitle.
+    /// </summary>
     public class SubtitleInfo
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SubtitleInfo"/> class.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <param name="isDefault">Is subtitle default.</param>
+        /// <param name="isForced">Is subtitle forced.</param>
+        public SubtitleInfo(string path, bool isDefault, bool isForced)
+        {
+            Path = path;
+            IsDefault = isDefault;
+            IsForced = isForced;
+        }
+
         /// <summary>
         /// Gets or sets the path.
         /// </summary>
@@ -14,7 +28,7 @@ namespace Emby.Naming.Subtitles
         /// Gets or sets the language.
         /// </summary>
         /// <value>The language.</value>
-        public string Language { get; set; }
+        public string? Language { get; set; }
 
         /// <summary>
         /// Gets or sets a value indicating whether this instance is default.

+ 18 - 11
Emby.Naming/Subtitles/SubtitleParser.cs

@@ -1,6 +1,3 @@
-#nullable enable
-#pragma warning disable CS1591
-
 using System;
 using System.IO;
 using System.Linq;
@@ -8,20 +5,32 @@ using Emby.Naming.Common;
 
 namespace Emby.Naming.Subtitles
 {
+    /// <summary>
+    /// Subtitle Parser class.
+    /// </summary>
     public class SubtitleParser
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SubtitleParser"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> object containing SubtitleFileExtensions, SubtitleDefaultFlags, SubtitleForcedFlags and SubtitleFlagDelimiters.</param>
         public SubtitleParser(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Parse file to determine if is subtitle and <see cref="SubtitleInfo"/>.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <returns>Returns null or <see cref="SubtitleInfo"/> object if parsing is successful.</returns>
         public SubtitleInfo? ParseFile(string path)
         {
             if (path.Length == 0)
             {
-                throw new ArgumentException("File path can't be empty.", nameof(path));
+                return null;
             }
 
             var extension = Path.GetExtension(path);
@@ -31,12 +40,10 @@ namespace Emby.Naming.Subtitles
             }
 
             var flags = GetFlags(path);
-            var info = new SubtitleInfo
-            {
-                Path = path,
-                IsDefault = _options.SubtitleDefaultFlags.Any(i => flags.Contains(i, StringComparer.OrdinalIgnoreCase)),
-                IsForced = _options.SubtitleForcedFlags.Any(i => flags.Contains(i, StringComparer.OrdinalIgnoreCase))
-            };
+            var info = new SubtitleInfo(
+                path,
+                _options.SubtitleDefaultFlags.Any(i => flags.Contains(i, StringComparer.OrdinalIgnoreCase)),
+                _options.SubtitleForcedFlags.Any(i => flags.Contains(i, StringComparer.OrdinalIgnoreCase)));
 
             var parts = flags.Where(i => !_options.SubtitleDefaultFlags.Contains(i, StringComparer.OrdinalIgnoreCase)
                 && !_options.SubtitleForcedFlags.Contains(i, StringComparer.OrdinalIgnoreCase))
@@ -53,7 +60,7 @@ namespace Emby.Naming.Subtitles
 
         private string[] GetFlags(string path)
         {
-            // Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
+            // Note: the tags need be surrounded be either a space ( ), hyphen -, dot . or underscore _.
 
             var file = Path.GetFileName(path);
 

+ 38 - 7
Emby.Naming/TV/EpisodeInfo.cs

@@ -1,9 +1,19 @@
-#pragma warning disable CS1591
-
 namespace Emby.Naming.TV
 {
+    /// <summary>
+    /// Holder object for Episode information.
+    /// </summary>
     public class EpisodeInfo
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="EpisodeInfo"/> class.
+        /// </summary>
+        /// <param name="path">Path to the file.</param>
+        public EpisodeInfo(string path)
+        {
+            Path = path;
+        }
+
         /// <summary>
         /// Gets or sets the path.
         /// </summary>
@@ -14,19 +24,19 @@ namespace Emby.Naming.TV
         /// Gets or sets the container.
         /// </summary>
         /// <value>The container.</value>
-        public string Container { get; set; }
+        public string? Container { get; set; }
 
         /// <summary>
         /// Gets or sets the name of the series.
         /// </summary>
         /// <value>The name of the series.</value>
-        public string SeriesName { get; set; }
+        public string? SeriesName { get; set; }
 
         /// <summary>
         /// Gets or sets the format3 d.
         /// </summary>
         /// <value>The format3 d.</value>
-        public string Format3D { get; set; }
+        public string? Format3D { get; set; }
 
         /// <summary>
         /// Gets or sets a value indicating whether [is3 d].
@@ -44,20 +54,41 @@ namespace Emby.Naming.TV
         /// Gets or sets the type of the stub.
         /// </summary>
         /// <value>The type of the stub.</value>
-        public string StubType { get; set; }
+        public string? StubType { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional season number.
+        /// </summary>
         public int? SeasonNumber { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional episode number.
+        /// </summary>
         public int? EpisodeNumber { get; set; }
 
-        public int? EndingEpsiodeNumber { get; set; }
+        /// <summary>
+        /// Gets or sets optional ending episode number. For multi-episode files 1-13.
+        /// </summary>
+        public int? EndingEpisodeNumber { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional year of release.
+        /// </summary>
         public int? Year { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional year of release.
+        /// </summary>
         public int? Month { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional day of release.
+        /// </summary>
         public int? Day { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether by date expression was used.
+        /// </summary>
         public bool IsByDate { get; set; }
     }
 }

+ 22 - 13
Emby.Naming/TV/EpisodePathParser.cs

@@ -1,6 +1,3 @@
-#pragma warning disable CS1591
-#nullable enable
-
 using System;
 using System.Collections.Generic;
 using System.Globalization;
@@ -9,15 +6,32 @@ using Emby.Naming.Common;
 
 namespace Emby.Naming.TV
 {
+    /// <summary>
+    /// Used to parse information about episode from path.
+    /// </summary>
     public class EpisodePathParser
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="EpisodePathParser"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> object containing EpisodeExpressions and MultipleEpisodeExpressions.</param>
         public EpisodePathParser(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Parses information about episode from path.
+        /// </summary>
+        /// <param name="path">Path.</param>
+        /// <param name="isDirectory">Is path for a directory or file.</param>
+        /// <param name="isNamed">Do we want to use IsNamed expressions.</param>
+        /// <param name="isOptimistic">Do we want to use Optimistic expressions.</param>
+        /// <param name="supportsAbsoluteNumbers">Do we want to use expressions supporting absolute episode numbers.</param>
+        /// <param name="fillExtendedInfo">Should we attempt to retrieve extended information.</param>
+        /// <returns>Returns <see cref="EpisodePathParserResult"/> object.</returns>
         public EpisodePathParserResult Parse(
             string path,
             bool isDirectory,
@@ -146,7 +160,7 @@ namespace Emby.Naming.TV
                         {
                             if (int.TryParse(endingNumberGroup.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
                             {
-                                result.EndingEpsiodeNumber = num;
+                                result.EndingEpisodeNumber = num;
                             }
                         }
                     }
@@ -186,7 +200,7 @@ namespace Emby.Naming.TV
 
         private void FillAdditional(string path, EpisodePathParserResult info)
         {
-            var expressions = _options.MultipleEpisodeExpressions.ToList();
+            var expressions = _options.MultipleEpisodeExpressions.Where(i => i.IsNamed).ToList();
 
             if (string.IsNullOrEmpty(info.SeriesName))
             {
@@ -200,11 +214,6 @@ namespace Emby.Naming.TV
         {
             foreach (var i in expressions)
             {
-                if (!i.IsNamed)
-                {
-                    continue;
-                }
-
                 var result = Parse(path, i);
 
                 if (!result.Success)
@@ -217,13 +226,13 @@ namespace Emby.Naming.TV
                     info.SeriesName = result.SeriesName;
                 }
 
-                if (!info.EndingEpsiodeNumber.HasValue && info.EpisodeNumber.HasValue)
+                if (!info.EndingEpisodeNumber.HasValue && info.EpisodeNumber.HasValue)
                 {
-                    info.EndingEpsiodeNumber = result.EndingEpsiodeNumber;
+                    info.EndingEpisodeNumber = result.EndingEpisodeNumber;
                 }
 
                 if (!string.IsNullOrEmpty(info.SeriesName)
-                    && (!info.EpisodeNumber.HasValue || info.EndingEpsiodeNumber.HasValue))
+                    && (!info.EpisodeNumber.HasValue || info.EndingEpisodeNumber.HasValue))
                 {
                     break;
                 }

+ 33 - 4
Emby.Naming/TV/EpisodePathParserResult.cs

@@ -1,25 +1,54 @@
-#pragma warning disable CS1591
-
 namespace Emby.Naming.TV
 {
+    /// <summary>
+    /// Holder object for <see cref="EpisodePathParser"/> result.
+    /// </summary>
     public class EpisodePathParserResult
     {
+        /// <summary>
+        /// Gets or sets optional season number.
+        /// </summary>
         public int? SeasonNumber { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional episode number.
+        /// </summary>
         public int? EpisodeNumber { get; set; }
 
-        public int? EndingEpsiodeNumber { get; set; }
+        /// <summary>
+        /// Gets or sets optional ending episode number. For multi-episode files 1-13.
+        /// </summary>
+        public int? EndingEpisodeNumber { get; set; }
 
-        public string SeriesName { get; set; }
+        /// <summary>
+        /// Gets or sets the name of the series.
+        /// </summary>
+        /// <value>The name of the series.</value>
+        public string? SeriesName { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether parsing was successful.
+        /// </summary>
         public bool Success { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether by date expression was used.
+        /// </summary>
         public bool IsByDate { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional year of release.
+        /// </summary>
         public int? Year { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional year of release.
+        /// </summary>
         public int? Month { get; set; }
 
+        /// <summary>
+        /// Gets or sets optional day of release.
+        /// </summary>
         public int? Day { get; set; }
     }
 }

+ 19 - 6
Emby.Naming/TV/EpisodeResolver.cs

@@ -1,6 +1,3 @@
-#pragma warning disable CS1591
-#nullable enable
-
 using System;
 using System.IO;
 using System.Linq;
@@ -9,15 +6,32 @@ using Emby.Naming.Video;
 
 namespace Emby.Naming.TV
 {
+    /// <summary>
+    /// Used to resolve information about episode from path.
+    /// </summary>
     public class EpisodeResolver
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="EpisodeResolver"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> object containing VideoFileExtensions and passed to <see cref="StubResolver"/>, <see cref="FlagParser"/>, <see cref="Format3DParser"/> and <see cref="EpisodePathParser"/>.</param>
         public EpisodeResolver(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Resolve information about episode from path.
+        /// </summary>
+        /// <param name="path">Path.</param>
+        /// <param name="isDirectory">Is path for a directory or file.</param>
+        /// <param name="isNamed">Do we want to use IsNamed expressions.</param>
+        /// <param name="isOptimistic">Do we want to use Optimistic expressions.</param>
+        /// <param name="supportsAbsoluteNumbers">Do we want to use expressions supporting absolute episode numbers.</param>
+        /// <param name="fillExtendedInfo">Should we attempt to retrieve extended information.</param>
+        /// <returns>Returns null or <see cref="EpisodeInfo"/> object if successful.</returns>
         public EpisodeInfo? Resolve(
             string path,
             bool isDirectory,
@@ -54,12 +68,11 @@ namespace Emby.Naming.TV
             var parsingResult = new EpisodePathParser(_options)
                 .Parse(path, isDirectory, isNamed, isOptimistic, supportsAbsoluteNumbers, fillExtendedInfo);
 
-            return new EpisodeInfo
+            return new EpisodeInfo(path)
             {
-                Path = path,
                 Container = container,
                 IsStub = isStub,
-                EndingEpsiodeNumber = parsingResult.EndingEpsiodeNumber,
+                EndingEpisodeNumber = parsingResult.EndingEpisodeNumber,
                 EpisodeNumber = parsingResult.EpisodeNumber,
                 SeasonNumber = parsingResult.SeasonNumber,
                 SeriesName = parsingResult.SeriesName,

+ 16 - 8
Emby.Naming/TV/SeasonPathParser.cs

@@ -1,11 +1,12 @@
-#pragma warning disable CS1591
-
 using System;
 using System.Globalization;
 using System.IO;
 
 namespace Emby.Naming.TV
 {
+    /// <summary>
+    /// Class to parse season paths.
+    /// </summary>
     public static class SeasonPathParser
     {
         /// <summary>
@@ -23,6 +24,13 @@ namespace Emby.Naming.TV
             "stagione"
         };
 
+        /// <summary>
+        /// Attempts to parse season number from path.
+        /// </summary>
+        /// <param name="path">Path to season.</param>
+        /// <param name="supportSpecialAliases">Support special aliases when parsing.</param>
+        /// <param name="supportNumericSeasonFolders">Support numeric season folders when parsing.</param>
+        /// <returns>Returns <see cref="SeasonPathParserResult"/> object.</returns>
         public static SeasonPathParserResult Parse(string path, bool supportSpecialAliases, bool supportNumericSeasonFolders)
         {
             var result = new SeasonPathParserResult();
@@ -101,9 +109,9 @@ namespace Emby.Naming.TV
             }
 
             var parts = filename.Split(new[] { '.', '_', ' ', '-' }, StringSplitOptions.RemoveEmptyEntries);
-            for (int i = 0; i < parts.Length; i++)
+            foreach (var part in parts)
             {
-                if (TryGetSeasonNumberFromPart(parts[i], out int seasonNumber))
+                if (TryGetSeasonNumberFromPart(part, out int seasonNumber))
                 {
                     return (seasonNumber, true);
                 }
@@ -139,7 +147,7 @@ namespace Emby.Naming.TV
             var numericStart = -1;
             var length = 0;
 
-            var hasOpenParenth = false;
+            var hasOpenParenthesis = false;
             var isSeasonFolder = true;
 
             // Find out where the numbers start, and then keep going until they end
@@ -147,7 +155,7 @@ namespace Emby.Naming.TV
             {
                 if (char.IsNumber(path[i]))
                 {
-                    if (!hasOpenParenth)
+                    if (!hasOpenParenthesis)
                     {
                         if (numericStart == -1)
                         {
@@ -167,11 +175,11 @@ namespace Emby.Naming.TV
                 var currentChar = path[i];
                 if (currentChar == '(')
                 {
-                    hasOpenParenth = true;
+                    hasOpenParenthesis = true;
                 }
                 else if (currentChar == ')')
                 {
-                    hasOpenParenth = false;
+                    hasOpenParenthesis = false;
                 }
             }
 

+ 7 - 2
Emby.Naming/TV/SeasonPathParserResult.cs

@@ -1,7 +1,8 @@
-#pragma warning disable CS1591
-
 namespace Emby.Naming.TV
 {
+    /// <summary>
+    /// Data object to pass result of <see cref="SeasonPathParser"/>.
+    /// </summary>
     public class SeasonPathParserResult
     {
         /// <summary>
@@ -16,6 +17,10 @@ namespace Emby.Naming.TV
         /// <value><c>true</c> if success; otherwise, <c>false</c>.</value>
         public bool Success { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether "Is season folder".
+        /// Seems redundant and barely used.
+        /// </summary>
         public bool IsSeasonFolder { get; set; }
     }
 }

+ 6 - 3
Emby.Naming/Video/CleanDateTimeParser.cs

@@ -1,6 +1,3 @@
-#pragma warning disable CS1591
-#nullable enable
-
 using System.Collections.Generic;
 using System.Globalization;
 using System.Text.RegularExpressions;
@@ -12,6 +9,12 @@ namespace Emby.Naming.Video
     /// </summary>
     public static class CleanDateTimeParser
     {
+        /// <summary>
+        /// Attempts to clean the name.
+        /// </summary>
+        /// <param name="name">Name of video.</param>
+        /// <param name="cleanDateTimeRegexes">Optional list of regexes to clean the name.</param>
+        /// <returns>Returns <see cref="CleanDateTimeResult"/> object.</returns>
         public static CleanDateTimeResult Clean(string name, IReadOnlyList<Regex> cleanDateTimeRegexes)
         {
             CleanDateTimeResult result = new CleanDateTimeResult(name);

+ 9 - 10
Emby.Naming/Video/CleanDateTimeResult.cs

@@ -1,22 +1,21 @@
-#pragma warning disable CS1591
-#nullable enable
-
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Holder structure for name and year.
+    /// </summary>
     public readonly struct CleanDateTimeResult
     {
-        public CleanDateTimeResult(string name, int? year)
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CleanDateTimeResult"/> struct.
+        /// </summary>
+        /// <param name="name">Name of video.</param>
+        /// <param name="year">Year of release.</param>
+        public CleanDateTimeResult(string name, int? year = null)
         {
             Name = name;
             Year = year;
         }
 
-        public CleanDateTimeResult(string name)
-        {
-            Name = name;
-            Year = null;
-        }
-
         /// <summary>
         /// Gets the name.
         /// </summary>

+ 7 - 3
Emby.Naming/Video/CleanStringParser.cs

@@ -1,6 +1,3 @@
-#pragma warning disable CS1591
-#nullable enable
-
 using System;
 using System.Collections.Generic;
 using System.Text.RegularExpressions;
@@ -12,6 +9,13 @@ namespace Emby.Naming.Video
     /// </summary>
     public static class CleanStringParser
     {
+        /// <summary>
+        /// Attempts to extract clean name with regular expressions.
+        /// </summary>
+        /// <param name="name">Name of file.</param>
+        /// <param name="expressions">List of regex to parse name and year from.</param>
+        /// <param name="newName">Parsing result string.</param>
+        /// <returns>True if parsing was successful.</returns>
         public static bool TryClean(string name, IReadOnlyList<Regex> expressions, out ReadOnlySpan<char> newName)
         {
             var len = expressions.Count;

+ 12 - 6
Emby.Naming/Video/ExtraResolver.cs

@@ -1,5 +1,3 @@
-#pragma warning disable CS1591
-
 using System;
 using System.IO;
 using System.Linq;
@@ -9,15 +7,27 @@ using Emby.Naming.Common;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Resolve if file is extra for video.
+    /// </summary>
     public class ExtraResolver
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ExtraResolver"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> object containing VideoExtraRules and passed to <see cref="AudioFileParser"/> and <see cref="VideoResolver"/>.</param>
         public ExtraResolver(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Attempts to resolve if file is extra.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <returns>Returns <see cref="ExtraResult"/> object.</returns>
         public ExtraResult GetExtraInfo(string path)
         {
             return _options.VideoExtraRules
@@ -43,10 +53,6 @@ namespace Emby.Naming.Video
                     return result;
                 }
             }
-            else
-            {
-                return result;
-            }
 
             if (rule.RuleType == ExtraRuleType.Filename)
             {

+ 4 - 3
Emby.Naming/Video/ExtraResult.cs

@@ -1,9 +1,10 @@
-#pragma warning disable CS1591
-
 using MediaBrowser.Model.Entities;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Holder object for passing results from ExtraResolver.
+    /// </summary>
     public class ExtraResult
     {
         /// <summary>
@@ -16,6 +17,6 @@ namespace Emby.Naming.Video
         /// Gets or sets the rule.
         /// </summary>
         /// <value>The rule.</value>
-        public ExtraRule Rule { get; set; }
+        public ExtraRule? Rule { get; set; }
     }
 }

+ 15 - 2
Emby.Naming/Video/ExtraRule.cs

@@ -1,5 +1,3 @@
-#pragma warning disable CS1591
-
 using MediaBrowser.Model.Entities;
 using MediaType = Emby.Naming.Common.MediaType;
 
@@ -10,6 +8,21 @@ namespace Emby.Naming.Video
     /// </summary>
     public class ExtraRule
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="ExtraRule"/> class.
+        /// </summary>
+        /// <param name="extraType">Type of extra.</param>
+        /// <param name="ruleType">Type of rule.</param>
+        /// <param name="token">Token.</param>
+        /// <param name="mediaType">Media type.</param>
+        public ExtraRule(ExtraType extraType, ExtraRuleType ruleType, string token, MediaType mediaType)
+        {
+            Token = token;
+            ExtraType = extraType;
+            RuleType = ruleType;
+            MediaType = mediaType;
+        }
+
         /// <summary>
         /// Gets or sets the token to use for matching against the file path.
         /// </summary>

+ 4 - 3
Emby.Naming/Video/ExtraRuleType.cs

@@ -1,7 +1,8 @@
-#pragma warning disable CS1591
-
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Extra rules type to determine against what <see cref="ExtraRule.Token"/> should be matched.
+    /// </summary>
     public enum ExtraRuleType
     {
         /// <summary>
@@ -22,6 +23,6 @@ namespace Emby.Naming.Video
         /// <summary>
         /// Match <see cref="ExtraRule.Token"/> against the name of the directory containing the file.
         /// </summary>
-        DirectoryName = 3,
+        DirectoryName = 3
     }
 }

+ 22 - 3
Emby.Naming/Video/FileStack.cs

@@ -1,24 +1,43 @@
-#pragma warning disable CS1591
-
 using System;
 using System.Collections.Generic;
 using System.Linq;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Object holding list of files paths with additional information.
+    /// </summary>
     public class FileStack
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="FileStack"/> class.
+        /// </summary>
         public FileStack()
         {
             Files = new List<string>();
         }
 
-        public string Name { get; set; }
+        /// <summary>
+        /// Gets or sets name of file stack.
+        /// </summary>
+        public string Name { get; set; } = string.Empty;
 
+        /// <summary>
+        /// Gets or sets list of paths in stack.
+        /// </summary>
         public List<string> Files { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether stack is directory stack.
+        /// </summary>
         public bool IsDirectoryStack { get; set; }
 
+        /// <summary>
+        /// Helper function to determine if path is in the stack.
+        /// </summary>
+        /// <param name="file">Path of desired file.</param>
+        /// <param name="isDirectory">Requested type of stack.</param>
+        /// <returns>True if file is in the stack.</returns>
         public bool ContainsFile(string file, bool isDirectory)
         {
             if (IsDirectoryStack == isDirectory)

+ 21 - 5
Emby.Naming/Video/FlagParser.cs

@@ -1,37 +1,53 @@
-#pragma warning disable CS1591
-
 using System;
 using System.IO;
 using Emby.Naming.Common;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Parses list of flags from filename based on delimiters.
+    /// </summary>
     public class FlagParser
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="FlagParser"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> object containing VideoFlagDelimiters.</param>
         public FlagParser(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Calls GetFlags function with _options.VideoFlagDelimiters parameter.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <returns>List of found flags.</returns>
         public string[] GetFlags(string path)
         {
             return GetFlags(path, _options.VideoFlagDelimiters);
         }
 
-        public string[] GetFlags(string path, char[] delimeters)
+        /// <summary>
+        /// Parses flags from filename based on delimiters.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <param name="delimiters">Delimiters used to extract flags.</param>
+        /// <returns>List of found flags.</returns>
+        public string[] GetFlags(string path, char[] delimiters)
         {
             if (string.IsNullOrEmpty(path))
             {
-                throw new ArgumentNullException(nameof(path));
+                return Array.Empty<string>();
             }
 
             // Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
 
             var file = Path.GetFileName(path);
 
-            return file.Split(delimeters, StringSplitOptions.RemoveEmptyEntries);
+            return file.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
         }
     }
 }

+ 20 - 10
Emby.Naming/Video/Format3DParser.cs

@@ -1,28 +1,38 @@
-#pragma warning disable CS1591
-
 using System;
 using System.Linq;
 using Emby.Naming.Common;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Parste 3D format related flags.
+    /// </summary>
     public class Format3DParser
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Format3DParser"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> object containing VideoFlagDelimiters and passes options to <see cref="FlagParser"/>.</param>
         public Format3DParser(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Parse 3D format related flags.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <returns>Returns <see cref="Format3DResult"/> object.</returns>
         public Format3DResult Parse(string path)
         {
             int oldLen = _options.VideoFlagDelimiters.Length;
-            var delimeters = new char[oldLen + 1];
-            _options.VideoFlagDelimiters.CopyTo(delimeters, 0);
-            delimeters[oldLen] = ' ';
+            var delimiters = new char[oldLen + 1];
+            _options.VideoFlagDelimiters.CopyTo(delimiters, 0);
+            delimiters[oldLen] = ' ';
 
-            return Parse(new FlagParser(_options).GetFlags(path, delimeters));
+            return Parse(new FlagParser(_options).GetFlags(path, delimiters));
         }
 
         internal Format3DResult Parse(string[] videoFlags)
@@ -44,7 +54,7 @@ namespace Emby.Naming.Video
         {
             var result = new Format3DResult();
 
-            if (string.IsNullOrEmpty(rule.PreceedingToken))
+            if (string.IsNullOrEmpty(rule.PrecedingToken))
             {
                 result.Format3D = new[] { rule.Token }.FirstOrDefault(i => videoFlags.Contains(i, StringComparer.OrdinalIgnoreCase));
                 result.Is3D = !string.IsNullOrEmpty(result.Format3D);
@@ -57,13 +67,13 @@ namespace Emby.Naming.Video
             else
             {
                 var foundPrefix = false;
-                string format = null;
+                string? format = null;
 
                 foreach (var flag in videoFlags)
                 {
                     if (foundPrefix)
                     {
-                        result.Tokens.Add(rule.PreceedingToken);
+                        result.Tokens.Add(rule.PrecedingToken);
 
                         if (string.Equals(rule.Token, flag, StringComparison.OrdinalIgnoreCase))
                         {
@@ -74,7 +84,7 @@ namespace Emby.Naming.Video
                         break;
                     }
 
-                    foundPrefix = string.Equals(flag, rule.PreceedingToken, StringComparison.OrdinalIgnoreCase);
+                    foundPrefix = string.Equals(flag, rule.PrecedingToken, StringComparison.OrdinalIgnoreCase);
                 }
 
                 result.Is3D = foundPrefix && !string.IsNullOrEmpty(format);

+ 7 - 3
Emby.Naming/Video/Format3DResult.cs

@@ -1,11 +1,15 @@
-#pragma warning disable CS1591
-
 using System.Collections.Generic;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Helper object to return data from <see cref="Format3DParser"/>.
+    /// </summary>
     public class Format3DResult
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Format3DResult"/> class.
+        /// </summary>
         public Format3DResult()
         {
             Tokens = new List<string>();
@@ -21,7 +25,7 @@ namespace Emby.Naming.Video
         /// Gets or sets the format3 d.
         /// </summary>
         /// <value>The format3 d.</value>
-        public string Format3D { get; set; }
+        public string? Format3D { get; set; }
 
         /// <summary>
         /// Gets or sets the tokens.

+ 17 - 5
Emby.Naming/Video/Format3DRule.cs

@@ -1,9 +1,21 @@
-#pragma warning disable CS1591
-
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Data holder class for 3D format rule.
+    /// </summary>
     public class Format3DRule
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Format3DRule"/> class.
+        /// </summary>
+        /// <param name="token">Token.</param>
+        /// <param name="precedingToken">Token present before current token.</param>
+        public Format3DRule(string token, string? precedingToken = null)
+        {
+            Token = token;
+            PrecedingToken = precedingToken;
+        }
+
         /// <summary>
         /// Gets or sets the token.
         /// </summary>
@@ -11,9 +23,9 @@ namespace Emby.Naming.Video
         public string Token { get; set; }
 
         /// <summary>
-        /// Gets or sets the preceeding token.
+        /// Gets or sets the preceding token.
         /// </summary>
-        /// <value>The preceeding token.</value>
-        public string PreceedingToken { get; set; }
+        /// <value>The preceding token.</value>
+        public string? PrecedingToken { get; set; }
     }
 }

+ 48 - 18
Emby.Naming/Video/StackResolver.cs

@@ -1,58 +1,88 @@
-#pragma warning disable CS1591
-
 using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Text.RegularExpressions;
+using Emby.Naming.AudioBook;
 using Emby.Naming.Common;
 using MediaBrowser.Model.IO;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Resolve <see cref="FileStack"/> from list of paths.
+    /// </summary>
     public class StackResolver
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="StackResolver"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> object containing VideoFileStackingRegexes and passes options to <see cref="VideoResolver"/>.</param>
         public StackResolver(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Resolves only directories from paths.
+        /// </summary>
+        /// <param name="files">List of paths.</param>
+        /// <returns>Enumerable <see cref="FileStack"/> of directories.</returns>
         public IEnumerable<FileStack> ResolveDirectories(IEnumerable<string> files)
         {
             return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = true }));
         }
 
+        /// <summary>
+        /// Resolves only files from paths.
+        /// </summary>
+        /// <param name="files">List of paths.</param>
+        /// <returns>Enumerable <see cref="FileStack"/> of files.</returns>
         public IEnumerable<FileStack> ResolveFiles(IEnumerable<string> files)
         {
             return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false }));
         }
 
-        public IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<FileSystemMetadata> files)
+        /// <summary>
+        /// Resolves audiobooks from paths.
+        /// </summary>
+        /// <param name="files">List of paths.</param>
+        /// <returns>Enumerable <see cref="FileStack"/> of directories.</returns>
+        public IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<AudioBookFileInfo> files)
         {
-            var groupedDirectoryFiles = files.GroupBy(file =>
-                file.IsDirectory
-                    ? file.FullName
-                    : Path.GetDirectoryName(file.FullName));
+            var groupedDirectoryFiles = files.GroupBy(file => Path.GetDirectoryName(file.Path));
 
             foreach (var directory in groupedDirectoryFiles)
             {
-                var stack = new FileStack { Name = Path.GetFileName(directory.Key), IsDirectoryStack = false };
-                foreach (var file in directory)
+                if (string.IsNullOrEmpty(directory.Key))
                 {
-                    if (file.IsDirectory)
+                    foreach (var file in directory)
                     {
-                        continue;
+                        var stack = new FileStack { Name = Path.GetFileNameWithoutExtension(file.Path), IsDirectoryStack = false };
+                        stack.Files.Add(file.Path);
+                        yield return stack;
                     }
-
-                    stack.Files.Add(file.FullName);
                 }
+                else
+                {
+                    var stack = new FileStack { Name = Path.GetFileName(directory.Key), IsDirectoryStack = false };
+                    foreach (var file in directory)
+                    {
+                        stack.Files.Add(file.Path);
+                    }
 
-                yield return stack;
+                    yield return stack;
+                }
             }
         }
 
+        /// <summary>
+        /// Resolves videos from paths.
+        /// </summary>
+        /// <param name="files">List of paths.</param>
+        /// <returns>Enumerable <see cref="FileStack"/> of videos.</returns>
         public IEnumerable<FileStack> Resolve(IEnumerable<FileSystemMetadata> files)
         {
             var resolver = new VideoResolver(_options);
@@ -81,10 +111,10 @@ namespace Emby.Naming.Video
 
                     if (match1.Success)
                     {
-                        var title1 = match1.Groups[1].Value;
-                        var volume1 = match1.Groups[2].Value;
-                        var ignore1 = match1.Groups[3].Value;
-                        var extension1 = match1.Groups[4].Value;
+                        var title1 = match1.Groups["title"].Value;
+                        var volume1 = match1.Groups["volume"].Value;
+                        var ignore1 = match1.Groups["ignore"].Value;
+                        var extension1 = match1.Groups["extension"].Value;
 
                         var j = i + 1;
                         while (j < list.Count)

+ 11 - 4
Emby.Naming/Video/StubResolver.cs

@@ -1,6 +1,3 @@
-#pragma warning disable CS1591
-#nullable enable
-
 using System;
 using System.IO;
 using System.Linq;
@@ -8,13 +5,23 @@ using Emby.Naming.Common;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Resolve if file is stub (.disc).
+    /// </summary>
     public static class StubResolver
     {
+        /// <summary>
+        /// Tries to resolve if file is stub (.disc).
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <param name="options">NamingOptions containing StubFileExtensions and StubTypes.</param>
+        /// <param name="stubType">Stub type.</param>
+        /// <returns>True if file is a stub.</returns>
         public static bool TryResolveFile(string path, NamingOptions options, out string? stubType)
         {
             stubType = default;
 
-            if (path == null)
+            if (string.IsNullOrEmpty(path))
             {
                 return false;
             }

+ 0 - 19
Emby.Naming/Video/StubResult.cs

@@ -1,19 +0,0 @@
-#pragma warning disable CS1591
-
-namespace Emby.Naming.Video
-{
-    public struct StubResult
-    {
-        /// <summary>
-        /// Gets or sets a value indicating whether this instance is stub.
-        /// </summary>
-        /// <value><c>true</c> if this instance is stub; otherwise, <c>false</c>.</value>
-        public bool IsStub { get; set; }
-
-        /// <summary>
-        /// Gets or sets the type of the stub.
-        /// </summary>
-        /// <value>The type of the stub.</value>
-        public string StubType { get; set; }
-    }
-}

+ 14 - 2
Emby.Naming/Video/StubTypeRule.cs

@@ -1,9 +1,21 @@
-#pragma warning disable CS1591
-
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Data class holding information about Stub type rule.
+    /// </summary>
     public class StubTypeRule
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="StubTypeRule"/> class.
+        /// </summary>
+        /// <param name="token">Token.</param>
+        /// <param name="stubType">Stub type.</param>
+        public StubTypeRule(string token, string stubType)
+        {
+            Token = token;
+            StubType = stubType;
+        }
+
         /// <summary>
         /// Gets or sets the token.
         /// </summary>

+ 34 - 6
Emby.Naming/Video/VideoFileInfo.cs

@@ -7,6 +7,35 @@ namespace Emby.Naming.Video
     /// </summary>
     public class VideoFileInfo
     {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="VideoFileInfo"/> class.
+        /// </summary>
+        /// <param name="name">Name of file.</param>
+        /// <param name="path">Path to the file.</param>
+        /// <param name="container">Container type.</param>
+        /// <param name="year">Year of release.</param>
+        /// <param name="extraType">Extra type.</param>
+        /// <param name="extraRule">Extra rule.</param>
+        /// <param name="format3D">Format 3D.</param>
+        /// <param name="is3D">Is 3D.</param>
+        /// <param name="isStub">Is Stub.</param>
+        /// <param name="stubType">Stub type.</param>
+        /// <param name="isDirectory">Is directory.</param>
+        public VideoFileInfo(string name, string path, string? container, int? year = default, ExtraType? extraType = default, ExtraRule? extraRule = default, string? format3D = default, bool is3D = default, bool isStub = default, string? stubType = default, bool isDirectory = default)
+        {
+            Path = path;
+            Container = container;
+            Name = name;
+            Year = year;
+            ExtraType = extraType;
+            ExtraRule = extraRule;
+            Format3D = format3D;
+            Is3D = is3D;
+            IsStub = isStub;
+            StubType = stubType;
+            IsDirectory = isDirectory;
+        }
+
         /// <summary>
         /// Gets or sets the path.
         /// </summary>
@@ -17,7 +46,7 @@ namespace Emby.Naming.Video
         /// Gets or sets the container.
         /// </summary>
         /// <value>The container.</value>
-        public string Container { get; set; }
+        public string? Container { get; set; }
 
         /// <summary>
         /// Gets or sets the name.
@@ -41,13 +70,13 @@ namespace Emby.Naming.Video
         /// Gets or sets the extra rule.
         /// </summary>
         /// <value>The extra rule.</value>
-        public ExtraRule ExtraRule { get; set; }
+        public ExtraRule? ExtraRule { get; set; }
 
         /// <summary>
         /// Gets or sets the format3 d.
         /// </summary>
         /// <value>The format3 d.</value>
-        public string Format3D { get; set; }
+        public string? Format3D { get; set; }
 
         /// <summary>
         /// Gets or sets a value indicating whether [is3 d].
@@ -65,7 +94,7 @@ namespace Emby.Naming.Video
         /// Gets or sets the type of the stub.
         /// </summary>
         /// <value>The type of the stub.</value>
-        public string StubType { get; set; }
+        public string? StubType { get; set; }
 
         /// <summary>
         /// Gets or sets a value indicating whether this instance is a directory.
@@ -84,8 +113,7 @@ namespace Emby.Naming.Video
         /// <inheritdoc />
         public override string ToString()
         {
-            // Makes debugging easier
-            return Name ?? base.ToString();
+            return "VideoFileInfo(Name: '" + Name + "')";
         }
     }
 }

+ 2 - 2
Emby.Naming/Video/VideoInfo.cs

@@ -12,7 +12,7 @@ namespace Emby.Naming.Video
         /// Initializes a new instance of the <see cref="VideoInfo" /> class.
         /// </summary>
         /// <param name="name">The name.</param>
-        public VideoInfo(string name)
+        public VideoInfo(string? name)
         {
             Name = name;
 
@@ -25,7 +25,7 @@ namespace Emby.Naming.Video
         /// Gets or sets the name.
         /// </summary>
         /// <value>The name.</value>
-        public string Name { get; set; }
+        public string? Name { get; set; }
 
         /// <summary>
         /// Gets or sets the year.

+ 27 - 8
Emby.Naming/Video/VideoListResolver.cs

@@ -1,5 +1,3 @@
-#pragma warning disable CS1591
-
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -11,22 +9,35 @@ using MediaBrowser.Model.IO;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Resolves alternative versions and extras from list of video files.
+    /// </summary>
     public class VideoListResolver
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="VideoListResolver"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> object containing CleanStringRegexes and VideoFlagDelimiters and passes options to <see cref="StackResolver"/> and <see cref="VideoResolver"/>.</param>
         public VideoListResolver(NamingOptions options)
         {
             _options = options;
         }
 
+        /// <summary>
+        /// Resolves alternative versions and extras from list of video files.
+        /// </summary>
+        /// <param name="files">List of related video files.</param>
+        /// <param name="supportMultiVersion">Indication we should consider multi-versions of content.</param>
+        /// <returns>Returns enumerable of <see cref="VideoInfo"/> which groups files together when related.</returns>
         public IEnumerable<VideoInfo> Resolve(List<FileSystemMetadata> files, bool supportMultiVersion = true)
         {
             var videoResolver = new VideoResolver(_options);
 
             var videoInfos = files
                 .Select(i => videoResolver.Resolve(i.FullName, i.IsDirectory))
-                .Where(i => i != null)
+                .OfType<VideoFileInfo>()
                 .ToList();
 
             // Filter out all extras, otherwise they could cause stacks to not be resolved
@@ -39,7 +50,7 @@ namespace Emby.Naming.Video
                 .Resolve(nonExtras).ToList();
 
             var remainingFiles = videoInfos
-                .Where(i => !stackResult.Any(s => s.ContainsFile(i.Path, i.IsDirectory)))
+                .Where(i => !stackResult.Any(s => i.Path != null && s.ContainsFile(i.Path, i.IsDirectory)))
                 .ToList();
 
             var list = new List<VideoInfo>();
@@ -48,7 +59,9 @@ namespace Emby.Naming.Video
             {
                 var info = new VideoInfo(stack.Name)
                 {
-                    Files = stack.Files.Select(i => videoResolver.Resolve(i, stack.IsDirectoryStack)).ToList()
+                    Files = stack.Files.Select(i => videoResolver.Resolve(i, stack.IsDirectoryStack))
+                        .OfType<VideoFileInfo>()
+                        .ToList()
                 };
 
                 info.Year = info.Files[0].Year;
@@ -133,7 +146,7 @@ namespace Emby.Naming.Video
             }
 
             // If there's only one video, accept all trailers
-            // Be lenient because people use all kinds of mish mash conventions with trailers
+            // Be lenient because people use all kinds of mishmash conventions with trailers.
             if (list.Count == 1)
             {
                 var trailers = remainingFiles
@@ -203,15 +216,21 @@ namespace Emby.Naming.Video
             return videos.Select(i => i.Year ?? -1).Distinct().Count() < 2;
         }
 
-        private bool IsEligibleForMultiVersion(string folderName, string testFilename)
+        private bool IsEligibleForMultiVersion(string folderName, string? testFilename)
         {
             testFilename = Path.GetFileNameWithoutExtension(testFilename) ?? string.Empty;
 
             if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
             {
+                if (CleanStringParser.TryClean(testFilename, _options.CleanStringRegexes, out var cleanName))
+                {
+                    testFilename = cleanName.ToString();
+                }
+
                 testFilename = testFilename.Substring(folderName.Length).Trim();
                 return string.IsNullOrEmpty(testFilename)
-                   || testFilename[0] == '-'
+                   || testFilename[0].Equals('-')
+                   || testFilename[0].Equals('_')
                    || string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
             }
 

+ 45 - 21
Emby.Naming/Video/VideoResolver.cs

@@ -1,6 +1,3 @@
-#pragma warning disable CS1591
-#nullable enable
-
 using System;
 using System.IO;
 using System.Linq;
@@ -8,10 +5,18 @@ using Emby.Naming.Common;
 
 namespace Emby.Naming.Video
 {
+    /// <summary>
+    /// Resolves <see cref="VideoFileInfo"/> from file path.
+    /// </summary>
     public class VideoResolver
     {
         private readonly NamingOptions _options;
 
+        /// <summary>
+        /// Initializes a new instance of the <see cref="VideoResolver"/> class.
+        /// </summary>
+        /// <param name="options"><see cref="NamingOptions"/> object containing VideoFileExtensions, StubFileExtensions, CleanStringRegexes and CleanDateTimeRegexes
+        /// and passes options in <see cref="StubResolver"/>, <see cref="FlagParser"/>, <see cref="Format3DParser"/> and <see cref="ExtraResolver"/>.</param>
         public VideoResolver(NamingOptions options)
         {
             _options = options;
@@ -22,7 +27,7 @@ namespace Emby.Naming.Video
         /// </summary>
         /// <param name="path">The path.</param>
         /// <returns>VideoFileInfo.</returns>
-        public VideoFileInfo? ResolveDirectory(string path)
+        public VideoFileInfo? ResolveDirectory(string? path)
         {
             return Resolve(path, true);
         }
@@ -32,7 +37,7 @@ namespace Emby.Naming.Video
         /// </summary>
         /// <param name="path">The path.</param>
         /// <returns>VideoFileInfo.</returns>
-        public VideoFileInfo? ResolveFile(string path)
+        public VideoFileInfo? ResolveFile(string? path)
         {
             return Resolve(path, false);
         }
@@ -45,11 +50,11 @@ namespace Emby.Naming.Video
         /// <param name="parseName">Whether or not the name should be parsed for info.</param>
         /// <returns>VideoFileInfo.</returns>
         /// <exception cref="ArgumentNullException"><c>path</c> is <c>null</c>.</exception>
-        public VideoFileInfo? Resolve(string path, bool isDirectory, bool parseName = true)
+        public VideoFileInfo? Resolve(string? path, bool isDirectory, bool parseName = true)
         {
             if (string.IsNullOrEmpty(path))
             {
-                throw new ArgumentNullException(nameof(path));
+                return null;
             }
 
             bool isStub = false;
@@ -99,39 +104,58 @@ namespace Emby.Naming.Video
                 }
             }
 
-            return new VideoFileInfo
-            {
-                Path = path,
-                Container = container,
-                IsStub = isStub,
-                Name = name,
-                Year = year,
-                StubType = stubType,
-                Is3D = format3DResult.Is3D,
-                Format3D = format3DResult.Format3D,
-                ExtraType = extraResult.ExtraType,
-                IsDirectory = isDirectory,
-                ExtraRule = extraResult.Rule
-            };
+            return new VideoFileInfo(
+                path: path,
+                container: container,
+                isStub: isStub,
+                name: name,
+                year: year,
+                stubType: stubType,
+                is3D: format3DResult.Is3D,
+                format3D: format3DResult.Format3D,
+                extraType: extraResult.ExtraType,
+                isDirectory: isDirectory,
+                extraRule: extraResult.Rule);
         }
 
+        /// <summary>
+        /// Determines if path is video file based on extension.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <returns>True if is video file.</returns>
         public bool IsVideoFile(string path)
         {
             var extension = Path.GetExtension(path) ?? string.Empty;
             return _options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
         }
 
+        /// <summary>
+        /// Determines if path is video file stub based on extension.
+        /// </summary>
+        /// <param name="path">Path to file.</param>
+        /// <returns>True if is video file stub.</returns>
         public bool IsStubFile(string path)
         {
             var extension = Path.GetExtension(path) ?? string.Empty;
             return _options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
         }
 
+        /// <summary>
+        /// Tries to clean name of clutter.
+        /// </summary>
+        /// <param name="name">Raw name.</param>
+        /// <param name="newName">Clean name.</param>
+        /// <returns>True if cleaning of name was successful.</returns>
         public bool TryCleanString(string name, out ReadOnlySpan<char> newName)
         {
             return CleanStringParser.TryClean(name, _options.CleanStringRegexes, out newName);
         }
 
+        /// <summary>
+        /// Tries to get name and year from raw name.
+        /// </summary>
+        /// <param name="name">Raw name.</param>
+        /// <returns>Returns <see cref="CleanDateTimeResult"/> with name and optional year.</returns>
         public CleanDateTimeResult CleanDateTime(string name)
         {
             return CleanDateTimeParser.Clean(name, _options.CleanDateTimeRegexes);

+ 3 - 4
Emby.Server.Implementations/ApplicationHost.cs

@@ -94,7 +94,6 @@ using MediaBrowser.Model.System;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Providers.Chapters;
 using MediaBrowser.Providers.Manager;
-using MediaBrowser.Providers.Plugins.TheTvdb;
 using MediaBrowser.Providers.Plugins.Tmdb;
 using MediaBrowser.Providers.Subtitles;
 using MediaBrowser.XbmcMetadata.Providers;
@@ -520,7 +519,6 @@ namespace Emby.Server.Implementations
             ServiceCollection.AddSingleton<IJsonSerializer, JsonSerializer>();
 
             ServiceCollection.AddSingleton(_fileSystemManager);
-            ServiceCollection.AddSingleton<TvdbClientManager>();
             ServiceCollection.AddSingleton<TmdbClientManager>();
 
             ServiceCollection.AddSingleton(_networkManager);
@@ -1070,7 +1068,6 @@ namespace Emby.Server.Implementations
                 if (!string.IsNullOrEmpty(lastName) && cleanup)
                 {
                     // Attempt a cleanup of old folders.
-                    versions.RemoveAt(x);
                     try
                     {
                         Logger.LogDebug("Deleting {Path}", versions[x].Path);
@@ -1080,6 +1077,8 @@ namespace Emby.Server.Implementations
                     {
                         Logger.LogWarning(e, "Unable to delete {Path}", versions[x].Path);
                     }
+
+                    versions.RemoveAt(x);
                 }
             }
 
@@ -1378,7 +1377,7 @@ namespace Emby.Server.Implementations
                 using var response = await _httpClientFactory.CreateClient(NamedClient.Default)
                     .SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
 
-                await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+                await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
                 var result = await System.Text.Json.JsonSerializer.DeserializeAsync<string>(stream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
                 var valid = string.Equals(Name, result, StringComparison.OrdinalIgnoreCase);
 

+ 0 - 14
Emby.Server.Implementations/Data/SqliteExtensions.cs

@@ -107,20 +107,6 @@ namespace Emby.Server.Implementations.Data
             return null;
         }
 
-        public static void Attach(SQLiteDatabaseConnection db, string path, string alias)
-        {
-            var commandText = string.Format(
-                CultureInfo.InvariantCulture,
-                "attach @path as {0};",
-                alias);
-
-            using (var statement = db.PrepareStatement(commandText))
-            {
-                statement.TryBind("@path", path);
-                statement.MoveNext();
-            }
-        }
-
         public static bool IsDBNull(this IReadOnlyList<IResultSetValue> result, int index)
         {
             return result[index].SQLiteType == SQLiteType.Null;

+ 1 - 1
Emby.Server.Implementations/Emby.Server.Implementations.csproj

@@ -36,7 +36,7 @@
     <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
     <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
     <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
-    <PackageReference Include="Mono.Nat" Version="3.0.0" />
+    <PackageReference Include="Mono.Nat" Version="3.0.1" />
     <PackageReference Include="prometheus-net.DotNetRuntime" Version="3.4.0" />
     <PackageReference Include="ServiceStack.Text.Core" Version="5.10.0" />
     <PackageReference Include="sharpcompress" Version="0.26.0" />

+ 5 - 4
Emby.Server.Implementations/Library/LibraryManager.cs

@@ -2486,9 +2486,10 @@ namespace Emby.Server.Implementations.Library
 
             var isFolder = episode.VideoType == VideoType.BluRay || episode.VideoType == VideoType.Dvd;
 
+            // TODO nullable - what are we trying to do there with empty episodeInfo?
             var episodeInfo = episode.IsFileProtocol
-                ? resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming) ?? new Naming.TV.EpisodeInfo()
-                : new Naming.TV.EpisodeInfo();
+                ? resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming) ?? new Naming.TV.EpisodeInfo(episode.Path)
+                : new Naming.TV.EpisodeInfo(episode.Path);
 
             try
             {
@@ -2577,12 +2578,12 @@ namespace Emby.Server.Implementations.Library
 
                 if (!episode.IndexNumberEnd.HasValue || forceRefresh)
                 {
-                    if (episode.IndexNumberEnd != episodeInfo.EndingEpsiodeNumber)
+                    if (episode.IndexNumberEnd != episodeInfo.EndingEpisodeNumber)
                     {
                         changed = true;
                     }
 
-                    episode.IndexNumberEnd = episodeInfo.EndingEpsiodeNumber;
+                    episode.IndexNumberEnd = episodeInfo.EndingEpisodeNumber;
                 }
 
                 if (!episode.ParentIndexNumber.HasValue || forceRefresh)

+ 1 - 1
Emby.Server.Implementations/Library/MediaStreamSelector.cs

@@ -101,7 +101,7 @@ namespace Emby.Server.Implementations.Library
 
         private static IEnumerable<MediaStream> GetSortedStreams(IEnumerable<MediaStream> streams, MediaStreamType type, string[] languagePreferences)
         {
-            // Give some preferance to external text subs for better performance
+            // Give some preference to external text subs for better performance
             return streams.Where(i => i.Type == type)
                 .OrderBy(i =>
             {

+ 4 - 3
Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs

@@ -77,11 +77,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
             _logger.LogInformation("Copying recording stream to file {0}", targetFile);
 
             // The media source if infinite so we need to handle stopping ourselves
-            var durationToken = new CancellationTokenSource(duration);
-            cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
+            using var durationToken = new CancellationTokenSource(duration);
+            using var linkedCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token);
+            cancellationToken = linkedCancellationToken.Token;
 
             await _streamHelper.CopyUntilCancelled(
-                await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
+                await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false),
                 output,
                 IODefaults.CopyToBufferSize,
                 cancellationToken).ConfigureAwait(false);

+ 10 - 10
Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs

@@ -112,7 +112,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             options.Content = new StringContent(requestString, Encoding.UTF8, MediaTypeNames.Application.Json);
             options.Headers.TryAddWithoutValidation("token", token);
             using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
-            await using var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             var dailySchedules = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Day>>(responseStream).ConfigureAwait(false);
             _logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId);
 
@@ -123,7 +123,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             programRequestOptions.Content = new StringContent("[\"" + string.Join("\", \"", programsID) + "\"]", Encoding.UTF8, MediaTypeNames.Application.Json);
 
             using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false);
-            await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             var programDetails = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ProgramDetails>>(innerResponseStream).ConfigureAwait(false);
             var programDict = programDetails.ToDictionary(p => p.programID, y => y);
 
@@ -261,7 +261,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
                 Id = newID,
                 StartDate = startAt,
                 EndDate = endAt,
-                Name = details.titles[0].title120 ?? "Unkown",
+                Name = details.titles[0].title120 ?? "Unknown",
                 OfficialRating = null,
                 CommunityRating = null,
                 EpisodeTitle = episodeTitle,
@@ -480,9 +480,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             try
             {
                 using var innerResponse2 = await Send(message, true, info, cancellationToken).ConfigureAwait(false);
-                await using var response = await innerResponse2.Content.ReadAsStreamAsync().ConfigureAwait(false);
-                return await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ShowImages>>(
-                    response).ConfigureAwait(false);
+                await using var response = await innerResponse2.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
+                return await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ShowImages>>(response).ConfigureAwait(false);
             }
             catch (Exception ex)
             {
@@ -509,7 +508,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             try
             {
                 using var httpResponse = await Send(options, false, info, cancellationToken).ConfigureAwait(false);
-                await using var response = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
+                await using var response = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
 
                 var root = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Headends>>(response).ConfigureAwait(false);
 
@@ -542,6 +541,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
 
         private readonly ConcurrentDictionary<string, NameValuePair> _tokens = new ConcurrentDictionary<string, NameValuePair>();
         private DateTime _lastErrorResponse;
+
         private async Task<string> GetToken(ListingsProviderInfo info, CancellationToken cancellationToken)
         {
             var username = info.Username;
@@ -651,7 +651,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             options.Content = new StringContent("{\"username\":\"" + username + "\",\"password\":\"" + hashedPassword + "\"}", Encoding.UTF8, MediaTypeNames.Application.Json);
 
             using var response = await Send(options, false, null, cancellationToken).ConfigureAwait(false);
-            await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Token>(stream).ConfigureAwait(false);
             if (root.message == "OK")
             {
@@ -705,7 +705,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             try
             {
                 using var httpResponse = await Send(options, false, null, cancellationToken).ConfigureAwait(false);
-                await using var stream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
+                await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
                 using var response = httpResponse.Content;
                 var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Lineups>(stream).ConfigureAwait(false);
 
@@ -780,7 +780,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             var list = new List<ChannelInfo>();
 
             using var httpResponse = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
-            await using var stream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Channel>(stream).ConfigureAwait(false);
             _logger.LogInformation("Found {ChannelCount} channels on the lineup on ScheduleDirect", root.map.Count);
             _logger.LogInformation("Mapping Stations to Channel");

+ 1 - 1
Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs

@@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));
 
             using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(path, cancellationToken).ConfigureAwait(false);
-            await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             await using (var fileStream = new FileStream(cacheFile, FileMode.CreateNew))
             {
                 await stream.CopyToAsync(fileStream, cancellationToken).ConfigureAwait(false);

+ 3 - 3
Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs

@@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
             var model = await GetModelInfo(info, false, cancellationToken).ConfigureAwait(false);
 
             using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(model.LineupURL, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
-            await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             var lineup = await JsonSerializer.DeserializeAsync<List<Channels>>(stream, cancellationToken: cancellationToken)
                 .ConfigureAwait(false) ?? new List<Channels>();
 
@@ -129,7 +129,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
                 using var response = await _httpClientFactory.CreateClient(NamedClient.Default)
                     .GetAsync(string.Format(CultureInfo.InvariantCulture, "{0}/discover.json", GetApiUrl(info)), HttpCompletionOption.ResponseHeadersRead, cancellationToken)
                     .ConfigureAwait(false);
-                await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+                await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
                 var discoverResponse = await JsonSerializer.DeserializeAsync<DiscoverResponse>(stream, cancellationToken: cancellationToken)
                     .ConfigureAwait(false);
 
@@ -175,7 +175,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
             using var response = await _httpClientFactory.CreateClient(NamedClient.Default)
                 .GetAsync(string.Format(CultureInfo.InvariantCulture, "{0}/tuners.html", GetApiUrl(info)), HttpCompletionOption.ResponseHeadersRead, cancellationToken)
                 .ConfigureAwait(false);
-            await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             using var sr = new StreamReader(stream, System.Text.Encoding.UTF8);
             var tuners = new List<LiveTvTunerInfo>();
             while (!sr.EndOfStream)

+ 2 - 2
Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs

@@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
                     .SendAsync(requestMessage, cancellationToken)
                     .ConfigureAwait(false);
                 response.EnsureSuccessStatusCode();
-                return await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+                return await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
             }
 
             return File.OpenRead(info.Url);
@@ -197,7 +197,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
                 if (string.IsNullOrWhiteSpace(numberString))
                 {
                     // Using this as a fallback now as this leads to Problems with channels like "5 USA"
-                    // where 5 isnt ment to be the channel number
+                    // where 5 isn't ment to be the channel number
                     // Check for channel number with the format from SatIp
                     // #EXTINF:0,84. VOX Schweiz
                     // #EXTINF:0,84.0 - VOX Schweiz

+ 1 - 1
Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs

@@ -135,7 +135,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
                 {
                     Logger.LogInformation("Beginning {0} stream to {1}", GetType().Name, TempFilePath);
                     using var message = response;
-                    await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+                    await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
                     await using var fileStream = new FileStream(TempFilePath, FileMode.Create, FileAccess.Write, FileShare.Read);
                     await StreamHelper.CopyToAsync(
                         stream,

+ 4 - 1
Emby.Server.Implementations/Localization/Core/de.json

@@ -115,5 +115,8 @@
     "TasksLibraryCategory": "Bibliothek",
     "TasksMaintenanceCategory": "Wartung",
     "TaskCleanActivityLogDescription": "Löscht Aktivitätsprotokolleinträge, die älter als das konfigurierte Alter sind.",
-    "TaskCleanActivityLog": "Aktivitätsprotokoll aufräumen"
+    "TaskCleanActivityLog": "Aktivitätsprotokoll aufräumen",
+    "Undefined": "Undefiniert",
+    "Forced": "Erzwungen",
+    "Default": "Standard"
 }

+ 6 - 1
Emby.Server.Implementations/Localization/Core/es-AR.json

@@ -113,5 +113,10 @@
     "TasksChannelsCategory": "Canales de internet",
     "TasksApplicationCategory": "Aplicación",
     "TasksLibraryCategory": "Biblioteca",
-    "TasksMaintenanceCategory": "Mantenimiento"
+    "TasksMaintenanceCategory": "Mantenimiento",
+    "TaskCleanActivityLogDescription": "Borrar log de actividades anteriores a la fecha establecida.",
+    "TaskCleanActivityLog": "Borrar log de actividades",
+    "Undefined": "Indefinido",
+    "Forced": "Forzado",
+    "Default": "Por Defecto"
 }

+ 4 - 1
Emby.Server.Implementations/Localization/Core/es.json

@@ -115,5 +115,8 @@
     "TaskDownloadMissingSubtitles": "Descargar los subtítulos que faltan",
     "TaskDownloadMissingSubtitlesDescription": "Busca en internet los subtítulos que falten en el contenido de tus bibliotecas, basándose en la configuración de los metadatos.",
     "TaskCleanActivityLogDescription": "Elimina todos los registros de actividad anteriores a la fecha configurada.",
-    "TaskCleanActivityLog": "Limpiar registro de actividad"
+    "TaskCleanActivityLog": "Limpiar registro de actividad",
+    "Undefined": "Indefinido",
+    "Forced": "Forzado",
+    "Default": "Predeterminado"
 }

+ 6 - 1
Emby.Server.Implementations/Localization/Core/he.json

@@ -113,5 +113,10 @@
     "TaskRefreshChannels": "רענן ערוץ",
     "TaskCleanTranscodeDescription": "מחק קבצי transcode שנוצרו מלפני יותר מיום.",
     "TaskCleanTranscode": "נקה תקיית Transcode",
-    "TaskUpdatePluginsDescription": "הורד והתקן עדכונים עבור תוספים שמוגדרים לעדכון אוטומטי."
+    "TaskUpdatePluginsDescription": "הורד והתקן עדכונים עבור תוספים שמוגדרים לעדכון אוטומטי.",
+    "TaskCleanActivityLogDescription": "מחק רשומת פעילות הישנה יותר מהגיל המוגדר.",
+    "TaskCleanActivityLog": "נקה רשומת פעילות",
+    "Undefined": "לא מוגדר",
+    "Forced": "כפוי",
+    "Default": "ברירת מחדל"
 }

+ 4 - 1
Emby.Server.Implementations/Localization/Core/ta.json

@@ -114,5 +114,8 @@
     "UserStoppedPlayingItemWithValues": "{0} {2} இல் {1} முடித்துவிட்டது",
     "UserStartedPlayingItemWithValues": "{0} {2}இல் {1} ஐ இயக்குகிறது",
     "TaskCleanActivityLogDescription": "உள்ளமைக்கப்பட்ட வயதை விட பழைய செயல்பாட்டு பதிவு உள்ளீடுகளை நீக்குகிறது.",
-    "TaskCleanActivityLog": "செயல்பாட்டு பதிவை அழி"
+    "TaskCleanActivityLog": "செயல்பாட்டு பதிவை அழி",
+    "Undefined": "வரையறுக்கப்படாத",
+    "Forced": "கட்டாயப்படுத்தப்பட்டது",
+    "Default": "இயல்புநிலை"
 }

+ 4 - 1
Emby.Server.Implementations/Localization/Core/vi.json

@@ -114,5 +114,8 @@
     "Application": "Ứng Dụng",
     "AppDeviceValues": "Ứng Dụng: {0}, Thiết Bị: {1}",
     "TaskCleanActivityLogDescription": "Xóa các mục nhật ký hoạt động cũ hơn độ tuổi đã cài đặt.",
-    "TaskCleanActivityLog": "Xóa Nhật Ký Hoạt Động"
+    "TaskCleanActivityLog": "Xóa Nhật Ký Hoạt Động",
+    "Undefined": "Không Xác Định",
+    "Forced": "Bắt Buộc",
+    "Default": "Mặc Định"
 }

+ 4 - 1
Emby.Server.Implementations/Localization/Core/zh-CN.json

@@ -115,5 +115,8 @@
     "TasksApplicationCategory": "应用程序",
     "TasksMaintenanceCategory": "维护",
     "TaskCleanActivityLog": "清理程序日志",
-    "TaskCleanActivityLogDescription": "删除早于设置时间的活动日志条目。"
+    "TaskCleanActivityLogDescription": "删除早于设置时间的活动日志条目。",
+    "Undefined": "未定义",
+    "Forced": "强制的",
+    "Default": "默认"
 }

+ 2 - 2
Emby.Server.Implementations/ScheduledTasks/TaskManager.cs

@@ -136,7 +136,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
             {
                 var type = scheduledTask.ScheduledTask.GetType();
 
-                _logger.LogInformation("Queueing task {0}", type.Name);
+                _logger.LogInformation("Queuing task {0}", type.Name);
 
                 lock (_taskQueue)
                 {
@@ -176,7 +176,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
         {
             var type = task.ScheduledTask.GetType();
 
-            _logger.LogInformation("Queueing task {0}", type.Name);
+            _logger.LogInformation("Queuing task {0}", type.Name);
 
             lock (_taskQueue)
             {

+ 1 - 1
Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs

@@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.SyncPlay
             new Dictionary<Guid, ISyncPlayController>();
 
         /// <summary>
-        /// Lock used for accesing any group.
+        /// Lock used for accessing any group.
         /// </summary>
         private readonly object _groupsLock = new object();
 

+ 4 - 3
Emby.Server.Implementations/Updates/InstallationManager.cs

@@ -99,7 +99,7 @@ namespace Emby.Server.Implementations.Updates
             {
                 using var response = await _httpClientFactory.CreateClient(NamedClient.Default)
                     .GetAsync(manifest, cancellationToken).ConfigureAwait(false);
-                await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+                await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
 
                 try
                 {
@@ -241,7 +241,8 @@ namespace Emby.Server.Implementations.Updates
                 _currentInstallations.Add(tuple);
             }
 
-            var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, innerCancellationTokenSource.Token).Token;
+            using var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, innerCancellationTokenSource.Token);
+            var linkedToken = linkedTokenSource.Token;
 
             await _eventManager.PublishAsync(new PluginInstallingEventArgs(package)).ConfigureAwait(false);
 
@@ -333,7 +334,7 @@ namespace Emby.Server.Implementations.Updates
 
             using var response = await _httpClientFactory.CreateClient(NamedClient.Default)
                 .GetAsync(package.SourceUrl, cancellationToken).ConfigureAwait(false);
-            await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
+            await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
 
             // CA5351: Do Not Use Broken Cryptographic Algorithms
 #pragma warning disable CA5351

+ 3 - 3
Jellyfin.Api/Controllers/AudioController.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Threading.Tasks;
@@ -42,7 +42,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="deviceProfileId">Optional. The dlna device profile id to utilize.</param>
         /// <param name="playSessionId">The play session id.</param>
         /// <param name="segmentContainer">The segment container.</param>
-        /// <param name="segmentLength">The segment lenght.</param>
+        /// <param name="segmentLength">The segment length.</param>
         /// <param name="minSegments">The minimum number of segments.</param>
         /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param>
         /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param>
@@ -71,7 +71,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxVideoBitDepth">Optional. The maximum video bit depth.</param>
         /// <param name="requireAvc">Optional. Whether to require avc.</param>
         /// <param name="deInterlace">Optional. Whether to deinterlace the video.</param>
-        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamporphic stream.</param>
+        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamorphic stream.</param>
         /// <param name="transcodingMaxAudioChannels">Optional. The maximum number of audio channels to transcode.</param>
         /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param>
         /// <param name="liveStreamId">The live stream id.</param>

+ 11 - 11
Jellyfin.Api/Controllers/DynamicHlsController.cs

@@ -120,7 +120,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="deviceProfileId">Optional. The dlna device profile id to utilize.</param>
         /// <param name="playSessionId">The play session id.</param>
         /// <param name="segmentContainer">The segment container.</param>
-        /// <param name="segmentLength">The segment lenght.</param>
+        /// <param name="segmentLength">The segment length.</param>
         /// <param name="minSegments">The minimum number of segments.</param>
         /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param>
         /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param>
@@ -149,7 +149,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxVideoBitDepth">Optional. The maximum video bit depth.</param>
         /// <param name="requireAvc">Optional. Whether to require avc.</param>
         /// <param name="deInterlace">Optional. Whether to deinterlace the video.</param>
-        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamporphic stream.</param>
+        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamorphic stream.</param>
         /// <param name="transcodingMaxAudioChannels">Optional. The maximum number of audio channels to transcode.</param>
         /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param>
         /// <param name="liveStreamId">The live stream id.</param>
@@ -285,7 +285,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="deviceProfileId">Optional. The dlna device profile id to utilize.</param>
         /// <param name="playSessionId">The play session id.</param>
         /// <param name="segmentContainer">The segment container.</param>
-        /// <param name="segmentLength">The segment lenght.</param>
+        /// <param name="segmentLength">The segment length.</param>
         /// <param name="minSegments">The minimum number of segments.</param>
         /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param>
         /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param>
@@ -315,7 +315,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxVideoBitDepth">Optional. The maximum video bit depth.</param>
         /// <param name="requireAvc">Optional. Whether to require avc.</param>
         /// <param name="deInterlace">Optional. Whether to deinterlace the video.</param>
-        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamporphic stream.</param>
+        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamorphic stream.</param>
         /// <param name="transcodingMaxAudioChannels">Optional. The maximum number of audio channels to transcode.</param>
         /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param>
         /// <param name="liveStreamId">The live stream id.</param>
@@ -452,7 +452,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="deviceProfileId">Optional. The dlna device profile id to utilize.</param>
         /// <param name="playSessionId">The play session id.</param>
         /// <param name="segmentContainer">The segment container.</param>
-        /// <param name="segmentLength">The segment lenght.</param>
+        /// <param name="segmentLength">The segment length.</param>
         /// <param name="minSegments">The minimum number of segments.</param>
         /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param>
         /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param>
@@ -481,7 +481,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxVideoBitDepth">Optional. The maximum video bit depth.</param>
         /// <param name="requireAvc">Optional. Whether to require avc.</param>
         /// <param name="deInterlace">Optional. Whether to deinterlace the video.</param>
-        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamporphic stream.</param>
+        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamorphic stream.</param>
         /// <param name="transcodingMaxAudioChannels">Optional. The maximum number of audio channels to transcode.</param>
         /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param>
         /// <param name="liveStreamId">The live stream id.</param>
@@ -615,7 +615,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="deviceProfileId">Optional. The dlna device profile id to utilize.</param>
         /// <param name="playSessionId">The play session id.</param>
         /// <param name="segmentContainer">The segment container.</param>
-        /// <param name="segmentLength">The segment lenght.</param>
+        /// <param name="segmentLength">The segment length.</param>
         /// <param name="minSegments">The minimum number of segments.</param>
         /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param>
         /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param>
@@ -645,7 +645,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxVideoBitDepth">Optional. The maximum video bit depth.</param>
         /// <param name="requireAvc">Optional. Whether to require avc.</param>
         /// <param name="deInterlace">Optional. Whether to deinterlace the video.</param>
-        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamporphic stream.</param>
+        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamorphic stream.</param>
         /// <param name="transcodingMaxAudioChannels">Optional. The maximum number of audio channels to transcode.</param>
         /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param>
         /// <param name="liveStreamId">The live stream id.</param>
@@ -812,7 +812,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxVideoBitDepth">Optional. The maximum video bit depth.</param>
         /// <param name="requireAvc">Optional. Whether to require avc.</param>
         /// <param name="deInterlace">Optional. Whether to deinterlace the video.</param>
-        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamporphic stream.</param>
+        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamorphic stream.</param>
         /// <param name="transcodingMaxAudioChannels">Optional. The maximum number of audio channels to transcode.</param>
         /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param>
         /// <param name="liveStreamId">The live stream id.</param>
@@ -953,7 +953,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="deviceProfileId">Optional. The dlna device profile id to utilize.</param>
         /// <param name="playSessionId">The play session id.</param>
         /// <param name="segmentContainer">The segment container.</param>
-        /// <param name="segmentLength">The segment lenght.</param>
+        /// <param name="segmentLength">The segment length.</param>
         /// <param name="minSegments">The minimum number of segments.</param>
         /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param>
         /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param>
@@ -983,7 +983,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxVideoBitDepth">Optional. The maximum video bit depth.</param>
         /// <param name="requireAvc">Optional. Whether to require avc.</param>
         /// <param name="deInterlace">Optional. Whether to deinterlace the video.</param>
-        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamporphic stream.</param>
+        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamorphic stream.</param>
         /// <param name="transcodingMaxAudioChannels">Optional. The maximum number of audio channels to transcode.</param>
         /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param>
         /// <param name="liveStreamId">The live stream id.</param>

+ 1 - 1
Jellyfin.Api/Controllers/EnvironmentController.cs

@@ -17,7 +17,7 @@ namespace Jellyfin.Api.Controllers
     /// <summary>
     /// Environment Controller.
     /// </summary>
-    [Authorize(Policy = Policies.RequiresElevation)]
+    [Authorize(Policy = Policies.FirstTimeSetupOrElevated)]
     public class EnvironmentController : BaseJellyfinApiController
     {
         private const char UncSeparator = '\\';

+ 25 - 25
Jellyfin.Api/Controllers/ItemsController.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.ComponentModel.DataAnnotations;
 using System.Globalization;
 using System.Linq;
@@ -73,8 +73,8 @@ namespace Jellyfin.Api.Controllers
         /// <param name="hasParentalRating">Optional filter by items that have or do not have a parental rating.</param>
         /// <param name="isHd">Optional filter by items that are HD or not.</param>
         /// <param name="is4K">Optional filter by items that are 4K or not.</param>
-        /// <param name="locationTypes">Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.</param>
-        /// <param name="excludeLocationTypes">Optional. If specified, results will be filtered based on the LocationType. This allows multiple, comma delimeted.</param>
+        /// <param name="locationTypes">Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimited.</param>
+        /// <param name="excludeLocationTypes">Optional. If specified, results will be filtered based on the LocationType. This allows multiple, comma delimited.</param>
         /// <param name="isMissing">Optional filter by items that are missing episodes or not.</param>
         /// <param name="isUnaired">Optional filter by items that are unaired episodes or not.</param>
         /// <param name="minCommunityRating">Optional filter by minimum community rating.</param>
@@ -87,42 +87,42 @@ namespace Jellyfin.Api.Controllers
         /// <param name="hasImdbId">Optional filter by items that have an imdb id or not.</param>
         /// <param name="hasTmdbId">Optional filter by items that have a tmdb id or not.</param>
         /// <param name="hasTvdbId">Optional filter by items that have a tvdb id or not.</param>
-        /// <param name="excludeItemIds">Optional. If specified, results will be filtered by exxcluding item ids. This allows multiple, comma delimeted.</param>
+        /// <param name="excludeItemIds">Optional. If specified, results will be filtered by excluding item ids. This allows multiple, comma delimited.</param>
         /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
         /// <param name="limit">Optional. The maximum number of records to return.</param>
         /// <param name="recursive">When searching within folders, this determines whether or not the search will be recursive. true/false.</param>
         /// <param name="searchTerm">Optional. Filter based on a search term.</param>
         /// <param name="sortOrder">Sort Order - Ascending,Descending.</param>
         /// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
-        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
-        /// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.</param>
-        /// <param name="includeItemTypes">Optional. If specified, results will be filtered based on the item type. This allows multiple, comma delimeted.</param>
-        /// <param name="filters">Optional. Specify additional filters to apply. This allows multiple, comma delimeted. Options: IsFolder, IsNotFolder, IsUnplayed, IsPlayed, IsFavorite, IsResumable, Likes, Dislikes.</param>
+        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
+        /// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
+        /// <param name="includeItemTypes">Optional. If specified, results will be filtered based on the item type. This allows multiple, comma delimited.</param>
+        /// <param name="filters">Optional. Specify additional filters to apply. This allows multiple, comma delimited. Options: IsFolder, IsNotFolder, IsUnplayed, IsPlayed, IsFavorite, IsResumable, Likes, Dislikes.</param>
         /// <param name="isFavorite">Optional filter by items that are marked as favorite, or not.</param>
         /// <param name="mediaTypes">Optional filter by MediaType. Allows multiple, comma delimited.</param>
         /// <param name="imageTypes">Optional. If specified, results will be filtered based on those containing image types. This allows multiple, comma delimited.</param>
-        /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime.</param>
+        /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimited. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime.</param>
         /// <param name="isPlayed">Optional filter by items that are played, or not.</param>
-        /// <param name="genres">Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimeted.</param>
-        /// <param name="officialRatings">Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimeted.</param>
-        /// <param name="tags">Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimeted.</param>
-        /// <param name="years">Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimeted.</param>
+        /// <param name="genres">Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimited.</param>
+        /// <param name="officialRatings">Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimited.</param>
+        /// <param name="tags">Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimited.</param>
+        /// <param name="years">Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimited.</param>
         /// <param name="enableUserData">Optional, include user data.</param>
         /// <param name="imageTypeLimit">Optional, the max number of images to return, per image type.</param>
         /// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
         /// <param name="person">Optional. If specified, results will be filtered to include only those containing the specified person.</param>
         /// <param name="personIds">Optional. If specified, results will be filtered to include only those containing the specified person id.</param>
         /// <param name="personTypes">Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited.</param>
-        /// <param name="studios">Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.</param>
-        /// <param name="artists">Optional. If specified, results will be filtered based on artists. This allows multiple, pipe delimeted.</param>
-        /// <param name="excludeArtistIds">Optional. If specified, results will be filtered based on artist id. This allows multiple, pipe delimeted.</param>
+        /// <param name="studios">Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimited.</param>
+        /// <param name="artists">Optional. If specified, results will be filtered based on artists. This allows multiple, pipe delimited.</param>
+        /// <param name="excludeArtistIds">Optional. If specified, results will be filtered based on artist id. This allows multiple, pipe delimited.</param>
         /// <param name="artistIds">Optional. If specified, results will be filtered to include only those containing the specified artist id.</param>
         /// <param name="albumArtistIds">Optional. If specified, results will be filtered to include only those containing the specified album artist id.</param>
         /// <param name="contributingArtistIds">Optional. If specified, results will be filtered to include only those containing the specified contributing artist id.</param>
-        /// <param name="albums">Optional. If specified, results will be filtered based on album. This allows multiple, pipe delimeted.</param>
-        /// <param name="albumIds">Optional. If specified, results will be filtered based on album id. This allows multiple, pipe delimeted.</param>
+        /// <param name="albums">Optional. If specified, results will be filtered based on album. This allows multiple, pipe delimited.</param>
+        /// <param name="albumIds">Optional. If specified, results will be filtered based on album id. This allows multiple, pipe delimited.</param>
         /// <param name="ids">Optional. If specific items are needed, specify a list of item id's to retrieve. This allows multiple, comma delimited.</param>
-        /// <param name="videoTypes">Optional filter by VideoType (videofile, dvd, bluray, iso). Allows multiple, comma delimeted.</param>
+        /// <param name="videoTypes">Optional filter by VideoType (videofile, dvd, bluray, iso). Allows multiple, comma delimited.</param>
         /// <param name="minOfficialRating">Optional filter by minimum official rating (PG, PG-13, TV-MA, etc).</param>
         /// <param name="isLocked">Optional filter by items that are locked.</param>
         /// <param name="isPlaceHolder">Optional filter by items that are placeholders.</param>
@@ -133,12 +133,12 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxWidth">Optional. Filter by the maximum width of the item.</param>
         /// <param name="maxHeight">Optional. Filter by the maximum height of the item.</param>
         /// <param name="is3D">Optional filter by items that are 3D, or not.</param>
-        /// <param name="seriesStatus">Optional filter by Series Status. Allows multiple, comma delimeted.</param>
+        /// <param name="seriesStatus">Optional filter by Series Status. Allows multiple, comma delimited.</param>
         /// <param name="nameStartsWithOrGreater">Optional filter by items whose name is sorted equally or greater than a given input string.</param>
         /// <param name="nameStartsWith">Optional filter by items whose name is sorted equally than a given input string.</param>
         /// <param name="nameLessThan">Optional filter by items whose name is equally or lesser than a given input string.</param>
-        /// <param name="studioIds">Optional. If specified, results will be filtered based on studio id. This allows multiple, pipe delimeted.</param>
-        /// <param name="genreIds">Optional. If specified, results will be filtered based on genre id. This allows multiple, pipe delimeted.</param>
+        /// <param name="studioIds">Optional. If specified, results will be filtered based on studio id. This allows multiple, pipe delimited.</param>
+        /// <param name="genreIds">Optional. If specified, results will be filtered based on genre id. This allows multiple, pipe delimited.</param>
         /// <param name="enableTotalRecordCount">Optional. Enable the total record count.</param>
         /// <param name="enableImages">Optional, include image information in output.</param>
         /// <returns>A <see cref="QueryResult{BaseItemDto}"/> with the items.</returns>
@@ -513,13 +513,13 @@ namespace Jellyfin.Api.Controllers
         /// <param name="limit">The item limit.</param>
         /// <param name="searchTerm">The search term.</param>
         /// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
-        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
+        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
         /// <param name="mediaTypes">Optional. Filter by MediaType. Allows multiple, comma delimited.</param>
         /// <param name="enableUserData">Optional. Include user data.</param>
         /// <param name="imageTypeLimit">Optional. The max number of images to return, per image type.</param>
         /// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
-        /// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.</param>
-        /// <param name="includeItemTypes">Optional. If specified, results will be filtered based on the item type. This allows multiple, comma delimeted.</param>
+        /// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
+        /// <param name="includeItemTypes">Optional. If specified, results will be filtered based on the item type. This allows multiple, comma delimited.</param>
         /// <param name="enableTotalRecordCount">Optional. Enable the total record count.</param>
         /// <param name="enableImages">Optional. Include image information in output.</param>
         /// <response code="200">Items returned.</response>

+ 3 - 2
Jellyfin.Api/Controllers/LiveTvController.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Diagnostics.CodeAnalysis;
@@ -1155,7 +1155,8 @@ namespace Jellyfin.Api.Controllers
         /// <param name="newDevicesOnly">Only discover new tuners.</param>
         /// <response code="200">Tuners returned.</response>
         /// <returns>An <see cref="OkResult"/> containing the tuners.</returns>
-        [HttpGet("Tuners/Discvover")]
+        [HttpGet("Tuners/Discvover", Name = "DiscvoverTuners")]
+        [HttpGet("Tuners/Discover")]
         [Authorize(Policy = Policies.DefaultAuthorization)]
         [ProducesResponseType(StatusCodes.Status200OK)]
         public async Task<ActionResult<IEnumerable<TunerHostInfo>>> DiscoverTuners([FromQuery] bool newDevicesOnly = false)

+ 21 - 21
Jellyfin.Api/Controllers/TrailersController.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using Jellyfin.Api.Constants;
 using Jellyfin.Api.ModelBinders;
 using MediaBrowser.Model.Dto;
@@ -42,8 +42,8 @@ namespace Jellyfin.Api.Controllers
         /// <param name="hasParentalRating">Optional filter by items that have or do not have a parental rating.</param>
         /// <param name="isHd">Optional filter by items that are HD or not.</param>
         /// <param name="is4K">Optional filter by items that are 4K or not.</param>
-        /// <param name="locationTypes">Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.</param>
-        /// <param name="excludeLocationTypes">Optional. If specified, results will be filtered based on the LocationType. This allows multiple, comma delimeted.</param>
+        /// <param name="locationTypes">Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimited.</param>
+        /// <param name="excludeLocationTypes">Optional. If specified, results will be filtered based on the LocationType. This allows multiple, comma delimited.</param>
         /// <param name="isMissing">Optional filter by items that are missing episodes or not.</param>
         /// <param name="isUnaired">Optional filter by items that are unaired episodes or not.</param>
         /// <param name="minCommunityRating">Optional filter by minimum community rating.</param>
@@ -56,41 +56,41 @@ namespace Jellyfin.Api.Controllers
         /// <param name="hasImdbId">Optional filter by items that have an imdb id or not.</param>
         /// <param name="hasTmdbId">Optional filter by items that have a tmdb id or not.</param>
         /// <param name="hasTvdbId">Optional filter by items that have a tvdb id or not.</param>
-        /// <param name="excludeItemIds">Optional. If specified, results will be filtered by exxcluding item ids. This allows multiple, comma delimeted.</param>
+        /// <param name="excludeItemIds">Optional. If specified, results will be filtered by excluding item ids. This allows multiple, comma delimited.</param>
         /// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
         /// <param name="limit">Optional. The maximum number of records to return.</param>
         /// <param name="recursive">When searching within folders, this determines whether or not the search will be recursive. true/false.</param>
         /// <param name="searchTerm">Optional. Filter based on a search term.</param>
         /// <param name="sortOrder">Sort Order - Ascending,Descending.</param>
         /// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
-        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
-        /// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.</param>
-        /// <param name="filters">Optional. Specify additional filters to apply. This allows multiple, comma delimeted. Options: IsFolder, IsNotFolder, IsUnplayed, IsPlayed, IsFavorite, IsResumable, Likes, Dislikes.</param>
+        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
+        /// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
+        /// <param name="filters">Optional. Specify additional filters to apply. This allows multiple, comma delimited. Options: IsFolder, IsNotFolder, IsUnplayed, IsPlayed, IsFavorite, IsResumable, Likes, Dislikes.</param>
         /// <param name="isFavorite">Optional filter by items that are marked as favorite, or not.</param>
         /// <param name="mediaTypes">Optional filter by MediaType. Allows multiple, comma delimited.</param>
         /// <param name="imageTypes">Optional. If specified, results will be filtered based on those containing image types. This allows multiple, comma delimited.</param>
-        /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime.</param>
+        /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimited. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime.</param>
         /// <param name="isPlayed">Optional filter by items that are played, or not.</param>
-        /// <param name="genres">Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimeted.</param>
-        /// <param name="officialRatings">Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimeted.</param>
-        /// <param name="tags">Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimeted.</param>
-        /// <param name="years">Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimeted.</param>
+        /// <param name="genres">Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimited.</param>
+        /// <param name="officialRatings">Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimited.</param>
+        /// <param name="tags">Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimited.</param>
+        /// <param name="years">Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimited.</param>
         /// <param name="enableUserData">Optional, include user data.</param>
         /// <param name="imageTypeLimit">Optional, the max number of images to return, per image type.</param>
         /// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
         /// <param name="person">Optional. If specified, results will be filtered to include only those containing the specified person.</param>
         /// <param name="personIds">Optional. If specified, results will be filtered to include only those containing the specified person id.</param>
         /// <param name="personTypes">Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited.</param>
-        /// <param name="studios">Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.</param>
-        /// <param name="artists">Optional. If specified, results will be filtered based on artists. This allows multiple, pipe delimeted.</param>
-        /// <param name="excludeArtistIds">Optional. If specified, results will be filtered based on artist id. This allows multiple, pipe delimeted.</param>
+        /// <param name="studios">Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimited.</param>
+        /// <param name="artists">Optional. If specified, results will be filtered based on artists. This allows multiple, pipe delimited.</param>
+        /// <param name="excludeArtistIds">Optional. If specified, results will be filtered based on artist id. This allows multiple, pipe delimited.</param>
         /// <param name="artistIds">Optional. If specified, results will be filtered to include only those containing the specified artist id.</param>
         /// <param name="albumArtistIds">Optional. If specified, results will be filtered to include only those containing the specified album artist id.</param>
         /// <param name="contributingArtistIds">Optional. If specified, results will be filtered to include only those containing the specified contributing artist id.</param>
-        /// <param name="albums">Optional. If specified, results will be filtered based on album. This allows multiple, pipe delimeted.</param>
-        /// <param name="albumIds">Optional. If specified, results will be filtered based on album id. This allows multiple, pipe delimeted.</param>
+        /// <param name="albums">Optional. If specified, results will be filtered based on album. This allows multiple, pipe delimited.</param>
+        /// <param name="albumIds">Optional. If specified, results will be filtered based on album id. This allows multiple, pipe delimited.</param>
         /// <param name="ids">Optional. If specific items are needed, specify a list of item id's to retrieve. This allows multiple, comma delimited.</param>
-        /// <param name="videoTypes">Optional filter by VideoType (videofile, dvd, bluray, iso). Allows multiple, comma delimeted.</param>
+        /// <param name="videoTypes">Optional filter by VideoType (videofile, dvd, bluray, iso). Allows multiple, comma delimited.</param>
         /// <param name="minOfficialRating">Optional filter by minimum official rating (PG, PG-13, TV-MA, etc).</param>
         /// <param name="isLocked">Optional filter by items that are locked.</param>
         /// <param name="isPlaceHolder">Optional filter by items that are placeholders.</param>
@@ -101,12 +101,12 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxWidth">Optional. Filter by the maximum width of the item.</param>
         /// <param name="maxHeight">Optional. Filter by the maximum height of the item.</param>
         /// <param name="is3D">Optional filter by items that are 3D, or not.</param>
-        /// <param name="seriesStatus">Optional filter by Series Status. Allows multiple, comma delimeted.</param>
+        /// <param name="seriesStatus">Optional filter by Series Status. Allows multiple, comma delimited.</param>
         /// <param name="nameStartsWithOrGreater">Optional filter by items whose name is sorted equally or greater than a given input string.</param>
         /// <param name="nameStartsWith">Optional filter by items whose name is sorted equally than a given input string.</param>
         /// <param name="nameLessThan">Optional filter by items whose name is equally or lesser than a given input string.</param>
-        /// <param name="studioIds">Optional. If specified, results will be filtered based on studio id. This allows multiple, pipe delimeted.</param>
-        /// <param name="genreIds">Optional. If specified, results will be filtered based on genre id. This allows multiple, pipe delimeted.</param>
+        /// <param name="studioIds">Optional. If specified, results will be filtered based on studio id. This allows multiple, pipe delimited.</param>
+        /// <param name="genreIds">Optional. If specified, results will be filtered based on genre id. This allows multiple, pipe delimited.</param>
         /// <param name="enableTotalRecordCount">Optional. Enable the total record count.</param>
         /// <param name="enableImages">Optional, include image information in output.</param>
         /// <returns>A <see cref="QueryResult{BaseItemDto}"/> with the trailers.</returns>

+ 3 - 3
Jellyfin.Api/Controllers/TvShowsController.cs

@@ -176,7 +176,7 @@ namespace Jellyfin.Api.Controllers
         /// </summary>
         /// <param name="seriesId">The series id.</param>
         /// <param name="userId">The user id.</param>
-        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls.</param>
+        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls.</param>
         /// <param name="season">Optional filter by season number.</param>
         /// <param name="seasonId">Optional. Filter by season id.</param>
         /// <param name="isMissing">Optional. Filter by items that are missing episodes or not.</param>
@@ -188,7 +188,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="imageTypeLimit">Optional, the max number of images to return, per image type.</param>
         /// <param name="enableImageTypes">Optional. The image types to include in the output.</param>
         /// <param name="enableUserData">Optional. Include user data.</param>
-        /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime.</param>
+        /// <param name="sortBy">Optional. Specify one or more sort orders, comma delimited. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime.</param>
         /// <returns>A <see cref="QueryResult{BaseItemDto}"/> with the episodes on success or a <see cref="NotFoundResult"/> if the series was not found.</returns>
         [HttpGet("{seriesId}/Episodes")]
         [ProducesResponseType(StatusCodes.Status200OK)]
@@ -303,7 +303,7 @@ namespace Jellyfin.Api.Controllers
         /// </summary>
         /// <param name="seriesId">The series id.</param>
         /// <param name="userId">The user id.</param>
-        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls.</param>
+        /// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls.</param>
         /// <param name="isSpecialSeason">Optional. Filter by special season.</param>
         /// <param name="isMissing">Optional. Filter by items that are missing episodes or not.</param>
         /// <param name="adjacentTo">Optional. Return items that are siblings of a supplied item.</param>

+ 2 - 2
Jellyfin.Api/Controllers/UserLibraryController.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Linq;
@@ -253,7 +253,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="userId">User id.</param>
         /// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
         /// <param name="fields">Optional. Specify additional fields of information to return in the output.</param>
-        /// <param name="includeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.</param>
+        /// <param name="includeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
         /// <param name="isPlayed">Filter by items that are played, or not.</param>
         /// <param name="enableImages">Optional. include image information in output.</param>
         /// <param name="imageTypeLimit">Optional. the max number of images to return, per image type.</param>

+ 2 - 2
Jellyfin.Api/Controllers/VideoHlsController.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Globalization;
@@ -145,7 +145,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxVideoBitDepth">Optional. The maximum video bit depth.</param>
         /// <param name="requireAvc">Optional. Whether to require avc.</param>
         /// <param name="deInterlace">Optional. Whether to deinterlace the video.</param>
-        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamporphic stream.</param>
+        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamorphic stream.</param>
         /// <param name="transcodingMaxAudioChannels">Optional. The maximum number of audio channels to transcode.</param>
         /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param>
         /// <param name="liveStreamId">The live stream id.</param>

+ 2 - 2
Jellyfin.Api/Controllers/VideosController.cs

@@ -283,7 +283,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="deviceProfileId">Optional. The dlna device profile id to utilize.</param>
         /// <param name="playSessionId">The play session id.</param>
         /// <param name="segmentContainer">The segment container.</param>
-        /// <param name="segmentLength">The segment lenght.</param>
+        /// <param name="segmentLength">The segment length.</param>
         /// <param name="minSegments">The minimum number of segments.</param>
         /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param>
         /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param>
@@ -312,7 +312,7 @@ namespace Jellyfin.Api.Controllers
         /// <param name="maxVideoBitDepth">Optional. The maximum video bit depth.</param>
         /// <param name="requireAvc">Optional. Whether to require avc.</param>
         /// <param name="deInterlace">Optional. Whether to deinterlace the video.</param>
-        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamporphic stream.</param>
+        /// <param name="requireNonAnamorphic">Optional. Whether to require a non anamorphic stream.</param>
         /// <param name="transcodingMaxAudioChannels">Optional. The maximum number of audio channels to transcode.</param>
         /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param>
         /// <param name="liveStreamId">The live stream id.</param>

+ 4 - 2
Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs

@@ -24,12 +24,14 @@ namespace Jellyfin.Api.Helpers
         /// <param name="isHeadRequest">Whether the current request is a HTTP HEAD request so only the headers get returned.</param>
         /// <param name="httpClient">The <see cref="HttpClient"/> making the remote request.</param>
         /// <param name="httpContext">The current http context.</param>
+        /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
         /// <returns>A <see cref="Task{ActionResult}"/> containing the API response.</returns>
         public static async Task<ActionResult> GetStaticRemoteStreamResult(
             StreamState state,
             bool isHeadRequest,
             HttpClient httpClient,
-            HttpContext httpContext)
+            HttpContext httpContext,
+            CancellationToken cancellationToken = default)
         {
             if (state.RemoteHttpHeaders.TryGetValue(HeaderNames.UserAgent, out var useragent))
             {
@@ -47,7 +49,7 @@ namespace Jellyfin.Api.Helpers
                 return new FileContentResult(Array.Empty<byte>(), contentType);
             }
 
-            return new FileStreamResult(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), contentType);
+            return new FileStreamResult(await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false), contentType);
         }
 
         /// <summary>

+ 2 - 2
Jellyfin.Api/Helpers/TranscodingJobHelper.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Globalization;
@@ -582,7 +582,7 @@ namespace Jellyfin.Api.Helpers
             // Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback
             _ = new JobLogger(_logger).StartStreamingLog(state, process.StandardError.BaseStream, logStream);
 
-            // Wait for the file to exist before proceeeding
+            // Wait for the file to exist before proceeding
             var ffmpegTargetFile = state.WaitForPath ?? outputPath;
             _logger.LogDebug("Waiting for the creation of {0}", ffmpegTargetFile);
             while (!File.Exists(ffmpegTargetFile) && !transcodingJob.HasExited)

+ 2 - 2
Jellyfin.Data/Entities/Libraries/CollectionItem.cs

@@ -73,7 +73,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// Gets or sets the next item in the collection.
         /// </summary>
         /// <remarks>
-        /// TODO check if this properly updated dependant and has the proper principal relationship.
+        /// TODO check if this properly updated Dependant and has the proper principal relationship.
         /// </remarks>
         public virtual CollectionItem Next { get; set; }
 
@@ -81,7 +81,7 @@ namespace Jellyfin.Data.Entities.Libraries
         /// Gets or sets the previous item in the collection.
         /// </summary>
         /// <remarks>
-        /// TODO check if this properly updated dependant and has the proper principal relationship.
+        /// TODO check if this properly updated Dependant and has the proper principal relationship.
         /// </remarks>
         public virtual CollectionItem Previous { get; set; }
 

+ 1 - 1
Jellyfin.Data/Entities/Libraries/ItemMetadata.cs

@@ -141,7 +141,7 @@ namespace Jellyfin.Data.Entities.Libraries
         public virtual ICollection<PersonRole> PersonRoles { get; protected set; }
 
         /// <summary>
-        /// Gets or sets a collection containing the generes for this item.
+        /// Gets or sets a collection containing the genres for this item.
         /// </summary>
         public virtual ICollection<Genre> Genres { get; protected set; }
 

+ 1 - 1
Jellyfin.Server.Implementations/Users/DefaultAuthenticationProvider.cs

@@ -53,7 +53,7 @@ namespace Jellyfin.Server.Implementations.Users
 
             bool success = false;
 
-            // As long as jellyfin supports passwordless users, we need this little block here to accommodate
+            // As long as jellyfin supports password-less users, we need this little block here to accommodate
             if (!HasPassword(resolvedUser) && string.IsNullOrEmpty(password))
             {
                 return Task.FromResult(new ProviderAuthenticationResult

+ 2 - 0
Jellyfin.Server/CoreAppHost.cs

@@ -13,6 +13,7 @@ using Jellyfin.Server.Implementations.Events;
 using Jellyfin.Server.Implementations.Users;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Controller;
+using MediaBrowser.Controller.BaseItemManager;
 using MediaBrowser.Controller.Drawing;
 using MediaBrowser.Controller.Events;
 using MediaBrowser.Controller.Library;
@@ -76,6 +77,7 @@ namespace Jellyfin.Server
                  options => options.UseSqlite($"Filename={Path.Combine(ApplicationPaths.DataPath, "jellyfin.db")}"));
 
             ServiceCollection.AddEventServices();
+            ServiceCollection.AddSingleton<IBaseItemManager, BaseItemManager>();
             ServiceCollection.AddSingleton<IEventManager, EventManager>();
             ServiceCollection.AddSingleton<JellyfinDbProvider>();
 

+ 1 - 1
MediaBrowser.Common/MediaBrowser.Common.csproj

@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
 
   <!-- ProjectGuid is only included as a requirement for SonarQube analysis -->
   <PropertyGroup>

+ 1 - 2
MediaBrowser.Common/Net/DefaultHttpClientHandler.cs

@@ -13,8 +13,7 @@ namespace MediaBrowser.Common.Net
         /// </summary>
         public DefaultHttpClientHandler()
         {
-            // TODO change to DecompressionMethods.All with .NET5
-            AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
+            AutomaticDecompression = DecompressionMethods.All;
         }
     }
 }

+ 2 - 2
MediaBrowser.Common/Net/INetworkManager.cs

@@ -58,7 +58,7 @@ namespace MediaBrowser.Common.Net
         /// <summary>
         /// Investigates an caches a list of interface addresses, excluding local link and LAN excluded addresses.
         /// </summary>
-        /// <returns>The list of ipaddresses.</returns>
+        /// <returns>The list of ip addresses.</returns>
         IPAddress[] GetLocalIpAddresses();
 
         /// <summary>
@@ -73,7 +73,7 @@ namespace MediaBrowser.Common.Net
         /// Returns true if address is in the LAN list in the config file.
         /// </summary>
         /// <param name="address">The address to check.</param>
-        /// <param name="excludeInterfaces">If true, check against addresses in the LAN settings which have [] arroud and return true if it matches the address give in address.</param>
+        /// <param name="excludeInterfaces">If true, check against addresses in the LAN settings which have [] around and return true if it matches the address give in address.</param>
         /// <param name="excludeRFC">If true, returns false if address is in the 127.x.x.x or 169.128.x.x range.</param>
         /// <returns><c>false</c>if the address isn't in the LAN list, <c>true</c> if the address has been defined as a LAN address.</returns>
         bool IsAddressInSubnets(IPAddress address, bool excludeInterfaces, bool excludeRFC);

+ 1 - 1
MediaBrowser.Common/Plugins/BasePlugin.cs

@@ -276,7 +276,7 @@ namespace MediaBrowser.Common.Plugins
 
             SaveConfiguration();
 
-            ConfigurationChanged.Invoke(this, configuration);
+            ConfigurationChanged?.Invoke(this, configuration);
         }
 
         /// <inheritdoc />

+ 86 - 0
MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs

@@ -0,0 +1,86 @@
+using System;
+using System.Linq;
+using MediaBrowser.Controller.Channels;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Configuration;
+
+namespace MediaBrowser.Controller.BaseItemManager
+{
+    /// <inheritdoc />
+    public class BaseItemManager : IBaseItemManager
+    {
+        private readonly IServerConfigurationManager _serverConfigurationManager;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BaseItemManager"/> class.
+        /// </summary>
+        /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
+        public BaseItemManager(IServerConfigurationManager serverConfigurationManager)
+        {
+            _serverConfigurationManager = serverConfigurationManager;
+        }
+
+        /// <inheritdoc />
+        public bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
+        {
+            if (baseItem is Channel)
+            {
+                // Hack alert.
+                return true;
+            }
+
+            if (baseItem.SourceType == SourceType.Channel)
+            {
+                // Hack alert.
+                return !baseItem.EnableMediaSourceDisplay;
+            }
+
+            var typeOptions = libraryOptions.GetTypeOptions(GetType().Name);
+            if (typeOptions != null)
+            {
+                return typeOptions.ImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
+            }
+
+            if (!libraryOptions.EnableInternetProviders)
+            {
+                return false;
+            }
+
+            var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, GetType().Name, StringComparison.OrdinalIgnoreCase));
+
+            return itemConfig == null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
+        }
+
+        /// <inheritdoc />
+        public bool IsImageFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
+        {
+            if (baseItem is Channel)
+            {
+                // Hack alert.
+                return true;
+            }
+
+            if (baseItem.SourceType == SourceType.Channel)
+            {
+                // Hack alert.
+                return !baseItem.EnableMediaSourceDisplay;
+            }
+
+            var typeOptions = libraryOptions.GetTypeOptions(GetType().Name);
+            if (typeOptions != null)
+            {
+                return typeOptions.ImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
+            }
+
+            if (!libraryOptions.EnableInternetProviders)
+            {
+                return false;
+            }
+
+            var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, GetType().Name, StringComparison.OrdinalIgnoreCase));
+
+            return itemConfig == null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
+        }
+    }
+}

+ 29 - 0
MediaBrowser.Controller/BaseItemManager/IBaseItemManager.cs

@@ -0,0 +1,29 @@
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Configuration;
+
+namespace MediaBrowser.Controller.BaseItemManager
+{
+    /// <summary>
+    /// The <c>BaseItem</c> manager.
+    /// </summary>
+    public interface IBaseItemManager
+    {
+        /// <summary>
+        /// Is metadata fetcher enabled.
+        /// </summary>
+        /// <param name="baseItem">The base item.</param>
+        /// <param name="libraryOptions">The library options.</param>
+        /// <param name="name">The metadata fetcher name.</param>
+        /// <returns><c>true</c> if metadata fetcher is enabled, else false.</returns>
+        bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name);
+
+        /// <summary>
+        /// Is image fetcher enabled.
+        /// </summary>
+        /// <param name="baseItem">The base item.</param>
+        /// <param name="libraryOptions">The library options.</param>
+        /// <param name="name">The image fetcher name.</param>
+        /// <returns><c>true</c> if image fetcher is enabled, else false.</returns>
+        bool IsImageFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name);
+    }
+}

+ 1 - 55
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -463,60 +463,6 @@ namespace MediaBrowser.Controller.Entities
         [JsonIgnore]
         public string PrimaryImagePath => this.GetImagePath(ImageType.Primary);
 
-        public bool IsMetadataFetcherEnabled(LibraryOptions libraryOptions, string name)
-        {
-            if (SourceType == SourceType.Channel)
-            {
-                // hack alert
-                return !EnableMediaSourceDisplay;
-            }
-
-            var typeOptions = libraryOptions.GetTypeOptions(GetType().Name);
-            if (typeOptions != null)
-            {
-                return typeOptions.MetadataFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
-            }
-
-            if (!libraryOptions.EnableInternetProviders)
-            {
-                return false;
-            }
-
-            var itemConfig = ConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, GetType().Name, StringComparison.OrdinalIgnoreCase));
-
-            return itemConfig == null || !itemConfig.DisabledMetadataFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
-        }
-
-        public bool IsImageFetcherEnabled(LibraryOptions libraryOptions, string name)
-        {
-            if (this is Channel)
-            {
-                // hack alert
-                return true;
-            }
-
-            if (SourceType == SourceType.Channel)
-            {
-                // hack alert
-                return !EnableMediaSourceDisplay;
-            }
-
-            var typeOptions = libraryOptions.GetTypeOptions(GetType().Name);
-            if (typeOptions != null)
-            {
-                return typeOptions.ImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
-            }
-
-            if (!libraryOptions.EnableInternetProviders)
-            {
-                return false;
-            }
-
-            var itemConfig = ConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, GetType().Name, StringComparison.OrdinalIgnoreCase));
-
-            return itemConfig == null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparer.OrdinalIgnoreCase);
-        }
-
         public virtual bool CanDelete()
         {
             if (SourceType == SourceType.Channel)
@@ -2611,7 +2557,7 @@ namespace MediaBrowser.Controller.Entities
         {
             if (!AllowsMultipleImages(type))
             {
-                throw new ArgumentException("The change index operation is only applicable to backdrops and screenshots");
+                throw new ArgumentException("The change index operation is only applicable to backdrops and screen shots");
             }
 
             var info1 = GetImageInfo(type, index1);

+ 1 - 1
MediaBrowser.Controller/Entities/Folder.cs

@@ -212,7 +212,7 @@ namespace MediaBrowser.Controller.Entities
 
         /// <summary>
         /// Loads our children.  Validation will occur externally.
-        /// We want this sychronous.
+        /// We want this synchronous.
         /// </summary>
         protected virtual List<BaseItem> LoadChildren()
         {

+ 3 - 3
MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs

@@ -63,7 +63,7 @@ namespace MediaBrowser.Controller.MediaEncoding
         {
             // Only use alternative encoders for video files.
             // When using concat with folder rips, if the mfx session fails to initialize, ffmpeg will be stuck retrying and will not exit gracefully
-            // Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this.
+            // Since transcoding of folder rips is experimental anyway, it's not worth adding additional variables such as this.
             if (state.VideoType == VideoType.VideoFile)
             {
                 var hwType = encodingOptions.HardwareAccelerationType;
@@ -247,7 +247,7 @@ namespace MediaBrowser.Controller.MediaEncoding
                 return null;
             }
 
-            // Seeing reported failures here, not sure yet if this is related to specfying input format
+            // Seeing reported failures here, not sure yet if this is related to specifying input format
             if (string.Equals(container, "m4v", StringComparison.OrdinalIgnoreCase))
             {
                 return null;
@@ -2757,7 +2757,7 @@ namespace MediaBrowser.Controller.MediaEncoding
             var videoType = state.MediaSource.VideoType ?? VideoType.VideoFile;
             // Only use alternative encoders for video files.
             // When using concat with folder rips, if the mfx session fails to initialize, ffmpeg will be stuck retrying and will not exit gracefully
-            // Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this.
+            // Since transcoding of folder rips is experimental anyway, it's not worth adding additional variables such as this.
             if (videoType != VideoType.VideoFile)
             {
                 return null;

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