mirror of
https://github.com/91270/MeiamSubtitles.git
synced 2026-02-03 02:24:16 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
492294941f | ||
|
|
18e00d72e2 | ||
|
|
ea887747b7 | ||
|
|
08a1936bf5 | ||
|
|
5d4b42c1f8 | ||
|
|
2216cb40b3 | ||
|
|
08c0071910 | ||
|
|
309da9469b | ||
|
|
69f15709ac | ||
|
|
4d6b80f5f7 |
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Emby.Subtitle.DevTool
|
||||
{
|
||||
@@ -8,11 +9,12 @@ namespace Emby.Subtitle.DevTool
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(getCid($"X:\\Download\\冰路营救 (2021)\\冰路营救 (2021) 1080p AC3.mkv"));
|
||||
//Console.WriteLine(ComputeFileHash($"X:\\Favorites\\Movie\\八佰 (2020)\\八佰 (2020) 1080p TrueHD.mkv"));
|
||||
Console.WriteLine(ComputeFileHash($"D:\\Documents\\Downloads\\testidx.avi"));
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private static string getCid(string filePath)
|
||||
private static string GetCid(string filePath)
|
||||
{
|
||||
var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||
var reader = new BinaryReader(stream);
|
||||
@@ -37,9 +39,57 @@ namespace Emby.Subtitle.DevTool
|
||||
var result = "";
|
||||
foreach (var i in buffer)
|
||||
{
|
||||
result += String.Format("{0:X2}", i);
|
||||
result += string.Format("{0:X2}", i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string ComputeFileHash(string filePath)
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(filePath);
|
||||
|
||||
string ret = "";
|
||||
|
||||
if (!fileInfo.Exists || fileInfo.Length < 8 * 1024)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
FileStream fs = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read);
|
||||
|
||||
long[] offset = new long[4];
|
||||
offset[3] = fileInfo.Length - 8 * 1024;
|
||||
offset[2] = fileInfo.Length / 3;
|
||||
offset[1] = fileInfo.Length / 3 * 2;
|
||||
offset[0] = 4 * 1024;
|
||||
|
||||
byte[] bBuf = new byte[1024 * 4];
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
fs.Seek(offset[i], 0);
|
||||
fs.Read(bBuf, 0, 4 * 1024);
|
||||
|
||||
MD5 md5Hash = MD5.Create();
|
||||
byte[] data = md5Hash.ComputeHash(bBuf);
|
||||
StringBuilder sBuilder = new StringBuilder();
|
||||
|
||||
for (int j = 0; j < data.Length; j++)
|
||||
{
|
||||
sBuilder.Append(data[j].ToString("x2"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(ret))
|
||||
{
|
||||
ret += ";";
|
||||
}
|
||||
|
||||
ret += sBuilder.ToString();
|
||||
}
|
||||
|
||||
fs.Close();
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
26
Emby.MeiamSub.Shooter/Emby.MeiamSub.Shooter.csproj
Normal file
26
Emby.MeiamSub.Shooter/Emby.MeiamSub.Shooter.csproj
Normal file
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>1.0.4.0</AssemblyVersion>
|
||||
<FileVersion>1.0.4.0</FileVersion>
|
||||
<Version>1.0.4</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<WarningLevel>2</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<OutputPath>..\Release</OutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Thumb.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Thumb.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MediaBrowser.Common" Version="4.4.2" />
|
||||
<PackageReference Include="MediaBrowser.Server.Core" Version="4.4.2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
15
Emby.MeiamSub.Shooter/Model/DownloadSubInfo.cs
Normal file
15
Emby.MeiamSub.Shooter/Model/DownloadSubInfo.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Emby.MeiamSub.Shooter.Model
|
||||
{
|
||||
public class DownloadSubInfo
|
||||
{
|
||||
public string Url { get; set; }
|
||||
public string Format { get; set; }
|
||||
public string Language { get; set; }
|
||||
public string TwoLetterISOLanguageName { get; set; }
|
||||
public bool? IsForced { get; set; }
|
||||
}
|
||||
}
|
||||
19
Emby.MeiamSub.Shooter/Model/SubtitleResponseRoot.cs
Normal file
19
Emby.MeiamSub.Shooter/Model/SubtitleResponseRoot.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Emby.MeiamSub.Shooter.Model
|
||||
{
|
||||
public class SubtitleResponseRoot
|
||||
{
|
||||
public string Desc { get; set; }
|
||||
public int Delay { get; set; }
|
||||
public SubFileInfo[] Files { get; set; }
|
||||
}
|
||||
|
||||
public class SubFileInfo
|
||||
{
|
||||
public string Ext { get; set; }
|
||||
public string Link { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
44
Emby.MeiamSub.Shooter/Plugin.cs
Normal file
44
Emby.MeiamSub.Shooter/Plugin.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Emby.MeiamSub.Shooter
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 插件入口
|
||||
/// </summary>
|
||||
public class Plugin : BasePlugin, IHasThumbImage
|
||||
{
|
||||
/// <summary>
|
||||
/// 插件ID
|
||||
/// </summary>
|
||||
public override Guid Id => new Guid("038D37A2-7A1E-4C01-9B6D-AA215D29AB4C");
|
||||
|
||||
/// <summary>
|
||||
/// 插件名称
|
||||
/// </summary>
|
||||
public override string Name => "MeiamSub.Shooter";
|
||||
|
||||
/// <summary>
|
||||
/// 插件描述
|
||||
/// </summary>
|
||||
public override string Description => "Download subtitles from Shooter";
|
||||
|
||||
/// <summary>
|
||||
/// 缩略图格式化类型
|
||||
/// </summary>
|
||||
public ImageFormat ThumbImageFormat => ImageFormat.Gif;
|
||||
|
||||
/// <summary>
|
||||
/// 缩略图资源文件
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Stream GetThumbImage()
|
||||
{
|
||||
var type = GetType();
|
||||
return type.Assembly.GetManifestResourceStream(type.Namespace + ".Thumb.png");
|
||||
}
|
||||
}
|
||||
}
|
||||
307
Emby.MeiamSub.Shooter/ShooterProvider.cs
Normal file
307
Emby.MeiamSub.Shooter/ShooterProvider.cs
Normal file
@@ -0,0 +1,307 @@
|
||||
using Emby.MeiamSub.Shooter.Model;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Subtitles;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace Emby.MeiamSub.Shooter
|
||||
{
|
||||
/// <summary>
|
||||
/// 迅雷字幕组件
|
||||
/// </summary>
|
||||
public class ShooterProvider : ISubtitleProvider, IHasOrder
|
||||
{
|
||||
#region 变量声明
|
||||
public const string ASS = "ass";
|
||||
public const string SSA = "ssa";
|
||||
public const string SRT = "srt";
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
private readonly IHttpClient _httpClient;
|
||||
|
||||
public int Order => 0;
|
||||
public string Name => "MeiamSub.Shooter";
|
||||
|
||||
/// <summary>
|
||||
/// 支持电影、剧集
|
||||
/// </summary>
|
||||
public IEnumerable<VideoContentType> SupportedMediaTypes => new List<VideoContentType>() { VideoContentType.Movie, VideoContentType.Episode };
|
||||
#endregion
|
||||
|
||||
#region 构造函数
|
||||
public ShooterProvider(ILogger logger, IJsonSerializer jsonSerializer,IHttpClient httpClient)
|
||||
{
|
||||
_logger = logger;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询字幕
|
||||
|
||||
/// <summary>
|
||||
/// 查询请求
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.Debug($"MeiamSub.Shooter Search | Request -> { _jsonSerializer.SerializeToString(request) }");
|
||||
|
||||
var subtitles = await SearchSubtitlesAsync(request);
|
||||
|
||||
return subtitles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询字幕
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(SubtitleSearchRequest request)
|
||||
{
|
||||
if (request.Language != "chi" && request.Language != "eng")
|
||||
{
|
||||
return Array.Empty<RemoteSubtitleInfo>();
|
||||
}
|
||||
|
||||
FileInfo fileInfo = new FileInfo(request.MediaPath);
|
||||
|
||||
var hash = ComputeFileHash(fileInfo);
|
||||
|
||||
HttpRequestOptions options = new HttpRequestOptions
|
||||
{
|
||||
Url = $"http://www.shooter.cn/api/subapi.php",
|
||||
UserAgent = "Emby.MeiamSub.Shooter",
|
||||
TimeoutMs = 30000,
|
||||
AcceptHeader = "*/*",
|
||||
};
|
||||
|
||||
options.SetPostData(new Dictionary<string, string>
|
||||
{
|
||||
{ "filehash", HttpUtility.UrlEncode(hash)},
|
||||
{ "pathinfo", HttpUtility.UrlEncode(request.MediaPath)},
|
||||
{ "format", "json"},
|
||||
{ "lang",request.Language == "chi" ? "chn" : "eng"}
|
||||
});
|
||||
|
||||
_logger.Debug($"MeiamSub.Shooter Search | Request -> { _jsonSerializer.SerializeToString(options) }");
|
||||
|
||||
var response = await _httpClient.Post(options);
|
||||
|
||||
_logger.Debug($"MeiamSub.Shooter Search | Response -> { _jsonSerializer.SerializeToString(response) }");
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK && response.ContentType.Contains("application/json"))
|
||||
{
|
||||
var subtitleResponse = _jsonSerializer.DeserializeFromStream<List<SubtitleResponseRoot>>(response.Content);
|
||||
|
||||
if (subtitleResponse != null)
|
||||
{
|
||||
_logger.Debug($"MeiamSub.Shooter Search | Response -> { _jsonSerializer.SerializeToString(subtitleResponse) }");
|
||||
|
||||
var remoteSubtitleInfos = new List<RemoteSubtitleInfo>();
|
||||
|
||||
foreach(var subFileInfo in subtitleResponse)
|
||||
{
|
||||
foreach(var subFile in subFileInfo.Files)
|
||||
{
|
||||
remoteSubtitleInfos.Add(new RemoteSubtitleInfo()
|
||||
{
|
||||
Id = Base64Encode(_jsonSerializer.SerializeToString(new DownloadSubInfo
|
||||
{
|
||||
Url = subFile.Link,
|
||||
Format = subFile.Ext,
|
||||
Language = request.Language,
|
||||
TwoLetterISOLanguageName = request.TwoLetterISOLanguageName,
|
||||
IsForced = request.IsForced
|
||||
})),
|
||||
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {request.TwoLetterISOLanguageName} | 射手",
|
||||
Author = "Meiam ",
|
||||
ProviderName = "MeiamSub.Shooter",
|
||||
Format = subFile.Ext,
|
||||
Comment = $"Format : { ExtractFormat(subFile.Ext)}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Debug($"MeiamSub.Shooter Search | Summary -> Get { remoteSubtitleInfos.Count } Subtitles");
|
||||
|
||||
return remoteSubtitleInfos;
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Debug($"MeiamSub.Shooter Search | Summary -> Get 0 Subtitles");
|
||||
|
||||
return Array.Empty<RemoteSubtitleInfo>();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 下载字幕
|
||||
/// <summary>
|
||||
/// 下载请求
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
_logger.Debug($"MeiamSub.Shooter DownloadSub | Request -> {id}");
|
||||
});
|
||||
|
||||
return await DownloadSubAsync(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载字幕
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<SubtitleResponse> DownloadSubAsync(string info)
|
||||
{
|
||||
var downloadSub = _jsonSerializer.DeserializeFromString<DownloadSubInfo>(Base64Decode(info));
|
||||
|
||||
downloadSub.Url = downloadSub.Url.Replace("https://www.shooter.cn", "http://www.shooter.cn");
|
||||
|
||||
_logger.Debug($"MeiamSub.Shooter DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
|
||||
|
||||
var response = await _httpClient.GetResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = downloadSub.Url,
|
||||
UserAgent = "Emby.MeiamSub.Shooter",
|
||||
TimeoutMs = 30000,
|
||||
AcceptHeader = "*/*",
|
||||
});
|
||||
|
||||
|
||||
_logger.Debug($"MeiamSub.Shooter DownloadSub | Response -> { response.StatusCode }");
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
|
||||
return new SubtitleResponse()
|
||||
{
|
||||
Language = downloadSub.Language,
|
||||
IsForced = false,
|
||||
Format = downloadSub.Format,
|
||||
Stream = response.Content,
|
||||
};
|
||||
}
|
||||
|
||||
return new SubtitleResponse();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 内部方法
|
||||
|
||||
/// <summary>
|
||||
/// Base64 加密
|
||||
/// </summary>
|
||||
/// <param name="plainText">明文</param>
|
||||
/// <returns></returns>
|
||||
public static string Base64Encode(string plainText)
|
||||
{
|
||||
var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
|
||||
return Convert.ToBase64String(plainTextBytes);
|
||||
}
|
||||
/// <summary>
|
||||
/// Base64 解密
|
||||
/// </summary>
|
||||
/// <param name="base64EncodedData"></param>
|
||||
/// <returns></returns>
|
||||
public static string Base64Decode(string base64EncodedData)
|
||||
{
|
||||
var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
|
||||
return Encoding.UTF8.GetString(base64EncodedBytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提取格式化字幕类型
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
protected string ExtractFormat(string text)
|
||||
{
|
||||
|
||||
string result = null;
|
||||
|
||||
if (text != null)
|
||||
{
|
||||
text = text.ToLower();
|
||||
if (text.Contains(ASS)) result = ASS;
|
||||
else if (text.Contains(SSA)) result = SSA;
|
||||
else if (text.Contains(SRT)) result = SRT;
|
||||
else result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件 Hash (射手)
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
public static string ComputeFileHash(FileInfo fileInfo)
|
||||
{
|
||||
string ret = "";
|
||||
|
||||
if (!fileInfo.Exists || fileInfo.Length < 8 * 1024)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
FileStream fs = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read);
|
||||
|
||||
long[] offset = new long[4];
|
||||
offset[3] = fileInfo.Length - 8 * 1024;
|
||||
offset[2] = fileInfo.Length / 3;
|
||||
offset[1] = fileInfo.Length / 3 * 2;
|
||||
offset[0] = 4 * 1024;
|
||||
|
||||
byte[] bBuf = new byte[1024 * 4];
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
fs.Seek(offset[i], 0);
|
||||
fs.Read(bBuf, 0, 4 * 1024);
|
||||
|
||||
MD5 md5Hash = MD5.Create();
|
||||
byte[] data = md5Hash.ComputeHash(bBuf);
|
||||
StringBuilder sBuilder = new StringBuilder();
|
||||
|
||||
for (int j = 0; j < data.Length; j++)
|
||||
{
|
||||
sBuilder.Append(data[j].ToString("x2"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(ret))
|
||||
{
|
||||
ret += ";";
|
||||
}
|
||||
|
||||
ret += sBuilder.ToString();
|
||||
}
|
||||
|
||||
fs.Close();
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
BIN
Emby.MeiamSub.Shooter/Thumb.png
Normal file
BIN
Emby.MeiamSub.Shooter/Thumb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -1,8 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>1.0.4.0</AssemblyVersion>
|
||||
<FileVersion>1.0.4.0</FileVersion>
|
||||
<Version>1.0.4</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<OutputPath>..\Release</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Thumb.png" />
|
||||
@@ -13,8 +23,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MediaBrowser.Common" Version="4.6.0.50" />
|
||||
<PackageReference Include="MediaBrowser.Server.Core" Version="4.6.0.50" />
|
||||
<PackageReference Include="MediaBrowser.Common" Version="4.4.2" />
|
||||
<PackageReference Include="MediaBrowser.Server.Core" Version="4.4.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Emby.MeiamSub.Thunder
|
||||
/// <summary>
|
||||
/// 插件名称
|
||||
/// </summary>
|
||||
public override string Name => "ThunderSubtitle";
|
||||
public override string Name => "MeiamSub.Thunder";
|
||||
|
||||
/// <summary>
|
||||
/// 插件描述
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
@@ -33,7 +33,7 @@ namespace Emby.MeiamSub.Thunder
|
||||
private readonly IHttpClient _httpClient;
|
||||
|
||||
public int Order => 0;
|
||||
public string Name => "ThunderSubtitle";
|
||||
public string Name => "MeiamSub.Thunder";
|
||||
|
||||
/// <summary>
|
||||
/// 支持电影、剧集
|
||||
@@ -60,7 +60,7 @@ namespace Emby.MeiamSub.Thunder
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.Debug($"ThunderSubtitle Search | Request -> { _jsonSerializer.SerializeToString(request) }");
|
||||
_logger.Debug($"MeiamSub.Thunder Search | Request -> { _jsonSerializer.SerializeToString(request) }");
|
||||
|
||||
var subtitles = await SearchSubtitlesAsync(request);
|
||||
|
||||
@@ -74,14 +74,22 @@ namespace Emby.MeiamSub.Thunder
|
||||
/// <returns></returns>
|
||||
private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(SubtitleSearchRequest request)
|
||||
{
|
||||
if (request.Language != "chi")
|
||||
{
|
||||
return Array.Empty<RemoteSubtitleInfo>();
|
||||
}
|
||||
|
||||
var cid = GetCidByFile(request.MediaPath);
|
||||
|
||||
var response = await _httpClient.GetResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = $"http://sub.xmp.sandai.net:8000/subxl/{cid}.json"
|
||||
Url = $"http://sub.xmp.sandai.net:8000/subxl/{cid}.json",
|
||||
UserAgent = "Emby.MeiamSub.Thunder",
|
||||
TimeoutMs = 30000,
|
||||
AcceptHeader = "*/*",
|
||||
});
|
||||
|
||||
_logger.Debug($"ThunderSubtitle Search | Response -> { _jsonSerializer.SerializeToString(response) }");
|
||||
_logger.Debug($"MeiamSub.Thunder Search | Response -> { _jsonSerializer.SerializeToString(response) }");
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
@@ -89,10 +97,14 @@ namespace Emby.MeiamSub.Thunder
|
||||
|
||||
if (subtitleResponse != null)
|
||||
{
|
||||
_logger.Debug($"MeiamSub.Thunder Search | Response -> { _jsonSerializer.SerializeToString(subtitleResponse) }");
|
||||
|
||||
var subtitles = subtitleResponse.sublist.Where(m => !string.IsNullOrEmpty(m.sname));
|
||||
|
||||
if (subtitles.Count() > 0)
|
||||
{
|
||||
_logger.Debug($"MeiamSub.Thunder Search | Summary -> Get { subtitles.Count() } Subtitles");
|
||||
|
||||
return subtitles.Select(m => new RemoteSubtitleInfo()
|
||||
{
|
||||
Id = Base64Encode(_jsonSerializer.SerializeToString(new DownloadSubInfo
|
||||
@@ -103,22 +115,23 @@ namespace Emby.MeiamSub.Thunder
|
||||
TwoLetterISOLanguageName = request.TwoLetterISOLanguageName,
|
||||
IsForced = request.IsForced
|
||||
})),
|
||||
Name = Path.GetFileName(HttpUtility.UrlDecode(m.sname)),
|
||||
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {request.TwoLetterISOLanguageName} | 迅雷",
|
||||
Author = "Meiam ",
|
||||
CommunityRating = Convert.ToSingle(m.rate),
|
||||
ProviderName = "ThunderSubtitle",
|
||||
ProviderName = "MeiamSub.Thunder",
|
||||
Format = ExtractFormat(m.sname),
|
||||
Comment = $"Rate : { m.rate }"
|
||||
Comment = $"Format : { ExtractFormat(m.sname)} - Rate : { m.rate }"
|
||||
}).OrderByDescending(m => m.CommunityRating);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Debug($"MeiamSub.Thunder Search | Summary -> Get 0 Subtitles");
|
||||
|
||||
return Array.Empty<RemoteSubtitleInfo>();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 下载字幕
|
||||
/// <summary>
|
||||
/// 下载请求
|
||||
@@ -130,7 +143,7 @@ namespace Emby.MeiamSub.Thunder
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
_logger.Debug($"ThunderSubtitle DownloadSub | Request -> {id}");
|
||||
_logger.Debug($"MeiamSub.Thunder DownloadSub | Request -> {id}");
|
||||
});
|
||||
|
||||
return await DownloadSubAsync(id);
|
||||
@@ -145,14 +158,17 @@ namespace Emby.MeiamSub.Thunder
|
||||
{
|
||||
var downloadSub = _jsonSerializer.DeserializeFromString<DownloadSubInfo>(Base64Decode(info));
|
||||
|
||||
_logger.Debug($"ThunderSubtitle DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
|
||||
_logger.Debug($"MeiamSub.Thunder DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
|
||||
|
||||
var response = await _httpClient.GetResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = downloadSub.Url
|
||||
Url = downloadSub.Url,
|
||||
UserAgent = "Emby.MeiamSub.Thunder",
|
||||
TimeoutMs = 30000,
|
||||
AcceptHeader = "*/*",
|
||||
});
|
||||
|
||||
_logger.Debug($"ThunderSubtitle DownloadSub | Response -> { response.StatusCode }");
|
||||
_logger.Debug($"MeiamSub.Thunder DownloadSub | Response -> { response.StatusCode }");
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.MeiamSub.Thunder", "Em
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.MeiamSub.DevTool", "Emby.MeiamSub.DevTool\Emby.MeiamSub.DevTool.csproj", "{6B0C23EA-EC24-4FB0-948E-094E84AEBF21}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.MeiamSub.Shooter", "Emby.MeiamSub.Shooter\Emby.MeiamSub.Shooter.csproj", "{0F502AEB-0FF4-44FA-8391-13AD61FC5490}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -21,6 +23,10 @@ Global
|
||||
{6B0C23EA-EC24-4FB0-948E-094E84AEBF21}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B0C23EA-EC24-4FB0-948E-094E84AEBF21}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6B0C23EA-EC24-4FB0-948E-094E84AEBF21}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0F502AEB-0FF4-44FA-8391-13AD61FC5490}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0F502AEB-0FF4-44FA-8391-13AD61FC5490}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0F502AEB-0FF4-44FA-8391-13AD61FC5490}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0F502AEB-0FF4-44FA-8391-13AD61FC5490}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
14
README.md
14
README.md
@@ -22,8 +22,8 @@ Emby 中文字幕插件 ,支持 迅雷影音、射手网、 精准匹配,自
|
||||
## 功能介绍
|
||||
|
||||
|
||||
- [x] 支持 迅雷看看 Hash 匹配自动下载字幕
|
||||
- [ ] 支持 射手影音 Hash 匹配自动下载字幕
|
||||
- [x] 支持 迅雷看看 字幕下载 Hash匹配
|
||||
- [x] 支持 射手影音 字幕下载 Hash匹配
|
||||
|
||||
|
||||
## 项目说明
|
||||
@@ -38,6 +38,8 @@ Emby 中文字幕插件 ,支持 迅雷影音、射手网、 精准匹配,自
|
||||
|
||||
## 使用插件
|
||||
|
||||
首先下载已编译好的插件 [LINK](https://github.com/91270/Emby.MeiamSub/releases)
|
||||
|
||||
### WINDOWS
|
||||
```bash
|
||||
复制插件文件到 Emby-Server\Programdata\Plugins\
|
||||
@@ -54,6 +56,14 @@ Emby 中文字幕插件 ,支持 迅雷影音、射手网、 精准匹配,自
|
||||
|
||||
|
||||
|
||||
### 群晖
|
||||
```bash
|
||||
复制插件文件到 /var/packages/EmbyServer/target/var/plugins
|
||||
复制插件文件到 /var/packages/EmbyServer/target/system/plugins
|
||||
重启服务
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 贡献
|
||||
|
||||
|
||||
Reference in New Issue
Block a user