Skip to content

Commit

Permalink
Emby .NET 框架更换到 netstandard2.0 适配最新版本
Browse files Browse the repository at this point in the history
  • Loading branch information
91270 committed May 24, 2024
1 parent f82702f commit bb81355
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 49 deletions.
15 changes: 10 additions & 5 deletions Emby.MeiamSub.Shooter/Emby.MeiamSub.Shooter.csproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyVersion>1.0.10.0</AssemblyVersion>
<FileVersion>1.0.10.0</FileVersion>
<Version>1.0.10</Version>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>2</WarningLevel>
<TargetFramework>netstandard2.0</TargetFramework>
</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.8.5" />
<PackageReference Include="MediaBrowser.Server.Core" Version="4.8.5" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="Copy $(TargetDir)$(TargetFileName) $(SolutionDir)$(ConfigurationName)\$(TargetFileName) /y&#xD;&#xA;" />
</Target>
</Project>

</Project>
31 changes: 17 additions & 14 deletions Emby.MeiamSub.Shooter/ShooterProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using static System.Net.Mime.MediaTypeNames;

namespace Emby.MeiamSub.Shooter
{
Expand All @@ -28,7 +29,7 @@ public class ShooterProvider : ISubtitleProvider, IHasOrder
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;

Expand All @@ -42,12 +43,12 @@ public class ShooterProvider : ISubtitleProvider, IHasOrder
#endregion

#region 构造函数
public ShooterProvider(ILogger logger, IJsonSerializer jsonSerializer,IHttpClient httpClient)
public ShooterProvider(ILogManager logManager, IJsonSerializer jsonSerializer,IHttpClient httpClient)
{
_logger = logger;
_logger = logManager.GetLogger(GetType().Name);
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
_logger.Info($"{Name} Init");
_logger.Info("{0} Init", new object[1] { Name });
}
#endregion

Expand All @@ -61,7 +62,7 @@ public ShooterProvider(ILogger logger, IJsonSerializer jsonSerializer,IHttpClien
/// <returns></returns>
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
_logger.Info($"{Name} Search | SubtitleSearchRequest -> { _jsonSerializer.SerializeToString(request) }");
_logger.Info("{0} Search | SubtitleSearchRequest -> {1}", new object[2] { Name , _jsonSerializer.SerializeToString(request) });

var subtitles = await SearchSubtitlesAsync(request);

Expand Down Expand Up @@ -90,7 +91,7 @@ private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(Subtitl

var hash = ComputeFileHash(fileInfo);

_logger.Info($"{Name} Search | FileHash -> { hash }");
_logger.Info("{0} Search | FileHash -> {1}", new object[2] { Name, hash });

HttpRequestOptions options = new HttpRequestOptions
{
Expand All @@ -108,19 +109,19 @@ private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(Subtitl
{ "lang",request.Language == "chi" ? "chn" : "eng"}
});

_logger.Info($"{Name} Search | Request -> { _jsonSerializer.SerializeToString(options) }");
_logger.Info("{0} Search | Request -> {1}", new object[2] { Name, _jsonSerializer.SerializeToString(options) });

var response = await _httpClient.Post(options);

_logger.Info($"{Name} Search | Response -> { _jsonSerializer.SerializeToString(response) }");
_logger.Info("{0} Search | Response -> {1}", new object[2] { Name, _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.Info($"{Name} Search | Response -> { _jsonSerializer.SerializeToString(subtitleResponse) }");
_logger.Info("{0} Search | Response -> {1}", new object[2] { Name, _jsonSerializer.SerializeToString(subtitleResponse) });

var remoteSubtitleInfos = new List<RemoteSubtitleInfo>();

Expand All @@ -146,14 +147,14 @@ private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(Subtitl
});
}
}
_logger.Info("{0} Search | Summary -> Get {1} Subtitles", new object[2] { Name, remoteSubtitleInfos.Count });

_logger.Info($"{Name} Search | Summary -> Get { remoteSubtitleInfos.Count } Subtitles");

return remoteSubtitleInfos;
}
}

_logger.Info($"{Name} Search | Summary -> Get 0 Subtitles");
_logger.Info("{0} Search | Summary -> Get 0 Subtitles", new object[1] { Name });

