mirror of
https://github.com/91270/MeiamSubtitles.git
synced 2026-02-03 02:24:16 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac28e193e3 | ||
|
|
f796c05f99 | ||
|
|
ddeb8e0c14 | ||
|
|
7a0fb35fc5 | ||
|
|
74e576de93 | ||
|
|
bc72ca4ab0 | ||
|
|
2d4940156d |
@@ -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.7.0</AssemblyVersion>
|
||||
<FileVersion>1.0.7.0</FileVersion>
|
||||
<Version>1.0.7</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -86,7 +87,7 @@ namespace Emby.MeiamSub.Shooter
|
||||
HttpRequestOptions options = new HttpRequestOptions
|
||||
{
|
||||
Url = $"http://www.shooter.cn/api/subapi.php",
|
||||
UserAgent = "Emby.MeiamSub.Shooter",
|
||||
UserAgent = $"{Name}",
|
||||
TimeoutMs = 30000,
|
||||
AcceptHeader = "*/*",
|
||||
};
|
||||
@@ -99,11 +100,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 +112,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 +127,24 @@ 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)}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_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 +159,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 +173,25 @@ namespace Emby.MeiamSub.Shooter
|
||||
{
|
||||
var downloadSub = _jsonSerializer.DeserializeFromString<DownloadSubInfo>(Base64Decode(info));
|
||||
|
||||
if (downloadSub == null)
|
||||
{
|
||||
return new SubtitleResponse();
|
||||
}
|
||||
|
||||
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 } ");
|
||||
_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)
|
||||
{
|
||||
|
||||
@@ -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.7.0</AssemblyVersion>
|
||||
<FileVersion>1.0.7.0</FileVersion>
|
||||
<Version>1.0.7</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -83,13 +84,14 @@ namespace Emby.MeiamSub.Thunder
|
||||
|
||||
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 +99,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,13 +114,12 @@ 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) } | {request.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 }"
|
||||
}).OrderByDescending(m => m.CommunityRating);
|
||||
@@ -126,7 +127,7 @@ namespace Emby.MeiamSub.Thunder
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Debug($"MeiamSub.Thunder Search | Summary -> Get 0 Subtitles");
|
||||
_logger.Info($"{Name} Search | Summary -> Get 0 Subtitles");
|
||||
|
||||
return Array.Empty<RemoteSubtitleInfo>();
|
||||
}
|
||||
@@ -141,10 +142,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 +156,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)
|
||||
{
|
||||
|
||||
@@ -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.7</Version>
|
||||
<AssemblyVersion>1.0.7.0</AssemblyVersion>
|
||||
<FileVersion>1.0.7.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>
|
||||
|
||||
@@ -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,8 +30,7 @@ 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 string Name => "MeiamSub.Shooter";
|
||||
@@ -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,79 @@ 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())
|
||||
var content = new StringContent(JsonSerializer.Serialize(new
|
||||
{
|
||||
var options = new {
|
||||
filehash = HttpUtility.UrlEncode(hash),
|
||||
pathinfo = HttpUtility.UrlEncode(request.MediaPath),
|
||||
format = "json",
|
||||
lang = request.Language == "chi" ? "chn" : "eng"
|
||||
}), Encoding.UTF8, "application/json");
|
||||
|
||||
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) }");
|
||||
|
||||
var response = await PostAsync($"http://www.shooter.cn/api/subapi.php", options);
|
||||
|
||||
_logger.LogInformation($"MeiamSub.Shooter Search | Response -> { _jsonSerializer.SerializeToString(response) }");
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK && response.Headers.Any(m => m.Value.Contains("application/json")))
|
||||
{
|
||||
var subtitleResponse = _jsonSerializer.DeserializeFromStream<List<SubtitleResponseRoot>>(await response.Content.ReadAsStreamAsync());
|
||||
|
||||
if (subtitleResponse != null)
|
||||
var options = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri($"http://www.shooter.cn/api/subapi.php"),
|
||||
Content = content,
|
||||
Headers =
|
||||
{
|
||||
_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)
|
||||
{
|
||||
remoteSubtitleInfos.Add(new RemoteSubtitleInfo()
|
||||
{
|
||||
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",
|
||||
Format = subFile.Ext,
|
||||
Comment = $"Format : { ExtractFormat(subFile.Ext)}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation($"MeiamSub.Shooter Search | Summary -> Get { remoteSubtitleInfos.Count } Subtitles");
|
||||
|
||||
return remoteSubtitleInfos;
|
||||
UserAgent = { new ProductInfoHeaderValue(new ProductHeaderValue($"{Name}")) },
|
||||
Accept = { new MediaTypeWithQualityHeaderValue("*/*") }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
_logger.LogInformation($"{Name} Search | Request -> { JsonSerializer.Serialize(options) }");
|
||||
|
||||
var response = await _httpClient.SendAsync(options);
|
||||
|
||||
_logger.LogInformation($"{Name} Search | Response -> { JsonSerializer.Serialize(response) }");
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK && response.Headers.Any(m => m.Value.Contains("application/json")))
|
||||
{
|
||||
var subtitleResponse = JsonSerializer.Deserialize<List<SubtitleResponseRoot>>(await response.Content.ReadAsStringAsync());
|
||||
|
||||
if (subtitleResponse != null)
|
||||
{
|
||||
_logger.LogInformation($"{Name} Search | Response -> { JsonSerializer.Serialize(subtitleResponse) }");
|
||||
|
||||
var remoteSubtitleInfos = new List<RemoteSubtitleInfo>();
|
||||
|
||||
foreach (var subFileInfo in subtitleResponse)
|
||||
{
|
||||
foreach (var subFile in subFileInfo.Files)
|
||||
{
|
||||
remoteSubtitleInfos.Add(new RemoteSubtitleInfo()
|
||||
{
|
||||
Id = Base64Encode(JsonSerializer.Serialize(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 = $"{Name}",
|
||||
Format = subFile.Ext,
|
||||
Comment = $"Format : { ExtractFormat(subFile.Ext)}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_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 +165,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 +177,45 @@ 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));
|
||||
|
||||
if (downloadSub == null)
|
||||
{
|
||||
return new SubtitleResponse();
|
||||
}
|
||||
|
||||
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 } ");
|
||||
_logger.LogInformation($"{Name} DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
|
||||
|
||||
using (var _httpClient = new HttpClient())
|
||||
using var options = new HttpRequestMessage
|
||||
{
|
||||
|
||||
var response = await _httpClient.GetAsync(downloadSub.Url);
|
||||
|
||||
_logger.LogInformation($"MeiamSub.Shooter DownloadSub | Response -> { response.StatusCode }");
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
|
||||
return new SubtitleResponse()
|
||||
Method = HttpMethod.Get,
|
||||
RequestUri = new Uri(downloadSub.Url),
|
||||
Headers =
|
||||
{
|
||||
Language = downloadSub.Language,
|
||||
IsForced = false,
|
||||
Format = downloadSub.Format,
|
||||
Stream = await response.Content.ReadAsStreamAsync(),
|
||||
};
|
||||
}
|
||||
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 +316,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<ApplicationIcon />
|
||||
<StartupObject />
|
||||
<Version>1.0.5</Version>
|
||||
<Version>1.0.7</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
@@ -13,7 +13,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Jellyfin.Controller" Version="10.7.7" />
|
||||
<PackageReference Include="Jellyfin.Controller" Version="10.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
private static readonly HttpClient _httpClient = new HttpClient();
|
||||
|
||||
public int Order => 0;
|
||||
|
||||
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,57 @@ namespace Jellyfin.MeiamSub.Thunder
|
||||
|
||||
var cid = GetCidByFile(request.MediaPath);
|
||||
|
||||
|
||||
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 }"
|
||||
}).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 +145,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 +157,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();
|
||||
|
||||
}
|
||||
|
||||
10
README.md
10
README.md
@@ -1,4 +1,4 @@
|
||||
# Emby.MeiamSub
|
||||
# MeiamSubtitles
|
||||
Emby Jellyfin 中文字幕插件 ,支持 迅雷影音、射手网、 精准匹配,自动下载
|
||||
|
||||
|
||||
@@ -65,6 +65,14 @@ Emby Jellyfin 中文字幕插件 ,支持 迅雷影音、射手网、 精准匹
|
||||
重启服务
|
||||
```
|
||||
|
||||
### 威联通
|
||||
```bash
|
||||
# 其中`CACHEDEV{num}_DATA`的名称取决于你的qpkg安装位置
|
||||
复制插件文件到 /share/CACHEDEV1_DATA/.qpkg/EmbyServer/programdata/plugins
|
||||
复制插件文件到 /share/CACHEDEV1_DATA/.qpkg/EmbyServer/system/plugins
|
||||
重启服务
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 贡献
|
||||
|
||||
Reference in New Issue
Block a user