Skip to content

Commit

Permalink
upgrade dependencies, support jellyfin 10.8 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
kookxiang committed May 7, 2022
1 parent a31daef commit aa19748
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
18 changes: 10 additions & 8 deletions Jellyfin.Plugin.Bangumi.Test/Jellyfin.Plugin.Bangumi.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>

<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.2.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4"/>
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3"/>
<PackageReference Include="MSTest.TestFramework" Version="2.2.3"/>
<PackageReference Include="coverlet.collector" Version="3.0.2"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0"/>
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10"/>
<PackageReference Include="MSTest.TestFramework" Version="2.2.10"/>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Jellyfin.Plugin.Bangumi\Jellyfin.Plugin.Bangumi.csproj"/>
</ItemGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Bangumi/BangumiApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public BangumiApi(Plugin plugin)

public async Task<List<Subject>> SearchSubject(string keyword, CancellationToken token)
{
var jsonString = await SendRequest($"https://api.bgm.tv/search/subject/{Uri.EscapeUriString(keyword)}?type=2", token);
var jsonString = await SendRequest($"https://api.bgm.tv/search/subject/{Uri.EscapeDataString(keyword)}?type=2", token);
var searchResult = JsonSerializer.Deserialize<SearchResult<Subject>>(jsonString, _options);
return searchResult?.List ?? new List<Subject>();
}
Expand Down
10 changes: 5 additions & 5 deletions Jellyfin.Plugin.Bangumi/Jellyfin.Plugin.Bangumi.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.Bangumi</RootNamespace>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.7.7"/>
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="5.0.3"/>
<PackageReference Include="Jellyfin.Controller" Version="10.*-*"/>
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="6.0.4"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0"/>
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0"/>
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0"/>
</ItemGroup>

<ItemGroup>
Expand All @@ -23,4 +23,4 @@
<ItemGroup>
<InternalsVisibleTo Include="Jellyfin.Plugin.Bangumi.Test"/>
</ItemGroup>
</Project>
</Project>
16 changes: 11 additions & 5 deletions Jellyfin.Plugin.Bangumi/OAuth/OAuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public OAuthController(BangumiApi api, OAuthStore store, ISessionContext session
[Authorize("DefaultAuthorization")]
public async Task<Dictionary<string, object?>?> OAuthState()
{
var user = _sessionContext.GetUser(Request);
var user = await _sessionContext.GetUser(Request);
if (user == null)
return null;
var info = _store.Get(user.Id);
if (info == null)
return null;
Expand All @@ -59,7 +61,9 @@ public OAuthController(BangumiApi api, OAuthStore store, ISessionContext session
[Authorize("DefaultAuthorization")]
public async Task<ActionResult> RefreshOAuthToken()
{
var user = _sessionContext.GetUser(Request);
var user = await _sessionContext.GetUser(Request);
if (user == null)
return BadRequest();
var info = _store.Get(user.Id);
if (info == null)
return BadRequest();
Expand All @@ -71,9 +75,11 @@ public async Task<ActionResult> RefreshOAuthToken()

[HttpDelete("OAuth")]
[Authorize("DefaultAuthorization")]
public AcceptedResult DeAuth()
public async Task<ActionResult> DeAuth()
{
var user = _sessionContext.GetUser(Request);
var user = await _sessionContext.GetUser(Request);
if (user == null)
return BadRequest();
_store.Delete(user.Id);
_store.Save();
return Accepted();
Expand All @@ -89,7 +95,7 @@ public AcceptedResult DeAuth()
new KeyValuePair<string, string>("client_secret", ApplicationSecret),
new KeyValuePair<string, string>("code", code),
new KeyValuePair<string, string>("redirect_uri", $"{Request.Scheme}://{Request.Host}{Request.Path}?user={user}")
}!);
});
var response = await _plugin.GetHttpClient().PostAsync("https://bgm.tv/oauth/access_token", formData);
var responseBody = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) return JsonSerializer.Deserialize<OAuthError>(responseBody);
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Bangumi/OAuth/TokenRefreshTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public TokenRefreshTask(IActivityManager activity, INotificationManager notifica
public string Description => "OAuth 授权令牌到期前自动刷新";
public string Category => "Bangumi";

public async Task Execute(CancellationToken token, IProgress<double> progress)
public async Task ExecuteAsync(IProgress<double> progress, CancellationToken token)
{
var users = _store.GetUsers();
var current = 0d;
Expand Down

0 comments on commit aa19748

Please sign in to comment.