diff --git a/Emby.MeiamSub.Shooter/Emby.MeiamSub.Shooter.csproj b/Emby.MeiamSub.Shooter/Emby.MeiamSub.Shooter.csproj index 3b14774..32096c0 100644 --- a/Emby.MeiamSub.Shooter/Emby.MeiamSub.Shooter.csproj +++ b/Emby.MeiamSub.Shooter/Emby.MeiamSub.Shooter.csproj @@ -1,13 +1,13 @@  - 1.0.10.0 - 1.0.10.0 - 1.0.10 + 1.0.11.0 + 1.0.11.0 + 1.0.11 - netstandard2.0 + netstandard2.1 diff --git a/Emby.MeiamSub.Shooter/Plugin.cs b/Emby.MeiamSub.Shooter/Plugin.cs index 145dc0a..7dd7080 100644 --- a/Emby.MeiamSub.Shooter/Plugin.cs +++ b/Emby.MeiamSub.Shooter/Plugin.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Plugins; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Plugins; using MediaBrowser.Model.Drawing; using System; using System.IO; @@ -11,6 +12,12 @@ namespace Emby.MeiamSub.Shooter /// public class Plugin : BasePlugin, IHasThumbImage { + + public Plugin(IApplicationPaths applicationPaths) + { + Instance = this; + } + /// /// 插件ID /// @@ -31,6 +38,9 @@ namespace Emby.MeiamSub.Shooter /// public ImageFormat ThumbImageFormat => ImageFormat.Gif; + + public static Plugin Instance { get; private set; } + /// /// 缩略图资源文件 /// diff --git a/Emby.MeiamSub.Shooter/ShooterProvider.cs b/Emby.MeiamSub.Shooter/ShooterProvider.cs index c5e88c8..7857d89 100644 --- a/Emby.MeiamSub.Shooter/ShooterProvider.cs +++ b/Emby.MeiamSub.Shooter/ShooterProvider.cs @@ -8,14 +8,12 @@ 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; -using static System.Net.Mime.MediaTypeNames; namespace Emby.MeiamSub.Shooter { diff --git a/Emby.MeiamSub.Thunder/Emby.MeiamSub.Thunder.csproj b/Emby.MeiamSub.Thunder/Emby.MeiamSub.Thunder.csproj index e072e4a..4f10eb6 100644 --- a/Emby.MeiamSub.Thunder/Emby.MeiamSub.Thunder.csproj +++ b/Emby.MeiamSub.Thunder/Emby.MeiamSub.Thunder.csproj @@ -1,13 +1,13 @@  - 1.0.10.0 - 1.0.10.0 - 1.0.10 + 1.0.11.0 + 1.0.11.0 + 1.0.11 - netstandard2.0 + netstandard2.1 @@ -28,6 +28,11 @@ + + + + + diff --git a/Emby.MeiamSub.Thunder/Model/SubtitleResponseRoot.cs b/Emby.MeiamSub.Thunder/Model/SubtitleResponseRoot.cs index 49b7bf5..3392751 100644 --- a/Emby.MeiamSub.Thunder/Model/SubtitleResponseRoot.cs +++ b/Emby.MeiamSub.Thunder/Model/SubtitleResponseRoot.cs @@ -2,39 +2,30 @@ namespace Emby.MeiamSub.Thunder.Model { - public class SublistItem - { - /// - /// - /// - public string scid { get; set; } - /// - /// - /// - public string sname { get; set; } - /// - /// 未知语言 - /// - public string language { get; set; } - /// - /// - /// - public string rate { get; set; } - /// - /// - /// - public string surl { get; set; } - /// - /// - /// - public int svote { get; set; } - } public class SubtitleResponseRoot { - /// - /// - /// - public List sublist { get; set; } + public int Code { get; set; } + public List Data { get; set; } + public string Result { get; set; } } + + public class SublistItem + { + public string Gcid { get; set; } + public string Cid { get; set; } + public string Url { get; set; } + public string Ext { get; set; } + public string Name { get; set; } + public int Duration { get; set; } + public string[] Languages { get; set; } + + public string Langs=> Languages != null ? string.Join(",", Languages) : string.Empty; + + public int Source { get; set; } + public int Score { get; set; } + public int FingerprintfScore { get; set; } + public string ExtraName { get; set; } + } + } diff --git a/Emby.MeiamSub.Thunder/Plugin.cs b/Emby.MeiamSub.Thunder/Plugin.cs index 9e57a29..16aa521 100644 --- a/Emby.MeiamSub.Thunder/Plugin.cs +++ b/Emby.MeiamSub.Thunder/Plugin.cs @@ -1,5 +1,8 @@ -using MediaBrowser.Common.Plugins; +using MediaBrowser.Common; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Plugins; using MediaBrowser.Model.Drawing; +using MediaBrowser.Model.Serialization; using System; using System.IO; @@ -11,6 +14,12 @@ namespace Emby.MeiamSub.Thunder /// public class Plugin : BasePlugin, IHasThumbImage { + + public Plugin(IApplicationPaths applicationPaths) + { + Instance = this; + } + /// /// 插件ID /// @@ -31,6 +40,9 @@ namespace Emby.MeiamSub.Thunder /// public ImageFormat ThumbImageFormat => ImageFormat.Gif; + + public static Plugin Instance { get; private set; } + /// /// 缩略图资源文件 /// diff --git a/Emby.MeiamSub.Thunder/ThunderProvider.cs b/Emby.MeiamSub.Thunder/ThunderProvider.cs index 112a861..65a725d 100644 --- a/Emby.MeiamSub.Thunder/ThunderProvider.cs +++ b/Emby.MeiamSub.Thunder/ThunderProvider.cs @@ -14,7 +14,7 @@ using System.Security.Cryptography; using System.Text; using System.Threading; using System.Threading.Tasks; -using System.Web; +using static System.Net.WebRequestMethods; namespace Emby.MeiamSub.Thunder { @@ -28,11 +28,12 @@ namespace Emby.MeiamSub.Thunder public const string SSA = "ssa"; public const string SRT = "srt"; - private readonly ILogger _logger; + protected readonly ILogger _logger; private readonly IJsonSerializer _jsonSerializer; private readonly IHttpClient _httpClient; public int Order => 1; + public string Name => "MeiamSub.Thunder"; /// @@ -61,7 +62,7 @@ namespace Emby.MeiamSub.Thunder /// public async Task> Search(SubtitleSearchRequest request, CancellationToken cancellationToken) { - _logger.Info($"{0} Search | SubtitleSearchRequest -> {1}", new object[2] { Name, _jsonSerializer.SerializeToString(request) }); + _logger.Info("{0} Search | SubtitleSearchRequest -> {1}", new object[2] { Name, _jsonSerializer.SerializeToString(request) }); var subtitles = await SearchSubtitlesAsync(request); @@ -85,55 +86,62 @@ namespace Emby.MeiamSub.Thunder var cid = GetCidByFile(request.MediaPath); - _logger.Info($"{0} Search | FileHash -> {1}", new object[2] { Name, cid }); + _logger.Info("{0} Search | FileHash -> {1}", new object[2] { Name, cid }); - var response = await _httpClient.GetResponse(new HttpRequestOptions + + HttpRequestOptions options = new HttpRequestOptions { - //Url = $"http://sub.xmp.sandai.net:8000/subxl/{cid}.json", - Url = $"http://subtitle.kankan.xunlei.com:8000/subxl/{cid}.json", + Url = $"https://api-shoulei-ssl.xunlei.com/oracle/subtitle?&name={Path.GetFileName(request.MediaPath)}", UserAgent = $"{Name}", TimeoutMs = 30000, AcceptHeader = "*/*", - }); + }; + var response = await _httpClient.GetResponse(options); - _logger.Info($"{0} Search | Response -> {1}", new object[2] { Name, _jsonSerializer.SerializeToString(response) }); + _logger.Info("{0} Search | Response -> {1}", new object[2] { Name, _jsonSerializer.SerializeToString(response) }); if (response.StatusCode == HttpStatusCode.OK) { var subtitleResponse = _jsonSerializer.DeserializeFromStream(response.Content); - if (subtitleResponse != null) + if (subtitleResponse.Code == 0) { - _logger.Info($"{0} Search | Response -> {1}", new object[2] { Name, _jsonSerializer.SerializeToString(subtitleResponse) }); + _logger.Info("{0} Search | Response -> {1}", new object[2] { Name, _jsonSerializer.SerializeToString(subtitleResponse) }); - var subtitles = subtitleResponse.sublist.Where(m => !string.IsNullOrEmpty(m.sname)); + var subtitles = subtitleResponse.Data.Where(m => !string.IsNullOrEmpty(m.Name)); + + var remoteSubtitleInfos = new List(); if (subtitles.Count() > 0) { - _logger.Info($"{0} Search | Summary -> Get {1} Subtitles", new object[2] { Name, subtitles.Count() }); - - return subtitles.Select(m => new RemoteSubtitleInfo() + foreach (var item in subtitles) { - Id = Base64Encode(_jsonSerializer.SerializeToString(new DownloadSubInfo + remoteSubtitleInfos.Add(new RemoteSubtitleInfo() { - Url = m.surl, - Format = ExtractFormat(m.sname), - Language = request.Language, - IsForced = request.IsForced - })), - Name = $"[MEIAMSUB] { Path.GetFileName(request.MediaPath) } | {m.language} | 迅雷", - 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); + Id = Base64Encode(_jsonSerializer.SerializeToString(new DownloadSubInfo + { + Url = item.Url, + Format = item.Ext, + Language = request.Language, + IsForced = request.IsForced + })), + Name = $"[MEIAMSUB] {item.Name} | {(item.Langs == string.Empty ? "未知" : item.Langs)} | 迅雷", + Author = "Meiam ", + ProviderName = $"{Name}", + Format = item.Ext, + Comment = $"Format : {item.Ext}", + IsHashMatch = cid == item.Cid, + }); + } } + + _logger.Info("{0} Search | Summary -> Get {1} Subtitles", new object[2] { Name, remoteSubtitleInfos.Count }); + + return remoteSubtitleInfos; } } - _logger.Info($"{0} Search | Summary -> Get 0 Subtitles", new object[1] { Name }); + _logger.Info("{0} Search | Summary -> Get 0 Subtitles", new object[1] { Name }); return Array.Empty(); @@ -149,7 +157,7 @@ namespace Emby.MeiamSub.Thunder /// public async Task GetSubtitles(string id, CancellationToken cancellationToken) { - _logger.Info($"{0} DownloadSub | Request -> {1}", new object[2] { Name, id }); + _logger.Info("{0} DownloadSub | Request -> {1}", new object[2] { Name, id }); return await DownloadSubAsync(id); } @@ -168,7 +176,7 @@ namespace Emby.MeiamSub.Thunder return new SubtitleResponse(); } - _logger.Info($"{0} DownloadSub | Url -> {1} | Format -> {2} | Language -> {3} ", + _logger.Info("{0} DownloadSub | Url -> {1} | Format -> {2} | Language -> {3} ", new object[4] { Name, downloadSub.Url, downloadSub.Format, downloadSub.Language }); var response = await _httpClient.GetResponse(new HttpRequestOptions @@ -179,7 +187,7 @@ namespace Emby.MeiamSub.Thunder AcceptHeader = "*/*", }); - _logger.Info($"{0} DownloadSub | Response -> {1}", new object[2] { Name, response.StatusCode }); + _logger.Info("{0} DownloadSub | Response -> {1}", new object[2] { Name, response.StatusCode }); if (response.StatusCode == HttpStatusCode.OK) { diff --git a/Jellyfin.MeiamSub.Shooter/Jellyfin.MeiamSub.Shooter.csproj b/Jellyfin.MeiamSub.Shooter/Jellyfin.MeiamSub.Shooter.csproj index 59dc130..38359b4 100644 --- a/Jellyfin.MeiamSub.Shooter/Jellyfin.MeiamSub.Shooter.csproj +++ b/Jellyfin.MeiamSub.Shooter/Jellyfin.MeiamSub.Shooter.csproj @@ -2,9 +2,9 @@ net8.0 - 1.0.10 - 1.0.10.0 - 1.0.10.0 + 1.0.11 + 1.0.11.0 + 1.0.11.0 @@ -12,7 +12,7 @@ - + diff --git a/Jellyfin.MeiamSub.Shooter/ShooterProvider.cs b/Jellyfin.MeiamSub.Shooter/ShooterProvider.cs index e7676c0..af649cc 100644 --- a/Jellyfin.MeiamSub.Shooter/ShooterProvider.cs +++ b/Jellyfin.MeiamSub.Shooter/ShooterProvider.cs @@ -39,7 +39,7 @@ namespace Jellyfin.MeiamSub.Shooter private string apiUrl => "https://www.shooter.cn/api/subapi.php"; - public int Order => 1000; + public int Order => 1; public string Name => "MeiamSub.Shooter"; diff --git a/Jellyfin.MeiamSub.Thunder/Jellyfin.MeiamSub.Thunder.csproj b/Jellyfin.MeiamSub.Thunder/Jellyfin.MeiamSub.Thunder.csproj index 163660f..5513ae2 100644 --- a/Jellyfin.MeiamSub.Thunder/Jellyfin.MeiamSub.Thunder.csproj +++ b/Jellyfin.MeiamSub.Thunder/Jellyfin.MeiamSub.Thunder.csproj @@ -5,8 +5,8 @@ net8.0 - 1.0.10 - 1.0.10.0 + 1.0.11 + 1.0.11.0 @@ -14,7 +14,7 @@ - + diff --git a/Jellyfin.MeiamSub.Thunder/Model/SubtitleResponseRoot.cs b/Jellyfin.MeiamSub.Thunder/Model/SubtitleResponseRoot.cs index 0ec6e99..e677092 100644 --- a/Jellyfin.MeiamSub.Thunder/Model/SubtitleResponseRoot.cs +++ b/Jellyfin.MeiamSub.Thunder/Model/SubtitleResponseRoot.cs @@ -2,39 +2,28 @@ namespace Jellyfin.MeiamSub.Thunder.Model { - public class SublistItem - { - /// - /// - /// - public string scid { get; set; } - /// - /// - /// - public string sname { get; set; } - /// - /// 未知语言 - /// - public string language { get; set; } - /// - /// - /// - public string rate { get; set; } - /// - /// - /// - public string surl { get; set; } - /// - /// - /// - public int svote { get; set; } - } - public class SubtitleResponseRoot { - /// - /// - /// - public List sublist { get; set; } + public int Code { get; set; } + public List Data { get; set; } + public string Result { get; set; } + } + + public class SublistItem + { + public string Gcid { get; set; } + public string Cid { get; set; } + public string Url { get; set; } + public string Ext { get; set; } + public string Name { get; set; } + public int Duration { get; set; } + public string[] Languages { get; set; } + + public string Langs => Languages != null ? string.Join(",", Languages) : string.Empty; + + public int Source { get; set; } + public int Score { get; set; } + public int FingerprintfScore { get; set; } + public string ExtraName { get; set; } } } diff --git a/Jellyfin.MeiamSub.Thunder/ThunderProvider.cs b/Jellyfin.MeiamSub.Thunder/ThunderProvider.cs index ff32882..2eac733 100644 --- a/Jellyfin.MeiamSub.Thunder/ThunderProvider.cs +++ b/Jellyfin.MeiamSub.Thunder/ThunderProvider.cs @@ -85,8 +85,7 @@ namespace Jellyfin.MeiamSub.Thunder using var options = new HttpRequestMessage { 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"), + RequestUri = new Uri($"https://api-shoulei-ssl.xunlei.com/oracle/subtitle?&name={Path.GetFileName(request.MediaPath)}"), Headers = { UserAgent = { new ProductInfoHeaderValue(new ProductHeaderValue($"{Name}")) }, @@ -106,30 +105,36 @@ namespace Jellyfin.MeiamSub.Thunder { _logger.LogInformation($"{Name} Search | Response -> { JsonSerializer.Serialize(subtitleResponse) }"); - var subtitles = subtitleResponse.sublist.Where(m => !string.IsNullOrEmpty(m.sname)); + var subtitles = subtitleResponse.Data.Where(m => !string.IsNullOrEmpty(m.Name)); + + var remoteSubtitleInfos = new List(); if (subtitles.Count() > 0) { - _logger.LogInformation($"{Name} Search | Summary -> Get { subtitles.Count() } Subtitles"); - - return subtitles.Select(m => new RemoteSubtitleInfo() + foreach (var item in subtitles) { - Id = Base64Encode(JsonSerializer.Serialize(new DownloadSubInfo + remoteSubtitleInfos.Add(new RemoteSubtitleInfo() { - 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 = $"{Name}", - Format = ExtractFormat(m.sname), - Comment = $"Format : { ExtractFormat(m.sname)} - Rate : { m.rate }", - IsHashMatch = true - }).OrderByDescending(m => m.CommunityRating); + Id = Base64Encode(JsonSerializer.Serialize(new DownloadSubInfo + { + Url = item.Url, + Format = item.Ext, + Language = request.Language, + TwoLetterISOLanguageName = request.TwoLetterISOLanguageName, + })), + Name = $"[MEIAMSUB] {item.Name} | {(item.Langs == string.Empty ? "未知" : item.Langs)} | 迅雷", + Author = "Meiam ", + ProviderName = $"{Name}", + Format = item.Ext, + Comment = $"Format : {item.Ext}", + IsHashMatch = cid == item.Cid, + }); + } } + + _logger.LogInformation($"{Name} Search | Summary -> Get {subtitles.Count()} Subtitles"); + + return remoteSubtitleInfos; } }