From d8b09f6e094a151fd14ec28c877804fd69a89387 Mon Sep 17 00:00:00 2001 From: kookxiang Date: Wed, 28 Aug 2024 22:37:54 +0800 Subject: [PATCH] fix warning --- .../Providers/MusicSongProvider.cs | 2 +- .../ScheduledTask/RatingRefreshTask.cs | 1 + .../ScheduledTask/TokenRefreshTask.cs | 18 ++++++++---------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Jellyfin.Plugin.Bangumi/Providers/MusicSongProvider.cs b/Jellyfin.Plugin.Bangumi/Providers/MusicSongProvider.cs index c87593b..ed9eeba 100644 --- a/Jellyfin.Plugin.Bangumi/Providers/MusicSongProvider.cs +++ b/Jellyfin.Plugin.Bangumi/Providers/MusicSongProvider.cs @@ -69,7 +69,7 @@ public async Task GetImageResponse(string url, Cancellation if (string.IsNullOrEmpty(fileName)) return null; - var album = libraryManager.FindByPath(info.Path, false).FindParent(); + var album = libraryManager.FindByPath(info.Path, false)?.FindParent(); if (album is null) return null; diff --git a/Jellyfin.Plugin.Bangumi/ScheduledTask/RatingRefreshTask.cs b/Jellyfin.Plugin.Bangumi/ScheduledTask/RatingRefreshTask.cs index d00caa8..a4b4cd0 100644 --- a/Jellyfin.Plugin.Bangumi/ScheduledTask/RatingRefreshTask.cs +++ b/Jellyfin.Plugin.Bangumi/ScheduledTask/RatingRefreshTask.cs @@ -59,6 +59,7 @@ public async Task ExecuteAsync(IProgress progress, CancellationToken tok // obtain library item var item = library.GetItemById(id); + if (item == null) continue; // skip item if it was refreshed recently #if EMBY diff --git a/Jellyfin.Plugin.Bangumi/ScheduledTask/TokenRefreshTask.cs b/Jellyfin.Plugin.Bangumi/ScheduledTask/TokenRefreshTask.cs index 53be688..7a722cb 100644 --- a/Jellyfin.Plugin.Bangumi/ScheduledTask/TokenRefreshTask.cs +++ b/Jellyfin.Plugin.Bangumi/ScheduledTask/TokenRefreshTask.cs @@ -1,22 +1,20 @@ - +#if EMBY +using MediaBrowser.Model.Logging; +#else +using Microsoft.Extensions.Logging; +using Jellyfin.Data.Entities; +#endif using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Jellyfin.Plugin.Bangumi.OAuth; -using MediaBrowser.Controller.Library; using MediaBrowser.Model.Activity; using MediaBrowser.Model.Tasks; -#if EMBY -using MediaBrowser.Model.Logging; -#else -using Microsoft.Extensions.Logging; -using Jellyfin.Data.Entities; -#endif namespace Jellyfin.Plugin.Bangumi.ScheduledTask; -public class TokenRefreshTask(IUserManager userManager, IActivityManager activity, BangumiApi api, OAuthStore store) +public class TokenRefreshTask(IActivityManager activity, BangumiApi api, OAuthStore store) : IScheduledTask { public string Key => "OAuthTokenRefreshTask"; @@ -55,7 +53,6 @@ public async Task ExecuteAsync(IProgress progress, CancellationToken tok var total = users.Count; foreach (var (guid, user) in users) { - var userId = Guid.Parse(guid); token.ThrowIfCancellationRequested(); progress.Report(current / total); current++; @@ -83,6 +80,7 @@ public async Task ExecuteAsync(IProgress progress, CancellationToken tok activity.Create(activityLogEntry); #else + var userId = Guid.Parse(guid); var activityLog = new ActivityLog("Bangumi 授权", "Bangumi", userId); try {