This commit is contained in:
Cody Robibero 2024-03-25 17:53:42 -06:00
parent 24d30df23e
commit 6d8ee4eb7a
7 changed files with 11 additions and 27 deletions

View File

@ -15,7 +15,7 @@ namespace Jellyfin.Plugin.OpenSubtitles.API
/// </summary>
[ApiController]
[Produces(MediaTypeNames.Application.Json)]
[Authorize(Policy = "DefaultAuthorization")]
[Authorize]
public class OpenSubtitlesController : ControllerBase
{
/// <summary>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
@ -19,7 +19,7 @@
<ItemGroup>
<PackageReference Include="Jellyfin.Common" Version="10.*-*" />
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

View File

@ -82,10 +82,7 @@ namespace Jellyfin.Plugin.OpenSubtitles
/// <inheritdoc />
public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
{
if (request == null)
{
throw new ArgumentNullException(nameof(request));
}
ArgumentNullException.ThrowIfNull(request);
await Login(cancellationToken).ConfigureAwait(false);

View File

@ -39,10 +39,7 @@ namespace Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler
/// <returns>logout status.</returns>
public static async Task<bool> LogOutAsync(LoginInfo user, string apiKey, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(user.Token))
{
throw new ArgumentNullException(nameof(user.Token), "Token is null or empty");
}
ArgumentException.ThrowIfNullOrEmpty(user.Token);
var headers = new Dictionary<string, string> { { "Authorization", user.Token } };
@ -60,10 +57,7 @@ namespace Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler
/// <returns>The encapsulated user info.</returns>
public static async Task<ApiResponse<EncapsulatedUserInfo>> GetUserInfo(LoginInfo user, string apiKey, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(user.Token))
{
throw new ArgumentNullException(nameof(user.Token), "Token is null or empty");
}
ArgumentException.ThrowIfNullOrEmpty(user.Token);
var headers = new Dictionary<string, string> { { "Authorization", user.Token } };
@ -82,10 +76,7 @@ namespace Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler
/// <returns>The subtitle download info.</returns>
public static async Task<ApiResponse<SubtitleDownloadInfo>> GetSubtitleLinkAsync(int file, LoginInfo user, string apiKey, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(user.Token))
{
throw new ArgumentNullException(nameof(user.Token), "Token is null or empty");
}
ArgumentException.ThrowIfNullOrEmpty(user.Token);
var headers = new Dictionary<string, string> { { "Authorization", user.Token } };

View File

@ -53,11 +53,7 @@ namespace Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler
throw new ArgumentException("Provided API key is blank", nameof(apiKey));
}
if (!headers.ContainsKey("Api-Key"))
{
headers.Add("Api-Key", apiKey);
}
headers.TryAdd("Api-Key", apiKey);
if (_hRemaining == 0)
{
await Task.Delay(1000 * _hReset, cancellationToken).ConfigureAwait(false);

View File

@ -2,8 +2,8 @@ name: "Open Subtitles"
guid: "4b9ed42f-5185-48b5-9803-6ff2989014c4"
imageUrl: "https://repo.jellyfin.org/releases/plugin/images/jellyfin-plugin-opensubtitles.png"
version: 19
targetAbi: "10.8.10.0"
framework: "net6.0"
targetAbi: "10.9.0.0"
framework: "net8.0"
owner: "jellyfin"
overview: "Download subtitles for your media"
description: "Download subtitles from the internet to use with your media files."

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>