17 Commits

Author SHA1 Message Date
Meiam
8bebe5ba5b 修复射手无法查询无字幕问题 2023-02-09 22:38:29 +08:00
91270
0c5a3656c8 Update README.md 2023-02-09 16:29:38 +08:00
Meiam
339b05b763 Update 2023-02-07 20:50:19 +08:00
91270
54b13d647d Update README.md 2023-02-02 21:01:48 +08:00
91270
2e06131f8d Update README.md 2023-02-02 21:00:57 +08:00
91270
8f69a7ffca Update README.md 2023-02-02 21:00:40 +08:00
Meiam
bf178f7cef 适配 Emby v4.7.1.0 2022-06-02 13:07:33 +08:00
91270
39aafddd23 Merge pull request #46 from LuckyPuppy514/master
适配Emby v4.7.1.0
2022-06-01 17:34:49 +08:00
LuckyPuppy514
f8854e2a85 适配EMBY v4.7.1.0 2022-06-01 17:00:45 +08:00
LuckyPuppy514
d63de08b8e 适配EMBY v4.7.1.0 2022-06-01 16:57:38 +08:00
Meiam
ac28e193e3 版本号修改 2022-05-28 10:10:14 +08:00
Meiam
f796c05f99 适配新版本 2022-05-28 10:02:49 +08:00
91270
ddeb8e0c14 Merge pull request #38 from hisune/master
readme增加威联通的位置说明
2022-04-21 21:56:16 +08:00
Hisune
7a0fb35fc5 Update README.md 2022-04-18 10:11:45 +08:00
Meiam
74e576de93 程序逻辑优化 2022-04-10 14:21:09 +08:00
Meiam
bc72ca4ab0 降低依赖侵入,适配低版本 2022-04-09 16:07:26 +08:00
Meiam
2d4940156d 修改说明文件 2022-03-31 21:32:22 +08:00
14 changed files with 264 additions and 217 deletions

View File

@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyVersion>1.0.5.0</AssemblyVersion>
<FileVersion>1.0.4.0</FileVersion>
<Version>1.0.5</Version>
<AssemblyVersion>1.0.9.0</AssemblyVersion>
<FileVersion>1.0.9.0</FileVersion>
<Version>1.0.9</Version>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

View File

@@ -9,7 +9,6 @@ namespace Emby.MeiamSub.Shooter.Model
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; }
}
}

View File

@@ -32,7 +32,7 @@ namespace Emby.MeiamSub.Shooter
private readonly IJsonSerializer _jsonSerializer;
private readonly IHttpClient _httpClient;
public int Order => 0;
public int Order => 1;
public string Name => "MeiamSub.Shooter";
/// <summary>
@@ -47,6 +47,7 @@ namespace Emby.MeiamSub.Shooter
_logger = logger;
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
_logger.Info($"{Name} Init");
}
#endregion
@@ -60,7 +61,7 @@ namespace Emby.MeiamSub.Shooter
/// <returns></returns>
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
_logger.Debug($"MeiamSub.Shooter Search | Request -> { _jsonSerializer.SerializeToString(request) }");
_logger.Info($"{Name} Search | SubtitleSearchRequest -> { _jsonSerializer.SerializeToString(request) }");
var subtitles = await SearchSubtitlesAsync(request);
@@ -74,6 +75,12 @@ namespace Emby.MeiamSub.Shooter
/// <returns></returns>
private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(SubtitleSearchRequest request)
{
if(request.Language == "zh-CN" || request.Language == "zh-TW" || request.Language == "zh-HK"){
request.Language = "chi";
}
if(request.Language == "en"){
request.Language = "eng";
}
if (request.Language != "chi" && request.Language != "eng")
{
return Array.Empty<RemoteSubtitleInfo>();
@@ -83,10 +90,12 @@ namespace Emby.MeiamSub.Shooter
var hash = ComputeFileHash(fileInfo);
_logger.Info($"{Name} Search | FileHash -> { hash }");
HttpRequestOptions options = new HttpRequestOptions
{
Url = $"http://www.shooter.cn/api/subapi.php",
UserAgent = "Emby.MeiamSub.Shooter",
Url = $"https://www.shooter.cn/api/subapi.php",
UserAgent = $"{Name}",
TimeoutMs = 30000,
AcceptHeader = "*/*",
};
@@ -99,11 +108,11 @@ namespace Emby.MeiamSub.Shooter
{ "lang",request.Language == "chi" ? "chn" : "eng"}
});
_logger.Debug($"MeiamSub.Shooter Search | Request -> { _jsonSerializer.SerializeToString(options) }");
_logger.Info($"{Name} Search | Request -> { _jsonSerializer.SerializeToString(options) }");
var response = await _httpClient.Post(options);
_logger.Debug($"MeiamSub.Shooter Search | Response -> { _jsonSerializer.SerializeToString(response) }");
_logger.Info($"{Name} Search | Response -> { _jsonSerializer.SerializeToString(response) }");
if (response.StatusCode == HttpStatusCode.OK && response.ContentType.Contains("application/json"))
{
@@ -111,7 +120,7 @@ namespace Emby.MeiamSub.Shooter
if (subtitleResponse != null)
{
_logger.Debug($"MeiamSub.Shooter Search | Response -> { _jsonSerializer.SerializeToString(subtitleResponse) }");
_logger.Info($"{Name} Search | Response -> { _jsonSerializer.SerializeToString(subtitleResponse) }");
var remoteSubtitleInfos = new List<RemoteSubtitleInfo>();
@@ -126,25 +135,25 @@ namespace Emby.MeiamSub.Shooter
Url = subFile.Link,
Format = subFile.Ext,
Language = request.Language,
TwoLetterISOLanguageName = request.TwoLetterISOLanguageName,
IsForced = request.IsForced
})),
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {request.TwoLetterISOLanguageName} | 射手",
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {request.Language} | 射手",
Author = "Meiam ",
ProviderName = "MeiamSub.Shooter",
ProviderName = $"{Name}",
Format = subFile.Ext,
Comment = $"Format : { ExtractFormat(subFile.Ext)}"
Comment = $"Format : { ExtractFormat(subFile.Ext)}",
IsHashMatch = true
});
}
}
_logger.Debug($"MeiamSub.Shooter Search | Summary -> Get { remoteSubtitleInfos.Count } Subtitles");
_logger.Info($"{Name} Search | Summary -> Get { remoteSubtitleInfos.Count } Subtitles");
return remoteSubtitleInfos;
}
}
_logger.Debug($"MeiamSub.Shooter Search | Summary -> Get 0 Subtitles");
_logger.Info($"{Name} Search | Summary -> Get 0 Subtitles");
return Array.Empty<RemoteSubtitleInfo>();
}
@@ -159,10 +168,7 @@ namespace Emby.MeiamSub.Shooter
/// <returns></returns>
public async Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken)
{
await Task.Run(() =>
{
_logger.Debug($"MeiamSub.Shooter DownloadSub | Request -> {id}");
});
_logger.Info($"{Name} DownloadSub | Request -> {id}");
return await DownloadSubAsync(id);
}
@@ -176,20 +182,23 @@ namespace Emby.MeiamSub.Shooter
{
var downloadSub = _jsonSerializer.DeserializeFromString<DownloadSubInfo>(Base64Decode(info));
downloadSub.Url = downloadSub.Url.Replace("https://www.shooter.cn", "http://www.shooter.cn");
if (downloadSub == null)
{
return new SubtitleResponse();
}
_logger.Debug($"MeiamSub.Shooter DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
_logger.Info($"{Name} DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
var response = await _httpClient.GetResponse(new HttpRequestOptions
{
Url = downloadSub.Url,
UserAgent = "Emby.MeiamSub.Shooter",
UserAgent = $"{Name}",
TimeoutMs = 30000,
AcceptHeader = "*/*",
});
_logger.Debug($"MeiamSub.Shooter DownloadSub | Response -> { response.StatusCode }");
_logger.Info($"{Name} DownloadSub | Response -> { response.StatusCode }");
if (response.StatusCode == HttpStatusCode.OK)
{

View File

@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyVersion>1.0.5.0</AssemblyVersion>
<FileVersion>1.0.5.0</FileVersion>
<Version>1.0.5</Version>
<AssemblyVersion>1.0.9.0</AssemblyVersion>
<FileVersion>1.0.9.0</FileVersion>
<Version>1.0.9</Version>
</PropertyGroup>
<PropertyGroup>

View File

@@ -9,7 +9,6 @@ namespace Emby.MeiamSub.Thunder.Model
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; }
}
}

View File

@@ -28,10 +28,6 @@ namespace Emby.MeiamSub.Thunder.Model
///
/// </summary>
public int svote { get; set; }
/// <summary>
///
/// </summary>
public int roffset { get; set; }
}
public class SubtitleResponseRoot

