From 6d8ee4eb7aef681192f01d50e9bab61df4cff697 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Mon, 25 Mar 2024 17:53:42 -0600 Subject: [PATCH] 10.9 --- .../API/OpenSubtitlesController.cs | 2 +- .../Jellyfin.Plugin.OpenSubtitles.csproj | 4 ++-- .../OpenSubtitleDownloader.cs | 5 +---- .../OpenSubtitlesHandler/OpenSubtitles.cs | 15 +++------------ .../OpenSubtitlesHandler/RequestHandler.cs | 6 +----- build.yaml | 4 ++-- .../Jellyfin.Plugin.OpenSubtitles.Tests.csproj | 2 +- 7 files changed, 11 insertions(+), 27 deletions(-) diff --git a/Jellyfin.Plugin.OpenSubtitles/API/OpenSubtitlesController.cs b/Jellyfin.Plugin.OpenSubtitles/API/OpenSubtitlesController.cs index 8307ecb..cdff0bf 100644 --- a/Jellyfin.Plugin.OpenSubtitles/API/OpenSubtitlesController.cs +++ b/Jellyfin.Plugin.OpenSubtitles/API/OpenSubtitlesController.cs @@ -15,7 +15,7 @@ namespace Jellyfin.Plugin.OpenSubtitles.API /// [ApiController] [Produces(MediaTypeNames.Application.Json)] - [Authorize(Policy = "DefaultAuthorization")] + [Authorize] public class OpenSubtitlesController : ControllerBase { /// diff --git a/Jellyfin.Plugin.OpenSubtitles/Jellyfin.Plugin.OpenSubtitles.csproj b/Jellyfin.Plugin.OpenSubtitles/Jellyfin.Plugin.OpenSubtitles.csproj index b47f3ab..b6b8e63 100644 --- a/Jellyfin.Plugin.OpenSubtitles/Jellyfin.Plugin.OpenSubtitles.csproj +++ b/Jellyfin.Plugin.OpenSubtitles/Jellyfin.Plugin.OpenSubtitles.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true true enable @@ -19,7 +19,7 @@ - + diff --git a/Jellyfin.Plugin.OpenSubtitles/OpenSubtitleDownloader.cs b/Jellyfin.Plugin.OpenSubtitles/OpenSubtitleDownloader.cs index c7634c6..6ae8a13 100644 --- a/Jellyfin.Plugin.OpenSubtitles/OpenSubtitleDownloader.cs +++ b/Jellyfin.Plugin.OpenSubtitles/OpenSubtitleDownloader.cs @@ -82,10 +82,7 @@ namespace Jellyfin.Plugin.OpenSubtitles /// public async Task> Search(SubtitleSearchRequest request, CancellationToken cancellationToken) { - if (request == null) - { - throw new ArgumentNullException(nameof(request)); - } + ArgumentNullException.ThrowIfNull(request); await Login(cancellationToken).ConfigureAwait(false); diff --git a/Jellyfin.Plugin.OpenSubtitles/OpenSubtitlesHandler/OpenSubtitles.cs b/Jellyfin.Plugin.OpenSubtitles/OpenSubtitlesHandler/OpenSubtitles.cs index 2aa786f..8af1c52 100644 --- a/Jellyfin.Plugin.OpenSubtitles/OpenSubtitlesHandler/OpenSubtitles.cs +++ b/Jellyfin.Plugin.OpenSubtitles/OpenSubtitlesHandler/OpenSubtitles.cs @@ -39,10 +39,7 @@ namespace Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler /// logout status. public static async Task 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 { { "Authorization", user.Token } }; @@ -60,10 +57,7 @@ namespace Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler /// The encapsulated user info. public static async Task> 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 { { "Authorization", user.Token } }; @@ -82,10 +76,7 @@ namespace Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler /// The subtitle download info. public static async Task> 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 { { "Authorization", user.Token } }; diff --git a/Jellyfin.Plugin.OpenSubtitles/OpenSubtitlesHandler/RequestHandler.cs b/Jellyfin.Plugin.OpenSubtitles/OpenSubtitlesHandler/RequestHandler.cs index 0f65747..46521c3 100644 --- a/Jellyfin.Plugin.OpenSubtitles/OpenSubtitlesHandler/RequestHandler.cs +++ b/Jellyfin.Plugin.OpenSubtitles/OpenSubtitlesHandler/RequestHandler.cs @@ -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); diff --git a/build.yaml b/build.yaml index 6de7627..3bb8d62 100644 --- a/build.yaml +++ b/build.yaml @@ -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." diff --git a/tests/Jellyfin.Plugin.OpenSubtitles.Tests/Jellyfin.Plugin.OpenSubtitles.Tests.csproj b/tests/Jellyfin.Plugin.OpenSubtitles.Tests/Jellyfin.Plugin.OpenSubtitles.Tests.csproj index eda0b31..3deaf5f 100644 --- a/tests/Jellyfin.Plugin.OpenSubtitles.Tests/Jellyfin.Plugin.OpenSubtitles.Tests.csproj +++ b/tests/Jellyfin.Plugin.OpenSubtitles.Tests/Jellyfin.Plugin.OpenSubtitles.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable false