From c0e8658cf54821ed030cb64fb72c0e46b6c95f81 Mon Sep 17 00:00:00 2001 From: cxfksword <718792+cxfksword@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:18:44 +0800 Subject: [PATCH] feat: add episode count match config. #42 --- .../Configuration/PluginConfiguration.cs | 15 +++++++++ .../Configuration/configPage.html | 21 ++++++++++++ .../LibraryManagerEventsHelper.cs | 33 +++++++++---------- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/Jellyfin.Plugin.Danmu/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.Danmu/Configuration/PluginConfiguration.cs index a8699be..69e74ab 100644 --- a/Jellyfin.Plugin.Danmu/Configuration/PluginConfiguration.cs +++ b/Jellyfin.Plugin.Danmu/Configuration/PluginConfiguration.cs @@ -42,6 +42,12 @@ public class PluginConfiguration : BasePluginConfiguration /// public string AssSpeed { get; set; } = string.Empty; + + /// + /// 检测弹幕数和视频剧集数需要一致才自动下载弹幕. + /// + public DanmuDownloadOption DownloadOption { get; set; } = new DanmuDownloadOption(); + /// /// 透明度. /// @@ -124,6 +130,15 @@ public class ScraperConfigItem } +public class DanmuDownloadOption +{ + /// + /// 检测弹幕数和视频剧集数需要一致才自动下载弹幕. + /// + public bool EnableEpisodeCountSame { get; set; } = true; + +} + /// /// 弹弹play配置 /// diff --git a/Jellyfin.Plugin.Danmu/Configuration/configPage.html b/Jellyfin.Plugin.Danmu/Configuration/configPage.html index b83dc86..8566aa6 100644 --- a/Jellyfin.Plugin.Danmu/Configuration/configPage.html +++ b/Jellyfin.Plugin.Danmu/Configuration/configPage.html @@ -31,6 +31,21 @@ +
+ +

弹幕匹配下载配置

+
+ +
+ +
勾选后,假如匹配了错误的电视剧,可以避免自动下载错误的弹幕。
+
+
+

弹弹play配置

@@ -120,6 +135,8 @@ document.querySelector('#AssLineCount').value = config.AssLineCount; document.querySelector('#AssSpeed').value = config.AssSpeed; + document.querySelector('#EnableEpisodeCountSame').checked = config.DownloadOption.EnableEpisodeCountSame; + document.querySelector('#WithRelatedDanmu').checked = config.Dandan.WithRelatedDanmu; document.querySelector('#ChConvert').value = config.Dandan.ChConvert; @@ -165,6 +182,10 @@ }); config.Scrapers = scrapers; + var download = new Object(); + download.EnableEpisodeCountSame = document.querySelector('#EnableEpisodeCountSame').checked; + config.DownloadOption = download; + var dandan = new Object(); dandan.WithRelatedDanmu = document.querySelector('#WithRelatedDanmu').checked; dandan.ChConvert = document.querySelector('#ChConvert').value; diff --git a/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs b/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs index 5d5aac1..880e03c 100644 --- a/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs +++ b/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs @@ -581,27 +581,26 @@ public class LibraryManagerEventsHelper : IDisposable continue; } - if (media.Episodes.Count == episodes.Count) + if (this.Config.DownloadOption.EnableEpisodeCountSame && media.Episodes.Count != episodes.Count) { - var epId = media.Episodes[idx].Id; - var commentId = media.Episodes[idx].CommentId; - _logger.LogInformation("[{0}]成功匹配. {1}.{2} -> epId: {3} cid: {4}", scraper.Name, indexNumber, episode.Name, epId, commentId); - - // 更新eposide元数据 - var episodeProviderVal = episode.GetProviderId(scraper.ProviderId); - if (!string.IsNullOrEmpty(epId) && episodeProviderVal != epId) - { - episode.SetProviderId(scraper.ProviderId, epId); - queueUpdateMeta.Add(episode); - } - - // 下载弹幕 - await this.DownloadDanmu(scraper, episode, commentId).ConfigureAwait(false); + _logger.LogInformation("[{0}]刷新弹幕失败, 集数不一致。video: {1}.{2} 弹幕数:{3} 集数:{4}", scraper.Name, indexNumber, episode.Name, media.Episodes.Count, episodes.Count); + continue; } - else + + var epId = media.Episodes[idx].Id; + var commentId = media.Episodes[idx].CommentId; + _logger.LogInformation("[{0}]成功匹配. {1}.{2} -> epId: {3} cid: {4}", scraper.Name, indexNumber, episode.Name, epId, commentId); + + // 更新eposide元数据 + var episodeProviderVal = episode.GetProviderId(scraper.ProviderId); + if (!string.IsNullOrEmpty(epId) && episodeProviderVal != epId) { - _logger.LogInformation("[{0}]刷新弹幕失败, 集数不一致。video: {1}.{2} 弹幕数:{3} 集数:{4}", scraper.Name, indexNumber, episode.Name, media.Episodes.Count, episodes.Count); + episode.SetProviderId(scraper.ProviderId, epId); + queueUpdateMeta.Add(episode); } + + // 下载弹幕 + await this.DownloadDanmu(scraper, episode, commentId).ConfigureAwait(false); } break;