View File

@@ -32,7 +32,7 @@ namespace Emby.MeiamSub.Thunder
private readonly IJsonSerializer _jsonSerializer;
private readonly IHttpClient _httpClient;
public int Order => 0;
public int Order => 1;
public string Name => "MeiamSub.Thunder";
/// <summary>
@@ -47,6 +47,7 @@ namespace Emby.MeiamSub.Thunder
_logger = logger;
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
_logger.Info($"{Name} Init");
}
#endregion
@@ -60,7 +61,7 @@ namespace Emby.MeiamSub.Thunder
/// <returns></returns>
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
_logger.Debug($"MeiamSub.Thunder Search | Request -> { _jsonSerializer.SerializeToString(request) }");
_logger.Info($"{Name} Search | SubtitleSearchRequest -> { _jsonSerializer.SerializeToString(request) }");
var subtitles = await SearchSubtitlesAsync(request);
@@ -74,6 +75,9 @@ namespace Emby.MeiamSub.Thunder
/// <returns></returns>
private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(SubtitleSearchRequest request)
{
if(request.Language == "zh-CN" || request.Language == "zh-TW" || request.Language == "zh-HK"){
request.Language = "chi";
}
if (request.Language != "chi")
{
return Array.Empty<RemoteSubtitleInfo>();
@@ -81,15 +85,18 @@ namespace Emby.MeiamSub.Thunder
var cid = GetCidByFile(request.MediaPath);
_logger.Info($"{Name} Search | FileHash -> { cid }");
var response = await _httpClient.GetResponse(new HttpRequestOptions
{
Url = $"http://sub.xmp.sandai.net:8000/subxl/{cid}.json",
UserAgent = "Emby.MeiamSub.Thunder",
//Url = $"http://sub.xmp.sandai.net:8000/subxl/{cid}.json",
Url = $"http://subtitle.kankan.xunlei.com:8000/subxl/{cid}.json",
UserAgent = $"{Name}",
TimeoutMs = 30000,
AcceptHeader = "*/*",
});
_logger.Debug($"MeiamSub.Thunder Search | Response -> { _jsonSerializer.SerializeToString(response) }");
_logger.Info($"{Name} Search | Response -> { _jsonSerializer.SerializeToString(response) }");
if (response.StatusCode == HttpStatusCode.OK)
{
@@ -97,13 +104,13 @@ namespace Emby.MeiamSub.Thunder
if (subtitleResponse != null)
{
_logger.Debug($"MeiamSub.Thunder Search | Response -> { _jsonSerializer.SerializeToString(subtitleResponse) }");
_logger.Info($"{Name} 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");
_logger.Info($"{Name} Search | Summary -> Get { subtitles.Count() } Subtitles");
return subtitles.Select(m => new RemoteSubtitleInfo()
{
@@ -112,21 +119,21 @@ namespace Emby.MeiamSub.Thunder
Url = m.surl,
Format = ExtractFormat(m.sname),
Language = request.Language,
TwoLetterISOLanguageName = request.TwoLetterISOLanguageName,
IsForced = request.IsForced
})),
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {request.TwoLetterISOLanguageName} | 迅雷",
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {m.language} | 迅雷",
Author = "Meiam ",
CommunityRating = Convert.ToSingle(m.rate),
ProviderName = "MeiamSub.Thunder",
ProviderName = $"{Name}",
Format = ExtractFormat(m.sname),
Comment = $"Format : { ExtractFormat(m.sname)} - Rate : { m.rate }"
Comment = $"Format : { ExtractFormat(m.sname)} - Rate : { m.rate }",
IsHashMatch = true
}).OrderByDescending(m => m.CommunityRating);
}
}
}
_logger.Debug($"MeiamSub.Thunder Search | Summary -> Get 0 Subtitles");
_logger.Info($"{Name} Search | Summary -> Get 0 Subtitles");
return Array.Empty<RemoteSubtitleInfo>();
}
@@ -141,10 +148,7 @@ namespace Emby.MeiamSub.Thunder
/// <returns></returns>
public async Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken)
{
await Task.Run(() =>
{
_logger.Debug($"MeiamSub.Thunder DownloadSub | Request -> {id}");
});
_logger.Info($"{Name} DownloadSub | Request -> {id}");
return await DownloadSubAsync(id);
}
@@ -158,17 +162,22 @@ namespace Emby.MeiamSub.Thunder
{
var downloadSub = _jsonSerializer.DeserializeFromString<DownloadSubInfo>(Base64Decode(info));
_logger.Debug($"MeiamSub.Thunder DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
if (downloadSub == null)
{
return new SubtitleResponse();
}
_logger.Info($"{Name} DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
var response = await _httpClient.GetResponse(new HttpRequestOptions
{
Url = downloadSub.Url,
UserAgent = "Emby.MeiamSub.Thunder",
UserAgent = $"{Name}",
TimeoutMs = 30000,
AcceptHeader = "*/*",
});
_logger.Debug($"MeiamSub.Thunder DownloadSub | Response -> { response.StatusCode }");
_logger.Info($"{Name} DownloadSub | Response -> { response.StatusCode }");
if (response.StatusCode == HttpStatusCode.OK)
{

View File

@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>1.0.5</Version>
<AssemblyVersion>1.0.5.0</AssemblyVersion>
<FileVersion>1.0.5.0</FileVersion>
<Version>1.0.9</Version>
<AssemblyVersion>1.0.9.0</AssemblyVersion>
<FileVersion>1.0.9.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.7.7" />
<PackageReference Include="Jellyfin.Controller" Version="10.7.0" />
</ItemGroup>
</Project>

View File

@@ -2,7 +2,6 @@
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Subtitles;
using MediaBrowser.Model.Providers;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@@ -11,9 +10,9 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
@@ -31,10 +30,9 @@ namespace Jellyfin.MeiamSub.Shooter
public const string SRT = "srt";
private readonly ILogger<ShooterProvider> _logger;
private readonly IJsonSerializer _jsonSerializer;
private static readonly HttpClient Client = new HttpClient();
private static readonly HttpClient _httpClient = new HttpClient();
public int Order => 0;
public int Order => 1;
public string Name => "MeiamSub.Shooter";
/// <summary>
@@ -44,10 +42,11 @@ namespace Jellyfin.MeiamSub.Shooter
#endregion
#region
public ShooterProvider(ILogger<ShooterProvider> logger, IJsonSerializer jsonSerializer)
public ShooterProvider(ILogger<ShooterProvider> logger)
{
_logger = logger;
_jsonSerializer = jsonSerializer;
_httpClient.Timeout = TimeSpan.FromSeconds(30);
_logger.LogInformation($"{Name} Init");
}
#endregion
@@ -61,7 +60,7 @@ namespace Jellyfin.MeiamSub.Shooter
/// <returns></returns>
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
_logger.LogInformation($"MeiamSub.Shooter Search | Request -> { _jsonSerializer.SerializeToString(request) }");
_logger.LogInformation($"{Name} Search | SubtitleSearchRequest -> { JsonSerializer.Serialize(request) }");
var subtitles = await SearchSubtitlesAsync(request);
@@ -80,67 +79,76 @@ namespace Jellyfin.MeiamSub.Shooter
return Array.Empty<RemoteSubtitleInfo>();
}
FileInfo fileInfo = new FileInfo(request.MediaPath);
FileInfo fileInfo = new(request.MediaPath);
var hash = ComputeFileHash(fileInfo);
using (var _httpClient = new HttpClient())
_logger.LogInformation($"{Name} Search | FileHash -> { hash }");
var content = new Dictionary<string, string>
{
var options = new {
{ "filehash", hash},
{ "pathinfo", request.MediaPath},
{ "format", "json"},
{ "lang", request.Language == "chi" ? "chn" : "eng"}
};
filehash = HttpUtility.UrlEncode(hash),
pathinfo = HttpUtility.UrlEncode(request.MediaPath),
format = "json",
lang = request.Language == "chi" ? "chn" : "eng"
};
_logger.LogInformation($"MeiamSub.Shooter Search | Request -> { _jsonSerializer.SerializeToString(options) }");
HttpRequestMessage requestMessage = new HttpRequestMessage();
var response = await PostAsync($"http://www.shooter.cn/api/subapi.php", options);
requestMessage.Method = HttpMethod.Post;
requestMessage.RequestUri = new Uri($"https://www.shooter.cn/api/subapi.php");
requestMessage.Content = new FormUrlEncodedContent(content);
requestMessage.Headers.Add("User-Agent", $"{Name}");
requestMessage.Headers.Add("Accept-Encoding", $"gzip, deflate, br");
requestMessage.Headers.Add("Accept", $"*/*");
_logger.LogInformation($"MeiamSub.Shooter Search | Response -> { _jsonSerializer.SerializeToString(response) }");
var response = await _httpClient.SendAsync(requestMessage);
if (response.StatusCode == HttpStatusCode.OK && response.Headers.Any(m => m.Value.Contains("application/json")))
_logger.LogInformation($"{Name} Search | Response -> { JsonSerializer.Serialize(response) }");
if (response.StatusCode == HttpStatusCode.OK && response.Content.Headers.Any(m => m.Value.Contains("application/json; charset=utf-8")))
{
var subtitleResponse = JsonSerializer.Deserialize<List<SubtitleResponseRoot>>(await response.Content.ReadAsStringAsync());
_logger.LogInformation($"{Name} Search | Response -> { JsonSerializer.Serialize(subtitleResponse) }");
if (subtitleResponse != null)
{
var subtitleResponse = _jsonSerializer.DeserializeFromStream<List<SubtitleResponseRoot>>(await response.Content.ReadAsStreamAsync());
var remoteSubtitleInfos = new List<RemoteSubtitleInfo>();
if (subtitleResponse != null)
foreach (var subFileInfo in subtitleResponse)
{
_logger.LogInformation($"MeiamSub.Shooter Search | Response -> { _jsonSerializer.SerializeToString(subtitleResponse) }");
var remoteSubtitleInfos = new List<RemoteSubtitleInfo>();
foreach (var subFileInfo in subtitleResponse)
foreach (var subFile in subFileInfo.Files)
{
foreach (var subFile in subFileInfo.Files)
remoteSubtitleInfos.Add(new RemoteSubtitleInfo()
{
remoteSubtitleInfos.Add(new RemoteSubtitleInfo()
Id = Base64Encode(JsonSerializer.Serialize(new DownloadSubInfo
{
Id = Base64Encode(_jsonSerializer.SerializeToString(new DownloadSubInfo
{
Url = subFile.Link,
Format = subFile.Ext,
Language = request.Language,
TwoLetterISOLanguageName = request.TwoLetterISOLanguageName,
})),
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {request.TwoLetterISOLanguageName} | 射手",
Author = "Meiam ",
ProviderName = "MeiamSub.Shooter",
Url = subFile.Link,
Format = subFile.Ext,
Comment = $"Format : { ExtractFormat(subFile.Ext)}"
});
}
Language = request.Language,
TwoLetterISOLanguageName = request.TwoLetterISOLanguageName,
})),
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {request.TwoLetterISOLanguageName} | 射手",
Author = "Meiam ",
ProviderName = $"{Name}",
Format = subFile.Ext,
Comment = $"Format : { ExtractFormat(subFile.Ext)}",
IsHashMatch = true
});
}
_logger.LogInformation($"MeiamSub.Shooter Search | Summary -> Get { remoteSubtitleInfos.Count } Subtitles");
return remoteSubtitleInfos;
}
_logger.LogInformation($"{Name} Search | Summary -> Get { remoteSubtitleInfos.Count } Subtitles");
return remoteSubtitleInfos;
}
_logger.LogInformation($"MeiamSub.Shooter Search | Summary -> Get 0 Subtitles");
}
_logger.LogInformation($"{Name} Search | Summary -> Get 0 Subtitles");
return Array.Empty<RemoteSubtitleInfo>();
}
#endregion
@@ -154,10 +162,7 @@ namespace Jellyfin.MeiamSub.Shooter
/// <returns></returns>
public async Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken)
{
await Task.Run(() =>
{
_logger.LogInformation($"MeiamSub.Shooter DownloadSub | Request -> {id}");
});
_logger.LogInformation($"{Name} DownloadSub | Request -> {id}");
return await DownloadSubAsync(id);
}
@@ -169,31 +174,43 @@ namespace Jellyfin.MeiamSub.Shooter
/// <returns></returns>
private async Task<SubtitleResponse> DownloadSubAsync(string info)
{
var downloadSub = _jsonSerializer.DeserializeFromString<DownloadSubInfo>(Base64Decode(info));
var downloadSub = JsonSerializer.Deserialize<DownloadSubInfo>(Base64Decode(info));
downloadSub.Url = downloadSub.Url.Replace("https://www.shooter.cn", "http://www.shooter.cn");
_logger.LogInformation($"MeiamSub.Shooter DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
using (var _httpClient = new HttpClient())
if (downloadSub == null)
{
var response = await _httpClient.GetAsync(downloadSub.Url);
_logger.LogInformation($"MeiamSub.Shooter DownloadSub | Response -> { response.StatusCode }");
if (response.StatusCode == HttpStatusCode.OK)
{
return new SubtitleResponse()
{
Language = downloadSub.Language,
IsForced = false,
Format = downloadSub.Format,
Stream = await response.Content.ReadAsStreamAsync(),
};
}
return new SubtitleResponse();
}
_logger.LogInformation($"{Name} DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
using var options = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri(downloadSub.Url),
Headers =
{
UserAgent = { new ProductInfoHeaderValue(new ProductHeaderValue($"{Name}")) },
Accept = { new MediaTypeWithQualityHeaderValue("*/*") }
}
};
var response = await _httpClient.SendAsync(options);
_logger.LogInformation($"{Name} DownloadSub | Response -> { response.StatusCode }");
if (response.StatusCode == HttpStatusCode.OK)
{
var stream = await response.Content.ReadAsStreamAsync();
return new SubtitleResponse()
{
Language = downloadSub.Language,
IsForced = false,
Format = downloadSub.Format,
Stream = stream,
};
}
return new SubtitleResponse();
}
@@ -294,16 +311,5 @@ namespace Jellyfin.MeiamSub.Shooter
return ret;
}
#endregion
#region HTTP
public async Task<HttpResponseMessage> PostAsync(string url, object data)
{
string content = _jsonSerializer.SerializeToString(data);
var buffer = Encoding.UTF8.GetBytes(content);
var byteContent = new ByteArrayContent(buffer);
byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
return await Client.PostAsync(url, byteContent);
}
#endregion
}
}

