From 891b9f7a997ce5e5892c1b0f166a921ff07abf68 Mon Sep 17 00:00:00 2001
From: AmbulantRex <21176662+AmbulantRex@users.noreply.github.com>
Date: Thu, 30 Mar 2023 08:59:21 -0600
Subject: Add DLL whitelist support for plugins
---
.../Library/PathExtensions.cs | 99 +++++++++++++++++-----
1 file changed, 80 insertions(+), 19 deletions(-)
(limited to 'Emby.Server.Implementations/Library')
diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs
index 64e7d5446..7e0d0b78d 100644
--- a/Emby.Server.Implementations/Library/PathExtensions.cs
+++ b/Emby.Server.Implementations/Library/PathExtensions.cs
@@ -1,6 +1,9 @@
using System;
using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
using MediaBrowser.Common.Providers;
+using Nikse.SubtitleEdit.Core.Common;
namespace Emby.Server.Implementations.Library
{
@@ -86,24 +89,8 @@ namespace Emby.Server.Implementations.Library
return false;
}
- char oldDirectorySeparatorChar;
- char newDirectorySeparatorChar;
- // True normalization is still not possible https://github.com/dotnet/runtime/issues/2162
- // The reasoning behind this is that a forward slash likely means it's a Linux path and
- // so the whole path should be normalized to use / and vice versa for Windows (although Windows doesn't care much).
- if (newSubPath.Contains('/', StringComparison.Ordinal))
- {
- oldDirectorySeparatorChar = '\\';
- newDirectorySeparatorChar = '/';
- }
- else
- {
- oldDirectorySeparatorChar = '/';
- newDirectorySeparatorChar = '\\';
- }
-
- path = path.Replace(oldDirectorySeparatorChar, newDirectorySeparatorChar);
- subPath = subPath.Replace(oldDirectorySeparatorChar, newDirectorySeparatorChar);
+ subPath = subPath.NormalizePath(out var newDirectorySeparatorChar)!;
+ path = path.NormalizePath(newDirectorySeparatorChar)!;
// We have to ensure that the sub path ends with a directory separator otherwise we'll get weird results
// when the sub path matches a similar but in-complete subpath
@@ -120,12 +107,86 @@ namespace Emby.Server.Implementations.Library
return false;
}
- var newSubPathTrimmed = newSubPath.AsSpan().TrimEnd(newDirectorySeparatorChar);
+ var newSubPathTrimmed = newSubPath.AsSpan().TrimEnd((char)newDirectorySeparatorChar!);
// Ensure that the path with the old subpath removed starts with a leading dir separator
int idx = oldSubPathEndsWithSeparator ? subPath.Length - 1 : subPath.Length;
newPath = string.Concat(newSubPathTrimmed, path.AsSpan(idx));
return true;
}
+
+ ///
+ /// Retrieves the full resolved path and normalizes path separators to the .
+ ///
+ /// The path to canonicalize.
+ /// The fully expanded, normalized path.
+ public static string Canonicalize(this string path)
+ {
+ return Path.GetFullPath(path).NormalizePath()!;
+ }
+
+ ///
+ /// Normalizes the path's directory separator character to the currently defined .
+ ///
+ /// The path to normalize.
+ /// The normalized path string or if the input path is null or empty.
+ public static string? NormalizePath(this string? path)
+ {
+ return path.NormalizePath(Path.DirectorySeparatorChar);
+ }
+
+ ///
+ /// Normalizes the path's directory separator character.
+ ///
+ /// The path to normalize.
+ /// The separator character the path now uses or .
+ /// The normalized path string or if the input path is null or empty.
+ public static string? NormalizePath(this string? path, out char separator)
+ {
+ if (string.IsNullOrEmpty(path))
+ {
+ separator = default;
+ return path;
+ }
+
+ var newSeparator = '\\';
+
+ // True normalization is still not possible https://github.com/dotnet/runtime/issues/2162
+ // The reasoning behind this is that a forward slash likely means it's a Linux path and
+ // so the whole path should be normalized to use / and vice versa for Windows (although Windows doesn't care much).
+ if (path.Contains('/', StringComparison.Ordinal))
+ {
+ newSeparator = '/';
+ }
+
+ separator = newSeparator;
+
+ return path?.NormalizePath(newSeparator);
+ }
+
+ ///
+ /// Normalizes the path's directory separator character to the specified character.
+ ///
+ /// The path to normalize.
+ /// The replacement directory separator character. Must be a valid directory separator.
+ /// The normalized path.
+ /// Thrown if the new separator character is not a directory separator.
+ public static string? NormalizePath(this string? path, char newSeparator)
+ {
+ const char Bs = '\\';
+ const char Fs = '/';
+
+ if (!(newSeparator == Bs || newSeparator == Fs))
+ {
+ throw new ArgumentException("The character must be a directory separator.");
+ }
+
+ if (string.IsNullOrEmpty(path))
+ {
+ return path;
+ }
+
+ return newSeparator == Bs ? path?.Replace(Fs, newSeparator) : path?.Replace(Bs, newSeparator);
+ }
}
}
--
cgit v1.2.3
From 677b1f8e34799d26ffa9ef792aabcc79ad9073ca Mon Sep 17 00:00:00 2001
From: AmbulantRex <21176662+AmbulantRex@users.noreply.github.com>
Date: Thu, 30 Mar 2023 12:56:57 -0600
Subject: Remove unnecessary using statements in PluginManager
---
Emby.Server.Implementations/Library/PathExtensions.cs | 2 --
Emby.Server.Implementations/Plugins/PluginManager.cs | 3 ---
2 files changed, 5 deletions(-)
(limited to 'Emby.Server.Implementations/Library')
diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs
index 7e0d0b78d..a3d748a13 100644
--- a/Emby.Server.Implementations/Library/PathExtensions.cs
+++ b/Emby.Server.Implementations/Library/PathExtensions.cs
@@ -1,9 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
-using System.Linq;
using MediaBrowser.Common.Providers;
-using Nikse.SubtitleEdit.Core.Common;
namespace Emby.Server.Implementations.Library
{
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs
index a5c55c8a0..d253a0ab9 100644
--- a/Emby.Server.Implementations/Plugins/PluginManager.cs
+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs
@@ -22,11 +22,8 @@ using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Updates;
-using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Nikse.SubtitleEdit.Core.Common;
-using SQLitePCL.pretty;
namespace Emby.Server.Implementations.Plugins
{
--
cgit v1.2.3
From a944352aa8b961ab723fed2d66947c19129a11cc Mon Sep 17 00:00:00 2001
From: AmbulantRex <21176662+AmbulantRex@users.noreply.github.com>
Date: Sat, 1 Apr 2023 04:59:07 -0600
Subject: Correct style inconsistencies
---
Emby.Server.Implementations/Library/PathExtensions.cs | 9 ++++++---
Emby.Server.Implementations/Plugins/PluginManager.cs | 2 +-
MediaBrowser.Common/Plugins/PluginManifest.cs | 4 ++--
MediaBrowser.Model/Updates/VersionInfo.cs | 2 +-
.../Test Data/Updates/manifest-stable.json | 2 +-
5 files changed, 11 insertions(+), 8 deletions(-)
(limited to 'Emby.Server.Implementations/Library')
diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs
index a3d748a13..62a9e6419 100644
--- a/Emby.Server.Implementations/Library/PathExtensions.cs
+++ b/Emby.Server.Implementations/Library/PathExtensions.cs
@@ -87,8 +87,8 @@ namespace Emby.Server.Implementations.Library
return false;
}
- subPath = subPath.NormalizePath(out var newDirectorySeparatorChar)!;
- path = path.NormalizePath(newDirectorySeparatorChar)!;
+ subPath = subPath.NormalizePath(out var newDirectorySeparatorChar);
+ path = path.NormalizePath(newDirectorySeparatorChar);
// We have to ensure that the sub path ends with a directory separator otherwise we'll get weird results
// when the sub path matches a similar but in-complete subpath
@@ -128,6 +128,7 @@ namespace Emby.Server.Implementations.Library
///
/// The path to normalize.
/// The normalized path string or if the input path is null or empty.
+ [return: NotNullIfNotNull(nameof(path))]
public static string? NormalizePath(this string? path)
{
return path.NormalizePath(Path.DirectorySeparatorChar);
@@ -139,6 +140,7 @@ namespace Emby.Server.Implementations.Library
/// The path to normalize.
/// The separator character the path now uses or .
/// The normalized path string or if the input path is null or empty.
+ [return: NotNullIfNotNull(nameof(path))]
public static string? NormalizePath(this string? path, out char separator)
{
if (string.IsNullOrEmpty(path))
@@ -169,6 +171,7 @@ namespace Emby.Server.Implementations.Library
/// The replacement directory separator character. Must be a valid directory separator.
/// The normalized path.
/// Thrown if the new separator character is not a directory separator.
+ [return: NotNullIfNotNull(nameof(path))]
public static string? NormalizePath(this string? path, char newSeparator)
{
const char Bs = '\\';
@@ -184,7 +187,7 @@ namespace Emby.Server.Implementations.Library
return path;
}
- return newSeparator == Bs ? path?.Replace(Fs, newSeparator) : path?.Replace(Bs, newSeparator);
+ return newSeparator == Bs ? path.Replace(Fs, newSeparator) : path.Replace(Bs, newSeparator);
}
}
}
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs
index d253a0ab9..0a7c144ed 100644
--- a/Emby.Server.Implementations/Plugins/PluginManager.cs
+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs
@@ -765,7 +765,7 @@ namespace Emby.Server.Implementations.Plugins
/// If the is null.
private bool TryGetPluginDlls(LocalPlugin plugin, out IReadOnlyList whitelistedDlls)
{
- _ = plugin ?? throw new ArgumentNullException(nameof(plugin));
+ ArgumentNullException.ThrowIfNull(nameof(plugin));
IReadOnlyList pluginDlls = Directory.GetFiles(plugin.Path, "*.dll", SearchOption.AllDirectories);
diff --git a/MediaBrowser.Common/Plugins/PluginManifest.cs b/MediaBrowser.Common/Plugins/PluginManifest.cs
index 2bad3454d..e0847ccea 100644
--- a/MediaBrowser.Common/Plugins/PluginManifest.cs
+++ b/MediaBrowser.Common/Plugins/PluginManifest.cs
@@ -24,7 +24,7 @@ namespace MediaBrowser.Common.Plugins
Overview = string.Empty;
TargetAbi = string.Empty;
Version = string.Empty;
- Assemblies = new List();
+ Assemblies = Array.Empty();
}
///
@@ -112,6 +112,6 @@ namespace MediaBrowser.Common.Plugins
/// Paths are considered relative to the plugin folder.
///
[JsonPropertyName("assemblies")]
- public IList Assemblies { get; set; }
+ public IReadOnlyList Assemblies { get; set; }
}
}
diff --git a/MediaBrowser.Model/Updates/VersionInfo.cs b/MediaBrowser.Model/Updates/VersionInfo.cs
index 1e24bde84..8f7680645 100644
--- a/MediaBrowser.Model/Updates/VersionInfo.cs
+++ b/MediaBrowser.Model/Updates/VersionInfo.cs
@@ -80,6 +80,6 @@ namespace MediaBrowser.Model.Updates
/// Gets or sets the assemblies whitelist for this version.
///
[JsonPropertyName("assemblies")]
- public IList Assemblies { get; set; } = Array.Empty();
+ public IReadOnlyList Assemblies { get; set; } = Array.Empty();
}
}
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Test Data/Updates/manifest-stable.json b/tests/Jellyfin.Server.Implementations.Tests/Test Data/Updates/manifest-stable.json
index d69a52d6d..3aec29958 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Test Data/Updates/manifest-stable.json
+++ b/tests/Jellyfin.Server.Implementations.Tests/Test Data/Updates/manifest-stable.json
@@ -25,7 +25,7 @@
"timestamp": "2020-07-20T01:30:16Z",
"assemblies": [ "Jellyfin.Plugin.Anime.dll" ]
}
- ]
+ ]
},
{
"guid": "70b7b43b-471b-4159-b4be-56750c795499",
--
cgit v1.2.3
From 3a731051adf6d636517e5a9babbbe9f9da7d520b Mon Sep 17 00:00:00 2001
From: AmbulantRex <21176662+AmbulantRex@users.noreply.github.com>
Date: Sat, 1 Apr 2023 05:03:55 -0600
Subject: Correct styling inconsistencies
---
Emby.Server.Implementations/Library/PathExtensions.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'Emby.Server.Implementations/Library')
diff --git a/Emby.Server.Implementations/Library/PathExtensions.cs b/Emby.Server.Implementations/Library/PathExtensions.cs
index 62a9e6419..c4b6b3756 100644
--- a/Emby.Server.Implementations/Library/PathExtensions.cs
+++ b/Emby.Server.Implementations/Library/PathExtensions.cs
@@ -105,7 +105,7 @@ namespace Emby.Server.Implementations.Library
return false;
}
- var newSubPathTrimmed = newSubPath.AsSpan().TrimEnd((char)newDirectorySeparatorChar!);
+ var newSubPathTrimmed = newSubPath.AsSpan().TrimEnd(newDirectorySeparatorChar);
// Ensure that the path with the old subpath removed starts with a leading dir separator
int idx = oldSubPathEndsWithSeparator ? subPath.Length - 1 : subPath.Length;
newPath = string.Concat(newSubPathTrimmed, path.AsSpan(idx));
@@ -120,7 +120,7 @@ namespace Emby.Server.Implementations.Library
/// The fully expanded, normalized path.
public static string Canonicalize(this string path)
{
- return Path.GetFullPath(path).NormalizePath()!;
+ return Path.GetFullPath(path).NormalizePath();
}
///
@@ -161,7 +161,7 @@ namespace Emby.Server.Implementations.Library
separator = newSeparator;
- return path?.NormalizePath(newSeparator);
+ return path.NormalizePath(newSeparator);
}
///
--
cgit v1.2.3
From 6ddc449a89ac615deb8c6d736e9cac7af4e02b9c Mon Sep 17 00:00:00 2001
From: Shadowghost
Date: Tue, 2 Aug 2022 17:46:38 +0200
Subject: Implement NFO named season parsing
---
.../Library/Resolvers/TV/SeasonResolver.cs | 26 +++++---
MediaBrowser.Controller/Entities/TV/Series.cs | 4 ++
MediaBrowser.Providers/Manager/MetadataService.cs | 1 +
MediaBrowser.Providers/TV/SeriesMetadataService.cs | 78 ++++++++++++++++------
.../Parsers/SeasonNfoParser.cs | 12 ++++
.../Parsers/SeriesNfoParser.cs | 15 +++++
6 files changed, 107 insertions(+), 29 deletions(-)
(limited to 'Emby.Server.Implementations/Library')
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
index 62a524d2e..e9538a5c9 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
@@ -81,14 +81,24 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
if (season.IndexNumber.HasValue)
{
var seasonNumber = season.IndexNumber.Value;
-
- season.Name = seasonNumber == 0 ?
- args.LibraryOptions.SeasonZeroDisplayName :
- string.Format(
- CultureInfo.InvariantCulture,
- _localization.GetLocalizedString("NameSeasonNumber"),
- seasonNumber,
- args.LibraryOptions.PreferredMetadataLanguage);
+ if (string.IsNullOrEmpty(season.Name))
+ {
+ var seasonNames = series.SeasonNames;
+ if (seasonNames.TryGetValue(seasonNumber, out var seasonName))
+ {
+ season.Name = seasonName;
+ }
+ else
+ {
+ season.Name = seasonNumber == 0 ?
+ args.LibraryOptions.SeasonZeroDisplayName :
+ string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("NameSeasonNumber"),
+ seasonNumber,
+ args.LibraryOptions.PreferredMetadataLanguage);
+ }
+ }
}
return season;
diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs
index e7a8a773e..a49c1609d 100644
--- a/MediaBrowser.Controller/Entities/TV/Series.cs
+++ b/MediaBrowser.Controller/Entities/TV/Series.cs
@@ -28,12 +28,16 @@ namespace MediaBrowser.Controller.Entities.TV
public Series()
{
AirDays = Array.Empty();
+ SeasonNames = new Dictionary();
}
public DayOfWeek[] AirDays { get; set; }
public string AirTime { get; set; }
+ [JsonIgnore]
+ public Dictionary SeasonNames { get; set; }
+
[JsonIgnore]
public override bool SupportsAddingToPlaylist => true;
diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs
index 80f77f7c3..834ef29f5 100644
--- a/MediaBrowser.Providers/Manager/MetadataService.cs
+++ b/MediaBrowser.Providers/Manager/MetadataService.cs
@@ -12,6 +12,7 @@ using Jellyfin.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
+using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs
index 97f938397..b99f1cbdb 100644
--- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs
+++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs
@@ -41,7 +41,7 @@ namespace MediaBrowser.Providers.TV
RemoveObsoleteEpisodes(item);
RemoveObsoleteSeasons(item);
- await FillInMissingSeasonsAsync(item, cancellationToken).ConfigureAwait(false);
+ await UpdateAndCreateSeasonsAsync(item, cancellationToken).ConfigureAwait(false);
}
///
@@ -67,6 +67,24 @@ namespace MediaBrowser.Providers.TV
var sourceItem = source.Item;
var targetItem = target.Item;
+ var sourceSeasonNames = sourceItem.SeasonNames;
+ var targetSeasonNames = targetItem.SeasonNames;
+
+ if (replaceData || targetSeasonNames.Count == 0)
+ {
+ targetItem.SeasonNames = sourceSeasonNames;
+ }
+ else if (targetSeasonNames.Count != sourceSeasonNames.Count || !sourceSeasonNames.Keys.All(targetSeasonNames.ContainsKey))
+ {
+ foreach (var season in sourceSeasonNames)
+ {
+ var seasonNumber = season.Key;
+ if (!targetSeasonNames.ContainsKey(seasonNumber))
+ {
+ targetItem.SeasonNames[seasonNumber] = season.Value;
+ }
+ }
+ }
if (replaceData || string.IsNullOrEmpty(targetItem.AirTime))
{
@@ -86,7 +104,7 @@ namespace MediaBrowser.Providers.TV
private void RemoveObsoleteSeasons(Series series)
{
- // TODO Legacy. It's not really "physical" seasons as any virtual seasons are always converted to non-virtual in FillInMissingSeasonsAsync.
+ // TODO Legacy. It's not really "physical" seasons as any virtual seasons are always converted to non-virtual in UpdateAndCreateSeasonsAsync.
var physicalSeasonNumbers = new HashSet();
var virtualSeasons = new List();
foreach (var existingSeason in series.Children.OfType())
@@ -177,36 +195,43 @@ namespace MediaBrowser.Providers.TV
}
///
- /// Creates seasons for all episodes that aren't in a season folder.
+ /// Creates seasons for all episodes if they don't exist.
/// If no season number can be determined, a dummy season will be created.
+ /// Updates seasons names.
///
/// The series.
/// The cancellation token.
/// The async task.
- private async Task FillInMissingSeasonsAsync(Series series, CancellationToken cancellationToken)
+ private async Task UpdateAndCreateSeasonsAsync(Series series, CancellationToken cancellationToken)
{
+ var seasonNames = series.SeasonNames;
var seriesChildren = series.GetRecursiveChildren(i => i is Episode || i is Season);
- var episodesInSeriesFolder = seriesChildren
+ var seasons = seriesChildren.OfType().ToList();
+ var uniqueSeasonNumbers = seriesChildren
.OfType()
- .Where(i => !i.IsInSeasonFolder);
-
- List seasons = seriesChildren.OfType().ToList();
+ .Select(e => e.ParentIndexNumber >= 0 ? e.ParentIndexNumber : null)
+ .Distinct();
// Loop through the unique season numbers
- foreach (var episode in episodesInSeriesFolder)
+ foreach (var seasonNumber in uniqueSeasonNumbers)
{
// Null season numbers will have a 'dummy' season created because seasons are always required.
- var seasonNumber = episode.ParentIndexNumber >= 0 ? episode.ParentIndexNumber : null;
var existingSeason = seasons.FirstOrDefault(i => i.IndexNumber == seasonNumber);
+ string? seasonName = null;
+
+ if (seasonNumber.HasValue && seasonNames.ContainsKey(seasonNumber.Value))
+ {
+ seasonName = seasonNames[seasonNumber.Value];
+ }
if (existingSeason is null)
{
- var season = await CreateSeasonAsync(series, seasonNumber, cancellationToken).ConfigureAwait(false);
- seasons.Add(season);
+ var season = await CreateSeasonAsync(series, seasonName, seasonNumber, cancellationToken).ConfigureAwait(false);
+ series.AddChild(season);
}
- else if (existingSeason.IsVirtualItem)
+ else
{
- existingSeason.IsVirtualItem = false;
+ existingSeason.Name = GetValidSeasonNameForSeries(series, seasonName, seasonNumber);
await existingSeason.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
}
}
@@ -216,21 +241,17 @@ namespace MediaBrowser.Providers.TV
/// Creates a new season, adds it to the database by linking it to the [series] and refreshes the metadata.
///
/// The series.
+ /// The season name.
/// The season number.
/// The cancellation token.
/// The newly created season.
private async Task CreateSeasonAsync(
Series series,
+ string? seasonName,
int? seasonNumber,
CancellationToken cancellationToken)
{
- string seasonName = seasonNumber switch
- {
- null => _localizationManager.GetLocalizedString("NameSeasonUnknown"),
- 0 => LibraryManager.GetLibraryOptions(series).SeasonZeroDisplayName,
- _ => string.Format(CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("NameSeasonNumber"), seasonNumber.Value)
- };
-
+ seasonName = GetValidSeasonNameForSeries(series, seasonName, seasonNumber);
Logger.LogInformation("Creating Season {SeasonName} entry for {SeriesName}", seasonName, series.Name);
var season = new Season
@@ -251,5 +272,20 @@ namespace MediaBrowser.Providers.TV
return season;
}
+
+ private string GetValidSeasonNameForSeries(Series series, string? seasonName, int? seasonNumber)
+ {
+ if (string.IsNullOrEmpty(seasonName))
+ {
+ seasonName = seasonNumber switch
+ {
+ null => _localizationManager.GetLocalizedString("NameSeasonUnknown"),
+ 0 => LibraryManager.GetLibraryOptions(series).SeasonZeroDisplayName,
+ _ => string.Format(CultureInfo.InvariantCulture, _localizationManager.GetLocalizedString("NameSeasonNumber"), seasonNumber.Value)
+ };
+ }
+
+ return seasonName;
+ }
}
}
diff --git a/MediaBrowser.XbmcMetadata/Parsers/SeasonNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/SeasonNfoParser.cs
index 2f5fd40e2..51d5f932b 100644
--- a/MediaBrowser.XbmcMetadata/Parsers/SeasonNfoParser.cs
+++ b/MediaBrowser.XbmcMetadata/Parsers/SeasonNfoParser.cs
@@ -55,6 +55,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers
break;
}
+ case "seasonname":
+ {
+ var name = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrWhiteSpace(name))
+ {
+ item.Name = name;
+ }
+
+ break;
+ }
+
default:
base.FetchDataFromXmlNode(reader, itemResult);
break;
diff --git a/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs
index 3011d65a6..f22b861eb 100644
--- a/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs
+++ b/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs
@@ -1,4 +1,6 @@
using System;
+using System.Collections.Generic;
+using System.Globalization;
using System.Xml;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
@@ -110,6 +112,19 @@ namespace MediaBrowser.XbmcMetadata.Parsers
break;
}
+ case "namedseason":
+ {
+ var parsed = int.TryParse(reader.GetAttribute("number"), NumberStyles.Integer, CultureInfo.InvariantCulture, out var seasonNumber);
+ var name = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrWhiteSpace(name) && parsed)
+ {
+ item.SeasonNames[seasonNumber] = name;
+ }
+
+ break;
+ }
+
default:
base.FetchDataFromXmlNode(reader, itemResult);
break;
--
cgit v1.2.3