From 94d6358b232e5e4bb352544d210817b64eb9e4b4 Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Sat, 14 Dec 2024 19:36:49 +0100 Subject: [PATCH] feat: expose direct props to get tmdb entities through the abstraction --- .../DataModels/Shoko/IShokoEpisode.cs | 10 ++++ .../DataModels/Shoko/IShokoSeries.cs | 12 ++++- .../Shoko.Plugin.Abstractions.csproj | 2 +- Shoko.Server/Models/SVR_AnimeEpisode.cs | 46 ++++++++++--------- Shoko.Server/Models/SVR_AnimeSeries.cs | 10 ++-- 5 files changed, 54 insertions(+), 26 deletions(-) diff --git a/Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoEpisode.cs b/Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoEpisode.cs index 09a962a5f..d91f508bc 100644 --- a/Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoEpisode.cs +++ b/Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoEpisode.cs @@ -27,6 +27,16 @@ public interface IShokoEpisode : IEpisode /// IEpisode AnidbEpisode { get; } + /// + /// A direct link to all tmdb episodes linked to the shoko episode. + /// + IReadOnlyList TmdbEpisodes { get; } + + /// + /// A direct link to all tmdb movies linked to the shoko episode. + /// + IReadOnlyList TmdbMovies { get; } + /// /// All episodes linked to this shoko episode. /// diff --git a/Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoSeries.cs b/Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoSeries.cs index d09a60e63..4e73aa9f7 100644 --- a/Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoSeries.cs +++ b/Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoSeries.cs @@ -23,10 +23,20 @@ public interface IShokoSeries : ISeries int TopLevelGroupID { get; } /// - /// A direct link to the anidb series metadata. + /// A direct link to the anidb anime metadata. /// ISeries AnidbAnime { get; } + /// + /// A direct link to all tmdb shows linked to the shoko series. + /// + IReadOnlyList TmdbShows { get; } + + /// + /// A direct link to all tmdb movies linked to the shoko series. + /// + IReadOnlyList TmdbMovies { get; } + /// /// All series linked to this shoko series. /// diff --git a/Shoko.Plugin.Abstractions/Shoko.Plugin.Abstractions.csproj b/Shoko.Plugin.Abstractions/Shoko.Plugin.Abstractions.csproj index b605d43cc..d80d20b0e 100644 --- a/Shoko.Plugin.Abstractions/Shoko.Plugin.Abstractions.csproj +++ b/Shoko.Plugin.Abstractions/Shoko.Plugin.Abstractions.csproj @@ -13,7 +13,7 @@ https://github.com/ShokoAnime/ShokoServer plugins, shoko, anime, metadata, tagging Renamer Rewrite - 4.1.0-beta2 + 4.1.0-beta3 Debug;Release;Benchmarks AnyCPU;x64 false diff --git a/Shoko.Server/Models/SVR_AnimeEpisode.cs b/Shoko.Server/Models/SVR_AnimeEpisode.cs index 705672d2f..4a60fe2e3 100644 --- a/Shoko.Server/Models/SVR_AnimeEpisode.cs +++ b/Shoko.Server/Models/SVR_AnimeEpisode.cs @@ -330,6 +330,31 @@ IReadOnlyList IWithTitles.Titles IReadOnlyList IEpisode.ShokoEpisodes => [this]; + IReadOnlyList IEpisode.CrossReferences => + RepoFactory.CrossRef_File_Episode.GetByEpisodeID(AniDB_EpisodeID); + + IReadOnlyList IEpisode.VideoList => + RepoFactory.CrossRef_File_Episode.GetByEpisodeID(AniDB_EpisodeID) + .DistinctBy(xref => xref.Hash) + .Select(xref => xref.VideoLocal) + .WhereNotNull() + .ToList(); + + #endregion + + #region IShokoEpisode Implementation + + int IShokoEpisode.AnidbEpisodeID => AniDB_EpisodeID; + + IShokoSeries? IShokoEpisode.Series => AnimeSeries; + + IEpisode IShokoEpisode.AnidbEpisode => AniDB_Episode ?? + throw new NullReferenceException($"Unable to find AniDB Episode {AniDB_EpisodeID} for AnimeEpisode {AnimeEpisodeID}"); + + IReadOnlyList IShokoEpisode.TmdbEpisodes => TmdbEpisodes; + + IReadOnlyList IShokoEpisode.TmdbMovies => TmdbMovies; + IReadOnlyList IShokoEpisode.LinkedEpisodes { get @@ -362,26 +387,5 @@ IReadOnlyList IShokoEpisode.LinkedMovies } } - IReadOnlyList IEpisode.CrossReferences => - RepoFactory.CrossRef_File_Episode.GetByEpisodeID(AniDB_EpisodeID); - - IReadOnlyList IEpisode.VideoList => - RepoFactory.CrossRef_File_Episode.GetByEpisodeID(AniDB_EpisodeID) - .DistinctBy(xref => xref.Hash) - .Select(xref => xref.VideoLocal) - .WhereNotNull() - .ToList(); - - #endregion - - #region IShokoEpisode Implementation - - int IShokoEpisode.AnidbEpisodeID => AniDB_EpisodeID; - - IShokoSeries? IShokoEpisode.Series => AnimeSeries; - - IEpisode IShokoEpisode.AnidbEpisode => AniDB_Episode ?? - throw new NullReferenceException($"Unable to find AniDB Episode {AniDB_EpisodeID} for AnimeEpisode {AnimeEpisodeID}"); - #endregion } diff --git a/Shoko.Server/Models/SVR_AnimeSeries.cs b/Shoko.Server/Models/SVR_AnimeSeries.cs index bce80c171..8a9471601 100644 --- a/Shoko.Server/Models/SVR_AnimeSeries.cs +++ b/Shoko.Server/Models/SVR_AnimeSeries.cs @@ -648,15 +648,18 @@ public override string ToString() int IShokoSeries.TopLevelGroupID => TopLevelAnimeGroup.AnimeGroupID; - ISeries IShokoSeries.AnidbAnime => AniDB_Anime ?? - throw new NullReferenceException($"Unable to find AniDB anime with id {AniDB_ID} in IShokoSeries.AnidbAnime"); - IShokoGroup IShokoSeries.ParentGroup => AnimeGroup; IShokoGroup IShokoSeries.TopLevelGroup => TopLevelAnimeGroup; IReadOnlyList IShokoSeries.AllParentGroups => AllGroupsAbove; + ISeries IShokoSeries.AnidbAnime => AniDB_Anime ?? + throw new NullReferenceException($"Unable to find AniDB anime with id {AniDB_ID} in IShokoSeries.AnidbAnime"); + + IReadOnlyList IShokoSeries.TmdbShows => TmdbShows; + + IReadOnlyList IShokoSeries.TmdbMovies => TmdbMovies; IReadOnlyList IShokoSeries.LinkedSeries { @@ -675,6 +678,7 @@ IReadOnlyList IShokoSeries.LinkedSeries return seriesList; } } + IReadOnlyList IShokoSeries.LinkedMovies { get