return Array.Empty<RemoteSubtitleInfo>();
}
Expand All @@ -168,7 +169,7 @@ private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(Subtitl
/// <returns></returns>
public async Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken)
{
_logger.Info($"{Name} DownloadSub | Request -> {id}");
_logger.Info("{0} DownloadSub | Request -> {1}", new object[2] { Name, id });

return await DownloadSubAsync(id);
}
Expand All @@ -187,7 +188,8 @@ private async Task<SubtitleResponse> DownloadSubAsync(string info)
return new SubtitleResponse();
}

_logger.Info($"{Name} DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
_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
{
Expand All @@ -198,7 +200,8 @@ private async Task<SubtitleResponse> DownloadSubAsync(string info)
});


_logger.Info($"{Name} DownloadSub | Response -> { response.StatusCode }");
_logger.Info("{0} DownloadSub | Request -> {1}", new object[2] { Name, response.StatusCode });


if (response.StatusCode == HttpStatusCode.OK)
{
Expand Down
8 changes: 5 additions & 3 deletions Emby.MeiamSub.Thunder/Emby.MeiamSub.Thunder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<FileVersion>1.0.10.0</FileVersion>
<Version>1.0.10</Version>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>..\Release</OutputPath>
</PropertyGroup>
Expand All @@ -22,6 +22,7 @@
<EmbeddedResource Include="Thumb.png" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="MediaBrowser.Common" Version="4.8.5" />
<PackageReference Include="MediaBrowser.Server.Core" Version="4.8.5" />
Expand All @@ -31,4 +32,5 @@
<Exec Command="Copy $(TargetDir)$(TargetFileName) $(SolutionDir)$(ConfigurationName)\$(TargetFileName) /y&#xD;&#xA;" />
</Target>


</Project>
26 changes: 14 additions & 12 deletions Emby.MeiamSub.Thunder/ThunderProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public class ThunderProvider : ISubtitleProvider, IHasOrder
#endregion

#region 构造函数
public ThunderProvider(ILogger logger, IJsonSerializer jsonSerializer,IHttpClient httpClient)
public ThunderProvider(ILogManager logManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
{
_logger = logger;
_logger = logManager.GetLogger(GetType().Name);
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
_logger.Info($"{Name} Init");
_logger.Info("{0} Init", new object[1] { Name });
}
#endregion

Expand All @@ -61,7 +61,7 @@ public ThunderProvider(ILogger logger, IJsonSerializer jsonSerializer,IHttpClien
/// <returns></returns>
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
_logger.Info($"{Name} Search | SubtitleSearchRequest -> { _jsonSerializer.SerializeToString(request) }");
_logger.Info($"{0} Search | SubtitleSearchRequest -> {1}", new object[2] { Name, _jsonSerializer.SerializeToString(request) });

var subtitles = await SearchSubtitlesAsync(request);

Expand All @@ -85,7 +85,7 @@ private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(Subtitl

var cid = GetCidByFile(request.MediaPath);

_logger.Info($"{Name} Search | FileHash -> { cid }");
_logger.Info($"{0} Search | FileHash -> {1}", new object[2] { Name, cid });

var response = await _httpClient.GetResponse(new HttpRequestOptions
{
Expand All @@ -96,21 +96,21 @@ private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(Subtitl
AcceptHeader = "*/*",
});

_logger.Info($"{Name} Search | Response -> { _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<SubtitleResponseRoot>(response.Content);

if (subtitleResponse != null)
{
_logger.Info($"{Name} Search | Response -> { _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));

if (subtitles.Count() > 0)
{
_logger.Info($"{Name} Search | Summary -> Get { subtitles.Count() } Subtitles");
_logger.Info($"{0} Search | Summary -> Get {1} Subtitles", new object[2] { Name, subtitles.Count() });

return subtitles.Select(m => new RemoteSubtitleInfo()
{
Expand All @@ -133,7 +133,8 @@ private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(Subtitl
}
}

_logger.Info($"{Name} Search | Summary -> Get 0 Subtitles");
_logger.Info($"{0} Search | Summary -> Get 0 Subtitles", new object[1] { Name });


return Array.Empty<RemoteSubtitleInfo>();
}
Expand All @@ -148,7 +149,7 @@ private async Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitlesAsync(Subtitl
/// <returns></returns>
public async Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken)
{
_logger.Info($"{Name} DownloadSub | Request -> {id}");
_logger.Info($"{0} DownloadSub | Request -> {1}", new object[2] { Name, id });

return await DownloadSubAsync(id);
}
Expand All @@ -167,7 +168,8 @@ private async Task<SubtitleResponse> DownloadSubAsync(string info)
return new SubtitleResponse();
}

_logger.Info($"{Name} DownloadSub | Url -> { downloadSub.Url } | Format -> { downloadSub.Format } | Language -> { downloadSub.Language } ");
_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
{
Expand All @@ -177,7 +179,7 @@ private async Task<SubtitleResponse> DownloadSubAsync(string info)
AcceptHeader = "*/*",
});

_logger.Info($"{Name} DownloadSub | Response -> { response.StatusCode }");
_logger.Info($"{0} DownloadSub | Response -> {1}", new object[2] { Name, response.StatusCode });

if (response.StatusCode == HttpStatusCode.OK)
{
Expand Down
30 changes: 15 additions & 15 deletions MeiamSubtitles.sln
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31424.327
# Visual Studio Version 17
VisualStudioVersion = 17.10.34916.146
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.MeiamSub.Thunder", "Emby.MeiamSub.Thunder\Emby.MeiamSub.Thunder.csproj", "{96F3F427-0EC3-4610-81C3-2C92D773EDC8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.MeiamSub.DevTool", "Emby.MeiamSub.DevTool\Emby.MeiamSub.DevTool.csproj", "{6B0C23EA-EC24-4FB0-948E-094E84AEBF21}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.MeiamSub.Shooter", "Emby.MeiamSub.Shooter\Emby.MeiamSub.Shooter.csproj", "{0F502AEB-0FF4-44FA-8391-13AD61FC5490}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.MeiamSub.Thunder", "Jellyfin.MeiamSub.Thunder\Jellyfin.MeiamSub.Thunder.csproj", "{4676AA1B-CC6C-42DC-BD69-6A293BAE8823}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.MeiamSub.Shooter", "Jellyfin.MeiamSub.Shooter\Jellyfin.MeiamSub.Shooter.csproj", "{8F77E155-9A91-4882-82E8-E8D69FECD246}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.MeiamSub.Shooter", "Jellyfin.MeiamSub.Shooter\Jellyfin.MeiamSub.Shooter.csproj", "{8F77E155-9A91-4882-82E8-E8D69FECD246}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.MeiamSub.Shooter", "Emby.MeiamSub.Shooter\Emby.MeiamSub.Shooter.csproj", "{F2636BCB-111D-4F22-AA06-8852E96D05C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.MeiamSub.Thunder", "Emby.MeiamSub.Thunder\Emby.MeiamSub.Thunder.csproj", "{96F4C65C-11B1-46F4-B343-115168688C2D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{96F3F427-0EC3-4610-81C3-2C92D773EDC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96F3F427-0EC3-4610-81C3-2C92D773EDC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96F3F427-0EC3-4610-81C3-2C92D773EDC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96F3F427-0EC3-4610-81C3-2C92D773EDC8}.Release|Any CPU.Build.0 = Release|Any CPU
{6B0C23EA-EC24-4FB0-948E-094E84AEBF21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
{4676AA1B-CC6C-42DC-BD69-6A293BAE8823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4676AA1B-CC6C-42DC-BD69-6A293BAE8823}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4676AA1B-CC6C-42DC-BD69-6A293BAE8823}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -39,6 +31,14 @@ Global
{8F77E155-9A91-4882-82E8-E8D69FECD246}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F77E155-9A91-4882-82E8-E8D69FECD246}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F77E155-9A91-4882-82E8-E8D69FECD246}.Release|Any CPU.Build.0 = Release|Any CPU
{F2636BCB-111D-4F22-AA06-8852E96D05C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2636BCB-111D-4F22-AA06-8852E96D05C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2636BCB-111D-4F22-AA06-8852E96D05C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2636BCB-111D-4F22-AA06-8852E96D05C4}.Release|Any CPU.Build.0 = Release|Any CPU
{96F4C65C-11B1-46F4-B343-115168688C2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96F4C65C-11B1-46F4-B343-115168688C2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96F4C65C-11B1-46F4-B343-115168688C2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96F4C65C-11B1-46F4-B343-115168688C2D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit bb81355

Please sign in to comment.