mirror of
https://github.com/91270/MeiamSubtitles.git
synced 2026-07-27 08:50:25 +08:00
新增: 迅雷字幕元数据搜索选项移植到 Jellyfin
任务摘要:将 PR #133 的元数据搜索功能从 Emby.MeiamSub.Thunder 移植到 Jellyfin.MeiamSub.Thunder。新增 EnableUseMetadata 配置项和 configPage.html 配置页面,修改 Plugin.cs 注册 IHasWebPages,ThunderProvider.cs 添加元数据搜索逻辑。同步更新开发协议、任务清单和归档索引。
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -365,7 +365,6 @@ FodyWeavers.xsd
|
||||
TestServer/
|
||||
|
||||
.agent/
|
||||
.docs/
|
||||
|
||||
GEMINI.md
|
||||
|
||||
|
||||
@@ -2,7 +2,24 @@ using MediaBrowser.Model.Plugins;
|
||||
|
||||
namespace Jellyfin.MeiamSub.Thunder.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// 插件配置类
|
||||
/// <para>修改人: Meiam (移植自 PR #133 by Mayfly777w)</para>
|
||||
/// <para>修改时间: 2026-02-11</para>
|
||||
/// </summary>
|
||||
public class PluginConfiguration : BasePluginConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否使用元数据中的剧集名称和季集编号搜索字幕
|
||||
/// <para>启用后,剧集使用 "{SeriesName} S{Season}E{Episode}" 格式搜索</para>
|
||||
/// <para>电影使用元数据中的影片名称搜索</para>
|
||||
/// <para>默认关闭,使用文件名搜索</para>
|
||||
/// </summary>
|
||||
public bool EnableUseMetadata { get; set; }
|
||||
|
||||
public PluginConfiguration()
|
||||
{
|
||||
EnableUseMetadata = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
65
Jellyfin.MeiamSub.Thunder/Configuration/configPage.html
Normal file
65
Jellyfin.MeiamSub.Thunder/Configuration/configPage.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<title>MeiamSub.Thunder</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="MeiamSubThunderConfigPage" data-role="page" class="page type-interior pluginConfigurationPage"
|
||||
data-require="emby-checkbox">
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
<form id="MeiamSubThunderConfigForm">
|
||||
<div class="verticalSection">
|
||||
<h2 class="sectionTitle">迅雷字幕搜索设置</h2>
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label class="emby-checkbox-label">
|
||||
<input id="EnableUseMetadata" name="EnableUseMetadata" type="checkbox"
|
||||
is="emby-checkbox" />
|
||||
<span>使用元数据搜索字幕</span>
|
||||
</label>
|
||||
<div class="fieldDescription">
|
||||
勾选此项后,使用元数据中的剧集名称和季集编号搜索字幕,而非文件名。
|
||||
<br />
|
||||
剧集将使用 "剧集名 S01E01" 格式;电影将使用影片名称。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
|
||||
<span>保存</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var MeiamSubThunderConfig = {
|
||||
pluginUniqueId: 'E4CE9DA9-EF00-417C-96F2-861C512D45EB'
|
||||
};
|
||||
|
||||
document.querySelector('#MeiamSubThunderConfigPage')
|
||||
.addEventListener('pageshow', function () {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getPluginConfiguration(MeiamSubThunderConfig.pluginUniqueId).then(function (config) {
|
||||
document.querySelector('#EnableUseMetadata').checked = config.EnableUseMetadata;
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelector('#MeiamSubThunderConfigForm')
|
||||
.addEventListener('submit', function (e) {
|
||||
Dashboard.showLoadingMsg();
|
||||
ApiClient.getPluginConfiguration(MeiamSubThunderConfig.pluginUniqueId).then(function (config) {
|
||||
config.EnableUseMetadata = document.querySelector('#EnableUseMetadata').checked;
|
||||
ApiClient.updatePluginConfiguration(MeiamSubThunderConfig.pluginUniqueId, config).then(function (result) {
|
||||
Dashboard.processPluginConfigurationUpdateResult(result);
|
||||
});
|
||||
});
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -21,6 +21,10 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Configuration\configPage.html" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="Copy $(TargetDir)$(TargetFileName) $(SolutionDir)$(ConfigurationName)\$(TargetFileName) /y
" />
|
||||
</Target>
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
using Jellyfin.MeiamSub.Thunder.Configuration;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Jellyfin.MeiamSub.Thunder
|
||||
{
|
||||
/// <summary>
|
||||
/// 插件入口
|
||||
/// <para>修改人: Meiam</para>
|
||||
/// <para>修改时间: 2025-12-22</para>
|
||||
/// <para>修改人: Meiam (移植自 PR #133 by Mayfly777w)</para>
|
||||
/// <para>修改时间: 2026-02-11</para>
|
||||
/// </summary>
|
||||
public class Plugin : BasePlugin<PluginConfiguration>
|
||||
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
{
|
||||
/// <summary>
|
||||
/// 插件ID
|
||||
@@ -36,5 +38,21 @@ namespace Jellyfin.MeiamSub.Thunder
|
||||
}
|
||||
|
||||
public static Plugin Instance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取插件配置页面列表
|
||||
/// </summary>
|
||||
/// <returns>配置页面信息</returns>
|
||||
public IEnumerable<PluginPageInfo> GetPages()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new PluginPageInfo
|
||||
{
|
||||
Name = Name,
|
||||
EmbeddedResourcePath = GetType().Namespace + ".Configuration.configPage.html"
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ namespace Jellyfin.MeiamSub.Thunder
|
||||
/// <returns></returns>
|
||||
private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(SubtitleSearchRequest request)
|
||||
{
|
||||
// 修改人: Meiam
|
||||
// 修改时间: 2025-12-22
|
||||
// 备注: 增加极致探测日志
|
||||
// 修改人: Meiam (移植自 PR #133 by Mayfly777w)
|
||||
// 修改时间: 2026-02-11
|
||||
// 备注: 增加元数据搜索选项,可以以元数据中的系列名和季集信息来作为匹配对象
|
||||
|
||||
_logger.LogInformation("DEBUG: Entering SearchSubtitlesAsync (Thunder)");
|
||||
|
||||
@@ -97,14 +97,34 @@ namespace Jellyfin.MeiamSub.Thunder
|
||||
}
|
||||
|
||||
var language = NormalizeLanguage(request.Language);
|
||||
var fileName = string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(request.MediaPath))
|
||||
// 根据配置决定搜索名称:使用元数据 或 文件名
|
||||
string movieName;
|
||||
if (Plugin.Instance?.Configuration?.EnableUseMetadata == true)
|
||||
{
|
||||
fileName = Path.GetFileName(request.MediaPath);
|
||||
if (request.ContentType == VideoContentType.Episode)
|
||||
{
|
||||
movieName = $"{request.SeriesName} S{request.ParentIndexNumber}E{request.IndexNumber}";
|
||||
}
|
||||
else if (request.ContentType == VideoContentType.Movie)
|
||||
{
|
||||
movieName = request.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
movieName = !string.IsNullOrEmpty(request.MediaPath)
|
||||
? Path.GetFileName(request.MediaPath)
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
movieName = !string.IsNullOrEmpty(request.MediaPath)
|
||||
? Path.GetFileName(request.MediaPath)
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
_logger.LogInformation(Name + " Search | Target -> " + fileName + " | Language -> " + language);
|
||||
_logger.LogInformation(Name + " Search | Target -> " + movieName + " | Language -> " + language);
|
||||
|
||||
if (language != "chi")
|
||||
{
|
||||
@@ -127,7 +147,7 @@ namespace Jellyfin.MeiamSub.Thunder
|
||||
using var options = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri($"https://api-shoulei-ssl.xunlei.com/oracle/subtitle?name={Path.GetFileName(request.MediaPath)}")
|
||||
RequestUri = new Uri($"https://api-shoulei-ssl.xunlei.com/oracle/subtitle?name={movieName}")
|
||||
};
|
||||
|
||||
using var httpClient = _httpClientFactory.CreateClient(Name);
|
||||
|
||||
@@ -91,7 +91,8 @@ Jellyfin 用户可直接添加官方存储库,实现一键安装与自动更
|
||||
|
||||
欢迎通过提交 Issue 或 Pull Request 来完善本项目。
|
||||
|
||||
- **开发守则**: 遵循异步命名规范,所有修改请标注 `修改人: Meiam`。
|
||||
- **开发守则**: 遵循异步命名规范,详情请参阅 [.docs/开发协议.md](.docs/开发协议.md)。
|
||||
- **任务进展**: 查看 [.docs/任务清单.md](.docs/任务清单.md) 了解当前计划。
|
||||
- **致谢**: 感谢 [Emby.Subtitle.Subscene](https://github.com/nRafinia/Emby.Subtitle.Subscene) 提供的灵感与参考。
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user