Skip to content

Commit

Permalink
feat: expose direct props to get tmdb entities through the abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Dec 14, 2024
1 parent 55fd02d commit 94d6358
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 26 deletions.
10 changes: 10 additions & 0 deletions Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoEpisode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ public interface IShokoEpisode : IEpisode
/// </summary>
IEpisode AnidbEpisode { get; }

/// <summary>
/// A direct link to all tmdb episodes linked to the shoko episode.
/// </summary>
IReadOnlyList<IEpisode> TmdbEpisodes { get; }

/// <summary>
/// A direct link to all tmdb movies linked to the shoko episode.
/// </summary>
IReadOnlyList<IMovie> TmdbMovies { get; }

/// <summary>
/// All episodes linked to this shoko episode.
/// </summary>
Expand Down
12 changes: 11 additions & 1 deletion Shoko.Plugin.Abstractions/DataModels/Shoko/IShokoSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,20 @@ public interface IShokoSeries : ISeries
int TopLevelGroupID { get; }

/// <summary>
/// A direct link to the anidb series metadata.
/// A direct link to the anidb anime metadata.
/// </summary>
ISeries AnidbAnime { get; }

/// <summary>
/// A direct link to all tmdb shows linked to the shoko series.
/// </summary>
IReadOnlyList<ISeries> TmdbShows { get; }

/// <summary>
/// A direct link to all tmdb movies linked to the shoko series.
/// </summary>
IReadOnlyList<IMovie> TmdbMovies { get; }

/// <summary>
/// All series linked to this shoko series.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Shoko.Plugin.Abstractions/Shoko.Plugin.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<RepositoryUrl>https://github.com/ShokoAnime/ShokoServer</RepositoryUrl>
<PackageTags>plugins, shoko, anime, metadata, tagging</PackageTags>
<PackageReleaseNotes>Renamer Rewrite</PackageReleaseNotes>
<Version>4.1.0-beta2</Version>
<Version>4.1.0-beta3</Version>
<Configurations>Debug;Release;Benchmarks</Configurations>
<Platforms>AnyCPU;x64</Platforms>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
Expand Down
46 changes: 25 additions & 21 deletions Shoko.Server/Models/SVR_AnimeEpisode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,31 @@ IReadOnlyList<AnimeTitle> IWithTitles.Titles

IReadOnlyList<IShokoEpisode> IEpisode.ShokoEpisodes => [this];

IReadOnlyList<IVideoCrossReference> IEpisode.CrossReferences =>
RepoFactory.CrossRef_File_Episode.GetByEpisodeID(AniDB_EpisodeID);

IReadOnlyList<IVideo> 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<IEpisode> IShokoEpisode.TmdbEpisodes => TmdbEpisodes;

IReadOnlyList<IMovie> IShokoEpisode.TmdbMovies => TmdbMovies;

IReadOnlyList<IEpisode> IShokoEpisode.LinkedEpisodes
{
get
Expand Down Expand Up @@ -362,26 +387,5 @@ IReadOnlyList<IMovie> IShokoEpisode.LinkedMovies
}
}

IReadOnlyList<IVideoCrossReference> IEpisode.CrossReferences =>
RepoFactory.CrossRef_File_Episode.GetByEpisodeID(AniDB_EpisodeID);

IReadOnlyList<IVideo> 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
}
10 changes: 7 additions & 3 deletions Shoko.Server/Models/SVR_AnimeSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IShokoGroup> IShokoSeries.AllParentGroups => AllGroupsAbove;

ISeries IShokoSeries.AnidbAnime => AniDB_Anime ??
throw new NullReferenceException($"Unable to find AniDB anime with id {AniDB_ID} in IShokoSeries.AnidbAnime");

IReadOnlyList<ISeries> IShokoSeries.TmdbShows => TmdbShows;

IReadOnlyList<IMovie> IShokoSeries.TmdbMovies => TmdbMovies;

IReadOnlyList<ISeries> IShokoSeries.LinkedSeries
{
Expand All @@ -675,6 +678,7 @@ IReadOnlyList<ISeries> IShokoSeries.LinkedSeries
return seriesList;
}
}

IReadOnlyList<IMovie> IShokoSeries.LinkedMovies
{
get
Expand Down

0 comments on commit 94d6358

Please sign in to comment.