View File

@@ -5,7 +5,8 @@
<TargetFramework>net5.0</TargetFramework>
<ApplicationIcon />
<StartupObject />
<Version>1.0.5</Version>
<Version>1.0.9</Version>
<AssemblyVersion>1.0.9.0</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@@ -13,7 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.7.7" />
<PackageReference Include="Jellyfin.Controller" Version="10.7.0" />
</ItemGroup>
</Project>

View File

@@ -10,6 +10,5 @@ namespace Jellyfin.MeiamSub.Thunder.Model
public string Format { get; set; }
public string Language { get; set; }
public string TwoLetterISOLanguageName { get; set; }
public bool? IsForced { get; set; }
}
}

View File

@@ -28,10 +28,6 @@ namespace Jellyfin.MeiamSub.Thunder.Model
///
/// </summary>
public int svote { get; set; }
/// <summary>
///
/// </summary>
public int roffset { get; set; }
}
public class SubtitleResponseRoot

View File

@@ -2,7 +2,6 @@
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Subtitles;
using MediaBrowser.Model.Providers;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@@ -10,8 +9,10 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
@@ -20,7 +21,7 @@ namespace Jellyfin.MeiamSub.Thunder
/// <summary>
/// 迅雷字幕组件
/// </summary>
public class ThunderProvider : ISubtitleProvider
public class ThunderProvider : ISubtitleProvider, IHasOrder
{
#region
public const string ASS = "ass";
@@ -28,10 +29,9 @@ namespace Jellyfin.MeiamSub.Thunder
public const string SRT = "srt";
private readonly ILogger<ThunderProvider> _logger;
private readonly IJsonSerializer _jsonSerializer;
public int Order => 0;
private static readonly HttpClient _httpClient = new HttpClient();
public int Order => 1;
public string Name => "MeiamSub.Thunder";
/// <summary>
@@ -41,10 +41,11 @@ namespace Jellyfin.MeiamSub.Thunder
#endregion
#region
public ThunderProvider(ILogger<ThunderProvider> logger, IJsonSerializer jsonSerializer)
public ThunderProvider(ILogger<ThunderProvider> logger)
{
_logger = logger;
_jsonSerializer = jsonSerializer;
_httpClient.Timeout = TimeSpan.FromSeconds(30);
_logger.LogInformation($"{Name} Init");
}
#endregion
@@ -58,7 +59,7 @@ namespace Jellyfin.MeiamSub.Thunder
/// <returns></returns>
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
_logger.LogDebug($"MeiamSub.Thunder Search | Request -> { _jsonSerializer.SerializeToString(request) }");
_logger.LogInformation($"{Name} Search | SubtitleSearchRequest -> { JsonSerializer.Serialize(request) }");
var subtitles = await SearchSubtitlesAsync(request);
@@ -79,49 +80,60 @@ namespace Jellyfin.MeiamSub.Thunder
var cid = GetCidByFile(request.MediaPath);
_logger.LogInformation($"{Name} Search | FileHash -> { cid }");
using (var _httpClient = new HttpClient())
using var options = new HttpRequestMessage
{
var response = await _httpClient.GetAsync($"http://sub.xmp.sandai.net:8000/subxl/{cid}.json");
_logger.LogDebug($"MeiamSub.Thunder Search | Response -> { _jsonSerializer.SerializeToString(response) }");
if (response.StatusCode == HttpStatusCode.OK)
{
var subtitleResponse = _jsonSerializer.DeserializeFromStream<SubtitleResponseRoot>(await response.Content.ReadAsStreamAsync());
if (subtitleResponse != null)
Method = HttpMethod.Get,
//RequestUri = new Uri($"http://sub.xmp.sandai.net:8000/subxl/{cid}.json"),
RequestUri = new Uri($"http://subtitle.kankan.xunlei.com:8000/subxl/{cid}.json"),
Headers =
{
_logger.LogDebug($"MeiamSub.Thunder Search | Response -> { _jsonSerializer.SerializeToString(subtitleResponse) }");
UserAgent = { new ProductInfoHeaderValue(new ProductHeaderValue($"{Name}")) },
Accept = { new MediaTypeWithQualityHeaderValue("*/*") },
}
};
var subtitles = subtitleResponse.sublist.Where(m => !string.IsNullOrEmpty(m.sname));
var response = await _httpClient.SendAsync(options);
if (subtitles.Count() > 0)
_logger.LogInformation($"{Name} Search | Response -> { JsonSerializer.Serialize(response) }");
if (response.StatusCode == HttpStatusCode.OK)
{
var subtitleResponse = JsonSerializer.Deserialize<SubtitleResponseRoot>(await response.Content.ReadAsStringAsync());
if (subtitleResponse != null)
{
_logger.LogInformation($"{Name} Search | Response -> { JsonSerializer.Serialize(subtitleResponse) }");
var subtitles = subtitleResponse.sublist.Where(m => !string.IsNullOrEmpty(m.sname));
if (subtitles.Count() > 0)
{
_logger.LogInformation($"{Name} Search | Summary -> Get { subtitles.Count() } Subtitles");
return subtitles.Select(m => new RemoteSubtitleInfo()
{
_logger.LogDebug($"MeiamSub.Thunder Search | Summary -> Get { subtitles.Count() } Subtitles");
return subtitles.Select(m => new RemoteSubtitleInfo()
Id = Base64Encode(JsonSerializer.Serialize(new DownloadSubInfo
{
Id = Base64Encode(_jsonSerializer.SerializeToString(new DownloadSubInfo
{
Url = m.surl,
Format = ExtractFormat(m.sname),
Language = request.Language,
TwoLetterISOLanguageName = request.TwoLetterISOLanguageName,
})),
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {request.TwoLetterISOLanguageName} | 迅雷",
Author = "Meiam ",
CommunityRating = Convert.ToSingle(m.rate),
ProviderName = "MeiamSub.Thunder",
Url = m.surl,
Format = ExtractFormat(m.sname),
Comment = $"Format : { ExtractFormat(m.sname)} - Rate : { m.rate }"
}).OrderByDescending(m => m.CommunityRating);
}
Language = request.Language,
TwoLetterISOLanguageName = request.TwoLetterISOLanguageName,
})),
Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {request.TwoLetterISOLanguageName} | 迅雷",
Author = "Meiam ",
CommunityRating = Convert.ToSingle(m.rate),
ProviderName = $"{Name}",
Format = ExtractFormat(m.sname),
Comment = $"Format : { ExtractFormat(m.sname)} - Rate : { m.rate }",
IsHashMatch = true
}).OrderByDescending(m => m.CommunityRating);
}
}
}
_logger.LogDebug($"MeiamSub.Thunder Search | Summary -> Get 0 Subtitles");
_logger.LogInformation($"{Name} Search | Summary -> Get 0 Subtitles");
return Array.Empty<RemoteSubtitleInfo>();
}
@@ -136,10 +148,7 @@ namespace Jellyfin.MeiamSub.Thunder
/// <returns></returns>
public async Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken)
{
await Task.Run(() =>
{
_logger.LogDebug($"MeiamSub.Thunder DownloadSub | Request -> {id}");
});
_logger.LogInformation($"{Name} DownloadSub | Request -> {id}");
return await DownloadSubAsync(id);
}
@@ -151,29 +160,43 @@ namespace Jellyfin.MeiamSub.Thunder
/// <returns></returns>
private async Task<SubtitleResponse> DownloadSubAsync(string info)
{
var downloadSub = _jsonSerializer.DeserializeFromString<DownloadSubInfo>(Base64Decode(info));
var downloadSub = JsonSerializer.Deserialize<DownloadSubInfo>(Base64Decode(info));
_logger.LogDebug($"MeiamSub.Thunder DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
using (var _httpClient = new HttpClient())
if (downloadSub == null)
{
var response = await _httpClient.GetAsync(downloadSub.Url);
_logger.LogDebug($"MeiamSub.Thunder DownloadSub | Response -> { response.StatusCode }");
if (response.StatusCode == HttpStatusCode.OK)
{
return new SubtitleResponse()
{
Language = downloadSub.Language,
IsForced = false,
Format = downloadSub.Format,
Stream = await response.Content.ReadAsStreamAsync(),
};
}
return new SubtitleResponse();
}
_logger.LogInformation($"{Name} DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
using var options = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri(downloadSub.Url),
Headers =
{
UserAgent = { new ProductInfoHeaderValue(new ProductHeaderValue($"{Name}")) },
Accept = { new MediaTypeWithQualityHeaderValue("*/*") }
}
};
var response = await _httpClient.SendAsync(options);
_logger.LogInformation($"{Name} DownloadSub | Response -> { response.StatusCode }");
if (response.StatusCode == HttpStatusCode.OK)
{
var stream = await response.Content.ReadAsStreamAsync();
return new SubtitleResponse()
{
Language = downloadSub.Language,
IsForced = false,
Format = downloadSub.Format,
Stream = stream,
};
}
return new SubtitleResponse();
}

View File

@@ -1,4 +1,4 @@
# Emby.MeiamSub
# MeiamSubtitles
Emby Jellyfin 中文字幕插件 ,支持 迅雷影音、射手网、 精准匹配,自动下载
@@ -16,6 +16,8 @@ Emby Jellyfin 中文字幕插件 ,支持 迅雷影音、射手网、 精准匹
## 给个星星! ⭐️
如果你喜欢这个项目或者它帮助你, 请给 Star~(辛苦咯)
如果你能赞助稳定 Google Drive 团队盘用于媒体库插件测试, 请于我联系 91270#QQ.COM
&nbsp;
@@ -60,11 +62,19 @@ Emby Jellyfin 中文字幕插件 ,支持 迅雷影音、射手网、 精准匹
### 群晖
```bash
复制插件文件到 /var/packages/EmbyServer/target/var/plugins
复制插件文件到 /var/packages/EmbyServer/var/plugins
复制插件文件到 /var/packages/EmbyServer/target/system/plugins
重启服务
```
### 威联通
```bash
# 其中`CACHEDEV{num}_DATA`的名称取决于你的qpkg安装位置
复制插件文件到 /share/CACHEDEV1_DATA/.qpkg/EmbyServer/programdata/plugins
复制插件文件到 /share/CACHEDEV1_DATA/.qpkg/EmbyServer/system/plugins
重启服务
```
&nbsp;
## 贡献