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

Display order change fix, Cache collision fix, restrict airsbefore/after to aired display order #143

Merged
merged 5 commits into from
May 22, 2024
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
13 changes: 9 additions & 4 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private async Task<MetadataResult<Episode>> GetEpisode(EpisodeInfo searchInfo, C
var episodeTvdbId = searchInfo.GetTvdbId().ToString(CultureInfo.InvariantCulture);
try
{
if (string.Equals(episodeTvdbId, "0", StringComparison.OrdinalIgnoreCase) || ignoreTvdbIdField)
if (string.Equals(episodeTvdbId, "0", StringComparison.OrdinalIgnoreCase) || ignoreTvdbIdField || searchInfo.IsAutomated)
{
episodeTvdbId = await _tvdbClientManager
.GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken)
Expand Down Expand Up @@ -215,9 +215,6 @@ private async Task<MetadataResult<Episode>> MapEpisodeToResult(EpisodeInfo id, E
IndexNumber = id.IndexNumber,
ParentIndexNumber = id.ParentIndexNumber,
IndexNumberEnd = id.IndexNumberEnd,
AirsBeforeEpisodeNumber = episode.AirsBeforeEpisode,
AirsAfterSeasonNumber = episode.AirsAfterSeason,
AirsBeforeSeasonNumber = episode.AirsBeforeSeason,
// Tvdb uses 3 letter code for language (prob ISO 639-2)
// Reverts to OriginalName if no translation is found
Name = episode.Translations.GetTranslatedNamedOrDefault(id.MetadataLanguage) ?? episode.Name,
Expand All @@ -232,6 +229,14 @@ private async Task<MetadataResult<Episode>> MapEpisodeToResult(EpisodeInfo id, E
var imdbID = episode.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "IMDB", StringComparison.OrdinalIgnoreCase))?.Id;
item.SetProviderIdIfHasValue(MetadataProvider.Imdb, imdbID);

// Below metadata info only applicable for Aired Order
if (string.IsNullOrEmpty(id.SeriesDisplayOrder))
{
item.AirsBeforeEpisodeNumber = episode.AirsBeforeEpisode;
item.AirsAfterSeasonNumber = episode.AirsAfterSeason;
item.AirsBeforeSeasonNumber = episode.AirsBeforeSeason;
}

// Missing episodes loses the episode number when refreshed.
if (id.IsMissingEpisode)
{
Expand Down
12 changes: 9 additions & 3 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,21 @@ private void AddVirtualEpisode(EpisodeBaseRecord? episode, Season? season)
IsVirtualItem = true,
SeasonId = season.Id,
SeriesId = season.Series.Id,
AirsBeforeEpisodeNumber = episode.AirsBeforeEpisode,
AirsAfterSeasonNumber = episode.AirsAfterSeason,
AirsBeforeSeasonNumber = episode.AirsBeforeSeason,
Overview = episode.Overview,
SeriesName = season.Series.Name,
SeriesPresentationUniqueKey = season.SeriesPresentationUniqueKey,
SeasonName = season.Name,
DateLastSaved = DateTime.UtcNow
};

// Below metadata info only applicable for Aired Order
if (string.IsNullOrEmpty(season.Series.DisplayOrder))
{
newEpisode.AirsBeforeEpisodeNumber = episode.AirsBeforeEpisode;
newEpisode.AirsAfterSeasonNumber = episode.AirsAfterSeason;
newEpisode.AirsBeforeSeasonNumber = episode.AirsBeforeSeason;
}

if (DateTime.TryParse(episode!.Aired, out var premiereDate))
{
newEpisode.PremiereDate = premiereDate;
Expand Down
1 change: 1 addition & 0 deletions Jellyfin.Plugin.Tvdb/ScheduledTasks/UpdateTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public async Task ExecuteAsync(IProgress<double> progress, CancellationToken can
{
MetadataRefreshMode = MetadataRefreshMode.FullRefresh,
ReplaceAllMetadata = true,
IsAutomated = false,
};
double increment = 90.0 / toUpdateItems.Count;
double currentProgress = 10;
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/TvdbClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@
break;
}

key = $"FindTvdbEpisodeId_{seriesTvdbIdString}_{seasonNumber.Value.ToString(CultureInfo.InvariantCulture)}_{episodeNumber.Value.ToString(CultureInfo.InvariantCulture)}";
key = $"FindTvdbEpisodeId_{seriesTvdbIdString}_{seasonNumber.Value.ToString(CultureInfo.InvariantCulture)}_{episodeNumber.Value.ToString(CultureInfo.InvariantCulture)}_{searchInfo.SeriesDisplayOrder}";
scampower3 marked this conversation as resolved.
Show resolved Hide resolved
}
else if (searchInfo.PremiereDate.HasValue)
{
Expand Down