From fe7c84fe84444cc00a86db18e4197bff64138cf3 Mon Sep 17 00:00:00 2001 From: JPVenson Date: Mon, 19 Jun 2023 16:00:39 +0300 Subject: [PATCH] Enriched Logging with series name (#84) --- .../Providers/TvdbEpisodeImageProvider.cs | 9 +++--- .../Providers/TvdbEpisodeProvider.cs | 12 ++++++-- .../Providers/TvdbMissingEpisodeProvider.cs | 2 +- .../Providers/TvdbPersonImageProvider.cs | 2 +- .../Providers/TvdbSeasonImageProvider.cs | 2 +- .../Providers/TvdbSeriesImageProvider.cs | 5 ++-- .../Providers/TvdbSeriesProvider.cs | 29 ++++++++++++------- 7 files changed, 39 insertions(+), 22 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeImageProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeImageProvider.cs index 61a75b6..70e93bb 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeImageProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeImageProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Net.Http; @@ -82,10 +82,11 @@ public async Task> GetImages(BaseItem item, Cancell if (string.IsNullOrEmpty(episodeTvdbId)) { _logger.LogError( - "Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}", + "Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}:{Name}", episode.ParentIndexNumber, episode.IndexNumber, - series.GetProviderId(TvdbPlugin.ProviderId)); + series.GetProviderId(TvdbPlugin.ProviderId), + series.Name); return imageResult; } @@ -102,7 +103,7 @@ await _tvdbClientManager } catch (TvDbServerException e) { - _logger.LogError(e, "Failed to retrieve episode images for series {TvDbId}", series.GetProviderId(TvdbPlugin.ProviderId)); + _logger.LogError(e, "Failed to retrieve episode images for series {TvDbId}:{Name}", series.GetProviderId(TvdbPlugin.ProviderId), series.Name); } } diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs index 0e10ad6..0f8acf6 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs @@ -168,10 +168,11 @@ private async Task> GetEpisode(EpisodeInfo searchInfo, C if (string.IsNullOrEmpty(episodeTvdbId)) { _logger.LogError( - "Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}", + "Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}:{Name}", searchInfo.ParentIndexNumber, searchInfo.IndexNumber, - seriesTvdbId); + seriesTvdbId, + searchInfo.Name); return result; } @@ -184,7 +185,12 @@ private async Task> GetEpisode(EpisodeInfo searchInfo, C } catch (TvDbServerException e) { - _logger.LogError(e, "Failed to retrieve episode with id {EpisodeTvDbId}, series id {SeriesTvdbId}", episodeTvdbId, seriesTvdbId); + _logger.LogError( + e, + "Failed to retrieve episode with id {EpisodeTvDbId}, series id {SeriesTvdbId}:{Name}", + episodeTvdbId, + seriesTvdbId, + searchInfo.Name); } return result; diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs index 209e56a..c9c2e2b 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs index 5227de6..f473b85 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs @@ -117,7 +117,7 @@ public Task GetImageResponse(string url, CancellationToken } catch (TvDbServerException e) { - _logger.LogError(e, "Failed to retrieve actor {ActorName} from series {SeriesTvdbId}", personName, tvdbId); + _logger.LogError(e, "Failed to retrieve actor {ActorName} from series {SeriesTvdbId}:{Name}", personName, tvdbId, series.Name); return null; } } diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeasonImageProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeasonImageProvider.cs index 86f8e63..630952d 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeasonImageProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeasonImageProvider.cs @@ -89,7 +89,7 @@ public async Task> GetImages(BaseItem item, Cancell } catch (TvDbServerException) { - _logger.LogDebug("No images of type {KeyType} found for series {TvdbId}", keyType, tvdbId); + _logger.LogDebug("No images of type {KeyType} found for series {TvdbId}:{Name}", keyType, tvdbId, item.Name); } } diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesImageProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesImageProvider.cs index 721449b..d1a1d5b 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesImageProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesImageProvider.cs @@ -87,9 +87,10 @@ await _tvdbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellati catch (TvDbServerException) { _logger.LogDebug( - "No images of type {KeyType} exist for series {TvDbId}", + "No images of type {KeyType} exist for series {TvDbId}:{Name}", keyType, - tvdbId); + tvdbId, + item.Name); } } diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs index 3bf793f..1571177 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs @@ -65,7 +65,7 @@ public async Task> GetMetadata(SeriesInfo info, Cancellat { var result = new MetadataResult { - QueriedById = true + QueriedById = true, }; if (!IsValidSeries(info.ProviderIds)) @@ -81,7 +81,7 @@ public async Task> GetMetadata(SeriesInfo info, Cancellat result.Item = new Series(); result.HasMetadata = true; - await FetchSeriesMetadata(result, info.MetadataLanguage, info.ProviderIds, cancellationToken) + await FetchSeriesMetadata(result, info, cancellationToken) .ConfigureAwait(false); } @@ -118,6 +118,7 @@ private async Task> FetchSeriesSearchResult(Seri imdbId, MetadataProvider.Imdb.ToString(), seriesInfo.MetadataLanguage, + seriesInfo.Name, cancellationToken).ConfigureAwait(false); } } @@ -131,6 +132,7 @@ private async Task> FetchSeriesSearchResult(Seri zap2ItId, MetadataProvider.Zap2It.ToString(), seriesInfo.MetadataLanguage, + seriesInfo.Name, cancellationToken).ConfigureAwait(false); } } @@ -145,7 +147,7 @@ await _tvdbClientManager } catch (TvDbServerException e) { - _logger.LogError(e, "Failed to retrieve series with id {TvdbId}", tvdbId); + _logger.LogError(e, "Failed to retrieve series with id {TvdbId}:{SeriesName}", tvdbId, seriesInfo.Name); return Array.Empty(); } } @@ -177,8 +179,13 @@ private RemoteSearchResult MapSeriesToRemoteSearchResult(TvDbSharper.Dto.Series return remoteResult; } - private async Task FetchSeriesMetadata(MetadataResult result, string metadataLanguage, Dictionary seriesProviderIds, CancellationToken cancellationToken) + private async Task FetchSeriesMetadata( + MetadataResult result, + SeriesInfo info, + CancellationToken cancellationToken) { + string metadataLanguage = info.MetadataLanguage; + Dictionary seriesProviderIds = info.ProviderIds; var series = result.Item; if (seriesProviderIds.TryGetValue(TvdbPlugin.ProviderId, out var tvdbId) && !string.IsNullOrEmpty(tvdbId)) @@ -193,6 +200,7 @@ private async Task FetchSeriesMetadata(MetadataResult result, string met imdbId, MetadataProvider.Imdb.ToString(), metadataLanguage, + info.Name, cancellationToken).ConfigureAwait(false); } @@ -203,6 +211,7 @@ private async Task FetchSeriesMetadata(MetadataResult result, string met zap2It, MetadataProvider.Zap2It.ToString(), metadataLanguage, + info.Name, cancellationToken).ConfigureAwait(false); } @@ -216,7 +225,7 @@ await _tvdbClientManager } catch (TvDbServerException e) { - _logger.LogError(e, "Failed to retrieve series with id {TvdbId}", tvdbId); + _logger.LogError(e, "Failed to retrieve series with id {TvdbId}:{SeriesName}", tvdbId, info.Name); return; } @@ -232,11 +241,11 @@ await _tvdbClientManager } catch (TvDbServerException e) { - _logger.LogError(e, "Failed to retrieve actors for series {TvdbId}", tvdbId); + _logger.LogError(e, "Failed to retrieve actors for series {TvdbId}:{SeriesName}", tvdbId, info.Name); } } - private async Task GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken) + private async Task GetSeriesByRemoteId(string id, string idType, string language, string seriesName, CancellationToken cancellationToken) { TvDbResponse? result = null; @@ -255,7 +264,7 @@ await _tvdbClientManager } catch (TvDbServerException e) { - _logger.LogError(e, "Failed to retrieve series with remote id {RemoteId}", id); + _logger.LogError(e, "Failed to retrieve series with remote id {RemoteId}:{SeriesName}", id, seriesName); } return result?.Data.FirstOrDefault()?.Id.ToString(CultureInfo.InvariantCulture); @@ -341,7 +350,7 @@ await _tvdbClientManager.GetSeriesByIdAsync(seriesSearchResult.Id, language, can } catch (TvDbServerException e) { - _logger.LogError(e, "Unable to retrieve series with id {TvdbId}", seriesSearchResult.Id); + _logger.LogError(e, "Unable to retrieve series with id {TvdbId}:{SeriesName}", seriesSearchResult.Id, seriesSearchResult.SeriesName); } remoteSearchResult.SetProviderId(TvdbPlugin.ProviderId, seriesSearchResult.Id.ToString(CultureInfo.InvariantCulture)); @@ -484,7 +493,7 @@ private async Task MapSeriesToResult(MetadataResult result, TvDbSharper. } catch (TvDbServerException e) { - _logger.LogError(e, "Failed to find series end date for series {TvdbId}", tvdbSeries.Id); + _logger.LogError(e, "Failed to find series end date for series {TvdbId}:{SeriesName}", tvdbSeries.Id, tvdbSeries?.SeriesName ?? result.Item?.Name); } } }