diff --git a/Emby.MeiamSub.Thunder/Plugin.cs b/Emby.MeiamSub.Thunder/Plugin.cs
index bb1956f..199461b 100644
--- a/Emby.MeiamSub.Thunder/Plugin.cs
+++ b/Emby.MeiamSub.Thunder/Plugin.cs
@@ -5,16 +5,36 @@ using System.IO;
namespace Emby.MeiamSub.Thunder
{
+
+ ///
+ /// 插件入口
+ ///
public class Plugin : BasePlugin, IHasThumbImage
{
+ ///
+ /// 插件ID
+ ///
public override Guid Id => new Guid("E4CE9DA9-EF00-417C-96F2-861C512D45EB");
+ ///
+ /// 插件名称
+ ///
public override string Name => "ThunderSubtitle";
+ ///
+ /// 插件描述
+ ///
public override string Description => "Download subtitles from Thunder XMP";
+ ///
+ /// 缩略图格式化类型
+ ///
public ImageFormat ThumbImageFormat => ImageFormat.Gif;
+ ///
+ /// 缩略图资源文件
+ ///
+ ///
public Stream GetThumbImage()
{
var type = GetType();
diff --git a/Emby.MeiamSub.Thunder/ThunderProvider.cs b/Emby.MeiamSub.Thunder/ThunderProvider.cs
index 9478c6a..f2f9222 100644
--- a/Emby.MeiamSub.Thunder/ThunderProvider.cs
+++ b/Emby.MeiamSub.Thunder/ThunderProvider.cs
@@ -18,8 +18,12 @@ using System.Web;
namespace Emby.MeiamSub.Thunder
{
+ ///
+ /// 迅雷字幕组件
+ ///
public class ThunderProvider : ISubtitleProvider, IHasOrder
{
+ #region 变量声明
public const string ASS = "ass";
public const string SSA = "ssa";
public const string SRT = "srt";
@@ -28,18 +32,32 @@ namespace Emby.MeiamSub.Thunder
private readonly IJsonSerializer _jsonSerializer;
private readonly IHttpClient _httpClient;
- public int Order => 1;
+ public int Order => 0;
public string Name => "ThunderSubtitle";
+ ///
+ /// 支持电影、剧集
+ ///
public IEnumerable SupportedMediaTypes => new List() { VideoContentType.Movie, VideoContentType.Episode };
+ #endregion
+ #region 构造函数
public ThunderProvider(ILogger logger, IJsonSerializer jsonSerializer,IHttpClient httpClient)
{
_logger = logger;
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
}
+ #endregion
+ #region 查询字幕
+
+ ///
+ /// 查询请求
+ ///
+ ///
+ ///
+ ///
public async Task> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
_logger.Debug($"ThunderSubtitle Search | Request -> { _jsonSerializer.SerializeToString(request) }");
@@ -49,7 +67,11 @@ namespace Emby.MeiamSub.Thunder
return subtitles;
}
-
+ ///
+ /// 查询字幕
+ ///
+ ///
+ ///
private async Task> SearchSubtitlesAsync(SubtitleSearchRequest request)
{
var cid = GetCidByFile(request.MediaPath);
@@ -94,7 +116,16 @@ namespace Emby.MeiamSub.Thunder
return Array.Empty();
}
+ #endregion
+
+ #region 下载字幕
+ ///
+ /// 下载请求
+ ///
+ ///
+ ///
+ ///
public async Task GetSubtitles(string id, CancellationToken cancellationToken)
{
await Task.Run(() =>
@@ -105,6 +136,11 @@ namespace Emby.MeiamSub.Thunder
return await DownloadSubAsync(id);
}
+ ///
+ /// 下载字幕
+ ///
+ ///
+ ///
private async Task DownloadSubAsync(string info)
{
var downloadSub = _jsonSerializer.DeserializeFromString(Base64Decode(info));
@@ -133,7 +169,36 @@ namespace Emby.MeiamSub.Thunder
return new SubtitleResponse();
}
+ #endregion
+ #region 内部方法
+
+ ///
+ /// Base64 加密
+ ///
+ /// 明文
+ ///
+ public static string Base64Encode(string plainText)
+ {
+ var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
+ return Convert.ToBase64String(plainTextBytes);
+ }
+ ///
+ /// Base64 解密
+ ///
+ ///
+ ///
+ public static string Base64Decode(string base64EncodedData)
+ {
+ var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
+ return Encoding.UTF8.GetString(base64EncodedBytes);
+ }
+
+ ///
+ /// 提取格式化字幕类型
+ ///
+ ///
+ ///
protected string ExtractFormat(string text)
{
@@ -150,19 +215,11 @@ namespace Emby.MeiamSub.Thunder
return result;
}
- public static string Base64Encode(string plainText)
- {
- var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
- return Convert.ToBase64String(plainTextBytes);
- }
-
- public static string Base64Decode(string base64EncodedData)
- {
- var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
- return Encoding.UTF8.GetString(base64EncodedBytes);
- }
-
-
+ ///
+ /// 获取文件 CID (迅雷)
+ ///
+ ///
+ ///
private string GetCidByFile(string filePath)
{
var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
@@ -192,5 +249,6 @@ namespace Emby.MeiamSub.Thunder
}
return result;
}
+ #endregion
}
}