mirror of
https://github.com/cxfksword/jellyfin-plugin-danmu.git
synced 2026-05-03 08:53:17 +08:00
feat: add episode count match config. #42
This commit is contained in:
@@ -42,6 +42,12 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
/// </summary>
|
||||
public string AssSpeed { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测弹幕数和视频剧集数需要一致才自动下载弹幕.
|
||||
/// </summary>
|
||||
public DanmuDownloadOption DownloadOption { get; set; } = new DanmuDownloadOption();
|
||||
|
||||
/// <summary>
|
||||
/// 透明度.
|
||||
/// </summary>
|
||||
@@ -124,6 +130,15 @@ public class ScraperConfigItem
|
||||
|
||||
}
|
||||
|
||||
public class DanmuDownloadOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 检测弹幕数和视频剧集数需要一致才自动下载弹幕.
|
||||
/// </summary>
|
||||
public bool EnableEpisodeCountSame { get; set; } = true;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 弹弹play配置
|
||||
/// </summary>
|
||||
|
||||
@@ -31,6 +31,21 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="verticalSection verticalSection-extrabottompadding">
|
||||
<legend>
|
||||
<h3>弹幕匹配下载配置</h3>
|
||||
</legend>
|
||||
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="EnableEpisodeCountSame" name="EnableEpisodeCountSame" type="checkbox"
|
||||
is="emby-checkbox" />
|
||||
<span>弹幕总数需和电视剧总集数一致</span>
|
||||
</label>
|
||||
<div class="fieldDescription">勾选后,假如匹配了错误的电视剧,可以避免自动下载错误的弹幕。</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="verticalSection verticalSection-extrabottompadding">
|
||||
<legend>
|
||||
<h3>弹弹play配置</h3>
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user