From 11eb456c56047d54df0f73af66db076507081b75 Mon Sep 17 00:00:00 2001 From: DarkFighterLuke Date: Sat, 22 Feb 2025 15:37:33 +0100 Subject: [PATCH] Fix JF crash when setting watched status with TA offline --- Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs | 13 ++++++++++--- build.yaml | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs b/Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs index d3f3881..386948b 100644 --- a/Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs +++ b/Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs @@ -199,10 +199,17 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata return; } - var statusCode = await TubeArchivistApi.GetInstance().SetWatchedStatus(itemYTId, isPlayed).ConfigureAwait(true); - if (statusCode != System.Net.HttpStatusCode.OK) + try { - Logger.LogCritical("POST /watched returned {StatusCode} for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}", statusCode, eventArgs.Item.Name, itemYTId, isPlayed); + var statusCode = await TubeArchivistApi.GetInstance().SetWatchedStatus(itemYTId, isPlayed).ConfigureAwait(true); + if (statusCode != System.Net.HttpStatusCode.OK) + { + Logger.LogCritical("POST /watched returned {StatusCode} for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}", statusCode, eventArgs.Item.Name, itemYTId, isPlayed); + } + } + catch (Exception ex) + { + Logger.LogCritical("An exception occurred while calling POST /watched for item {ItemName} ({VideoYTId}) with watched status {IsPlayed}: {ExceptionMessage}", eventArgs.Item.Name, itemYTId, isPlayed, ex.Message); } } } diff --git a/build.yaml b/build.yaml index 100e397..4c79ed1 100644 --- a/build.yaml +++ b/build.yaml @@ -15,3 +15,4 @@ artifacts: - "Jellyfin.Plugin.TubeArchivistMetadata.dll" changelog: > Adapt to the new TA API changes + Fix JF crash when setting watched status with TA offline