Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enriched Logging with series name #84

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeImageProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
Expand Down Expand Up @@ -82,10 +82,11 @@ public async Task<IEnumerable<RemoteImageInfo>> 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;
}

Expand All @@ -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);
}
}

Expand Down
12 changes: 9 additions & 3 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ private async Task<MetadataResult<Episode>> 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;
}

Expand All @@ -131,7 +132,12 @@ private async Task<MetadataResult<Episode>> 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
Copy link
Member

@TimGels TimGels Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this using is now needed? nvm it was already there

using System.Collections.Generic;
using System.Globalization;
using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Task<HttpResponseMessage> 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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbSeasonImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public async Task<IEnumerable<RemoteImageInfo>> 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);
}
}

Expand Down
5 changes: 3 additions & 2 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
29 changes: 19 additions & 10 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, Cancellat
{
var result = new MetadataResult<Series>
{
QueriedById = true
QueriedById = true,
};

if (!IsValidSeries(info.ProviderIds))
Expand All @@ -81,7 +81,7 @@ public async Task<MetadataResult<Series>> 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);
}

Expand Down Expand Up @@ -118,6 +118,7 @@ private async Task<IEnumerable<RemoteSearchResult>> FetchSeriesSearchResult(Seri
imdbId,
MetadataProvider.Imdb.ToString(),
seriesInfo.MetadataLanguage,
seriesInfo.Name,
cancellationToken).ConfigureAwait(false);
}
}
Expand All @@ -131,6 +132,7 @@ private async Task<IEnumerable<RemoteSearchResult>> FetchSeriesSearchResult(Seri
zap2ItId,
MetadataProvider.Zap2It.ToString(),
seriesInfo.MetadataLanguage,
seriesInfo.Name,
cancellationToken).ConfigureAwait(false);
}
}
Expand All @@ -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<RemoteSearchResult>();
}
}
Expand Down Expand Up @@ -177,8 +179,13 @@ private RemoteSearchResult MapSeriesToRemoteSearchResult(TvDbSharper.Dto.Series
return remoteResult;
}

private async Task FetchSeriesMetadata(MetadataResult<Series> result, string metadataLanguage, Dictionary<string, string> seriesProviderIds, CancellationToken cancellationToken)
private async Task FetchSeriesMetadata(
MetadataResult<Series> result,
SeriesInfo info,
CancellationToken cancellationToken)
{
string metadataLanguage = info.MetadataLanguage;
Dictionary<string, string> seriesProviderIds = info.ProviderIds;
var series = result.Item;

if (seriesProviderIds.TryGetValue(TvdbPlugin.ProviderId, out var tvdbId) && !string.IsNullOrEmpty(tvdbId))
Expand All @@ -193,6 +200,7 @@ private async Task FetchSeriesMetadata(MetadataResult<Series> result, string met
imdbId,
MetadataProvider.Imdb.ToString(),
metadataLanguage,
info.Name,
cancellationToken).ConfigureAwait(false);
}

Expand All @@ -203,6 +211,7 @@ private async Task FetchSeriesMetadata(MetadataResult<Series> result, string met
zap2It,
MetadataProvider.Zap2It.ToString(),
metadataLanguage,
info.Name,
cancellationToken).ConfigureAwait(false);
}

Expand All @@ -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;
}

Expand All @@ -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<string?> GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken)
private async Task<string?> GetSeriesByRemoteId(string id, string idType, string language, string seriesName, CancellationToken cancellationToken)
{
TvDbResponse<SeriesSearchResult[]>? result = null;

Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -484,7 +493,7 @@ private async Task MapSeriesToResult(MetadataResult<Series> 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);
}
}
}
Expand Down