diff --git a/Shoko.Server/Models/SVR_AniDB_Anime.cs b/Shoko.Server/Models/SVR_AniDB_Anime.cs index b33cdf349..491d6a49d 100644 --- a/Shoko.Server/Models/SVR_AniDB_Anime.cs +++ b/Shoko.Server/Models/SVR_AniDB_Anime.cs @@ -260,10 +260,14 @@ public IReadOnlyList GetImages(ImageEntityType? entityType = nul } foreach (var xref in TmdbShowCrossReferences) images.AddRange(xref.GetImages(entityType, preferredImages)); + foreach (var xref in TmdbSeasonCrossReferences) + images.AddRange(xref.GetImages(entityType, preferredImages)); foreach (var xref in TmdbMovieCrossReferences) images.AddRange(xref.GetImages(entityType, preferredImages)); - return images; + return images + .DistinctBy(image => (image.ImageType, image.Source, image.ID)) + .ToList(); } #endregion @@ -299,6 +303,30 @@ public IReadOnlyList TmdbShowBackdrops .SelectMany(xref => RepoFactory.TMDB_Image.GetByTmdbShowIDAndType(xref.TmdbShowID, ImageEntityType.Backdrop)) .ToList(); + public IReadOnlyList TmdbEpisodeCrossReferences => RepoFactory.CrossRef_AniDB_TMDB_Episode.GetByAnidbAnimeID(AnimeID); + + public IReadOnlyList GetTmdbEpisodeCrossReferences(int? tmdbShowId = null) => tmdbShowId.HasValue + ? RepoFactory.CrossRef_AniDB_TMDB_Episode.GetOnlyByAnidbAnimeAndTmdbShowIDs(AnimeID, tmdbShowId.Value) + : RepoFactory.CrossRef_AniDB_TMDB_Episode.GetByAnidbAnimeID(AnimeID); + + public IReadOnlyList TmdbSeasonCrossReferences => + TmdbEpisodeCrossReferences + .Select(xref => xref.TmdbSeasonCrossReference) + .WhereNotNull() + .DistinctBy(xref => xref.TmdbSeasonID) + .ToList(); + + public IReadOnlyList TmdbSeasons => TmdbSeasonCrossReferences + .Select(xref => xref.TmdbSeason) + .WhereNotNull() + .ToList(); + + public IReadOnlyList GetTmdbSeasonCrossReferences(int? tmdbShowId = null) => + GetTmdbEpisodeCrossReferences(tmdbShowId) + .Select(xref => xref.TmdbSeasonCrossReference) + .WhereNotNull().Distinct() + .ToList(); + public IReadOnlyList TmdbMovieCrossReferences => RepoFactory.CrossRef_AniDB_TMDB_Movie.GetByAnidbAnimeID(AnimeID); diff --git a/Shoko.Server/Models/SVR_AniDB_Episode.cs b/Shoko.Server/Models/SVR_AniDB_Episode.cs index d3a7aa50f..87dc7d418 100644 --- a/Shoko.Server/Models/SVR_AniDB_Episode.cs +++ b/Shoko.Server/Models/SVR_AniDB_Episode.cs @@ -92,7 +92,9 @@ public IReadOnlyList GetImages(ImageEntityType? entityType = nul foreach (var tmdbMovie in TmdbMovies) images.AddRange(tmdbMovie.GetImages(entityType, preferredImages)); - return images; + return images + .DistinctBy(image => (image.ImageType, image.Source, image.ID)) + .ToList(); } #endregion diff --git a/Shoko.Server/Models/SVR_AnimeEpisode.cs b/Shoko.Server/Models/SVR_AnimeEpisode.cs index ff2bb259c..705672d2f 100644 --- a/Shoko.Server/Models/SVR_AnimeEpisode.cs +++ b/Shoko.Server/Models/SVR_AnimeEpisode.cs @@ -181,7 +181,9 @@ public IReadOnlyList GetImages(ImageEntityType? entityType = nul foreach (var xref in TmdbMovieCrossReferences) images.AddRange(xref.GetImages(entityType, preferredImages)); - return images; + return images + .DistinctBy(image => (image.ImageType, image.Source, image.ID)) + .ToList(); } #endregion diff --git a/Shoko.Server/Models/SVR_AnimeSeries.cs b/Shoko.Server/Models/SVR_AnimeSeries.cs index 10f754791..bce80c171 100644 --- a/Shoko.Server/Models/SVR_AnimeSeries.cs +++ b/Shoko.Server/Models/SVR_AnimeSeries.cs @@ -386,7 +386,9 @@ public IReadOnlyList GetImages(ImageEntityType? entityType = nul foreach (var xref in TmdbMovieCrossReferences.DistinctBy(xref => xref.TmdbMovieID)) images.AddRange(xref.GetImages(entityType, preferredImages)); - return images; + return images + .DistinctBy(image => (image.ImageType, image.Source, image.ID)) + .ToList(); } #endregion