From 4e31feecc66d4ae6900e37d8540809f5545e2039 Mon Sep 17 00:00:00 2001 From: cxfksword <718792+cxfksword@users.noreply.github.com> Date: Thu, 23 Feb 2023 20:03:01 +0800 Subject: [PATCH] Remove default season number. #13 --- .../Providers/EpisodeProvider.cs | 18 +++++++++--------- .../Providers/SeasonProvider.cs | 6 ++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Jellyfin.Plugin.MetaShark/Providers/EpisodeProvider.cs b/Jellyfin.Plugin.MetaShark/Providers/EpisodeProvider.cs index a812910..c08a4b7 100644 --- a/Jellyfin.Plugin.MetaShark/Providers/EpisodeProvider.cs +++ b/Jellyfin.Plugin.MetaShark/Providers/EpisodeProvider.cs @@ -145,7 +145,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers info.Year = parseResult.Year; info.Name = parseResult.ChineseName ?? parseResult.Name; - // 没有season级目录或文件命名不规范时,ParentIndexNumber会为null + // 没有season级目录(即虚拟季)ParentIndexNumber默认是1,季文件夹命名不规范时,ParentIndexNumber默认是null if (info.ParentIndexNumber is null) { info.ParentIndexNumber = parseResult.ParentIndexNumber; @@ -163,7 +163,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers } - // 当没有season级目录时,默认为1,即当成只有一季 + // // 当没有season级目录时,默认为1,即当成只有一季(不需要处理,虚拟季jellyfin默认传的ParentIndexNumber=1) // if (info.ParentIndexNumber is null && season != null && season.LocationType == LocationType.Virtual) // { // this.Log("FixSeasonNumber: season is virtual, set to default 1"); @@ -171,7 +171,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers // } } - // 从series文件夹名称猜出season number (没有季文件夹的在SeasonProvider处理不了,因为info.Path会为空,只能在这里处理) + // 从季文件夹名称猜出season number var seasonFolderPath = Path.GetDirectoryName(info.Path); if (info.ParentIndexNumber is null && seasonFolderPath != null) { @@ -185,12 +185,12 @@ namespace Jellyfin.Plugin.MetaShark.Providers info.ParentIndexNumber = 0; } - // 设为默认季数为1 - if (info.ParentIndexNumber is null) - { - this.Log("FixSeasonNumber: season number is null, set to default 1"); - info.ParentIndexNumber = 1; - } + // // 设为默认季数为1(问题:当同时存在S01和剧场版季文件夹时,剧场版的影片会因为默认第一季而在S01也显示出来) + // if (info.ParentIndexNumber is null) + // { + // this.Log("FixSeasonNumber: season number is null, set to default 1"); + // info.ParentIndexNumber = 1; + // } // 特典优先使用文件名(特典除了前面特别设置,还有SXX/Season XX等默认的) diff --git a/Jellyfin.Plugin.MetaShark/Providers/SeasonProvider.cs b/Jellyfin.Plugin.MetaShark/Providers/SeasonProvider.cs index c011e7b..06b3d9a 100644 --- a/Jellyfin.Plugin.MetaShark/Providers/SeasonProvider.cs +++ b/Jellyfin.Plugin.MetaShark/Providers/SeasonProvider.cs @@ -139,6 +139,12 @@ namespace Jellyfin.Plugin.MetaShark.Providers return null; } + // 没有季文件夹(即虚拟季),info.Path会为空,直接用series的sid + if (string.IsNullOrEmpty(info.Path)) + { + return sid; + } + // 从sereis获取正确名称,info.Name当是标准格式如S01等时,会变成第x季,非标准名称默认文件名 var series = await this._doubanApi.GetMovieAsync(sid, cancellationToken).ConfigureAwait(false); if (series == null)