From 9ed4869ece7fb70473b9dd65c8b0c9bc3284f54e Mon Sep 17 00:00:00 2001 From: "Yannik S." Date: Fri, 28 Nov 2025 23:51:54 +0100 Subject: [PATCH] Add error handling to SetProgress calls --- Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs | 13 ++++++++++--- .../Tasks/JFToTubeArchivistProgressSyncTask.cs | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs b/Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs index 7321375..604ae19 100644 --- a/Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs +++ b/Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs @@ -172,10 +172,17 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata { long progress = (long)eventArgs.PlaybackPositionTicks / TimeSpan.TicksPerSecond; var videoId = Utils.GetVideoNameFromPath(eventArgs.Item.Path); - var statusCode = await TubeArchivistApi.GetInstance().SetProgress(videoId, progress).ConfigureAwait(true); - if (statusCode != System.Net.HttpStatusCode.OK) + try { - Logger.LogCritical("{Message}", $"POST /video/{videoId}/progress returned {statusCode} for video {eventArgs.Item.Name} with progress {progress} seconds"); + var statusCode = await TubeArchivistApi.GetInstance().SetProgress(videoId, progress).ConfigureAwait(true); + if (statusCode != System.Net.HttpStatusCode.OK) + { + Logger.LogCritical("{Message}", $"POST /video/{videoId}/progress returned {statusCode} for video {eventArgs.Item.Name} with progress {progress} seconds"); + } + } + catch (Exception ex) + { + Logger.LogCritical("An exception occurred while calling POST /video/{VideoId}/progress for for video {VideoName} with progress {Progress} seconds: {ExceptionMessage}", videoId, eventArgs.Item.Name, progress, ex.Message); } } } diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/Tasks/JFToTubeArchivistProgressSyncTask.cs b/Jellyfin.Plugin.TubeArchivistMetadata/Tasks/JFToTubeArchivistProgressSyncTask.cs index ee66c78..3e01948 100644 --- a/Jellyfin.Plugin.TubeArchivistMetadata/Tasks/JFToTubeArchivistProgressSyncTask.cs +++ b/Jellyfin.Plugin.TubeArchivistMetadata/Tasks/JFToTubeArchivistProgressSyncTask.cs @@ -201,10 +201,17 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Tasks var playbackProgress = _userDataManager.GetUserData(user, video)?.PlaybackPositionTicks / TimeSpan.TicksPerSecond; if (playbackProgress != null) { - statusCode = await taApi.SetProgress(videoYTId, playbackProgress.Value).ConfigureAwait(true); - if (statusCode != System.Net.HttpStatusCode.OK) + try { - _logger.LogCritical("{Message}", $"POST /video/{videoYTId}/progress returned {statusCode} for video {video.Name} with progress {progress} seconds"); + statusCode = await taApi.SetProgress(videoYTId, playbackProgress.Value).ConfigureAwait(true); + if (statusCode != System.Net.HttpStatusCode.OK) + { + _logger.LogCritical("{Message}", $"POST /video/{videoYTId}/progress returned {statusCode} for video {video.Name} with progress {progress} seconds"); + } + } + catch (Exception ex) + { + _logger.LogCritical("An exception occurred while calling POST /video/{VideoId}/progress for for video {VideoName} with progress {Progress} seconds: {ExceptionMessage}", videoYTId, videoYTId, playbackProgress.Value, ex.Message); } } }