Skip to content

Commit

Permalink
feat: add cast, crew, studios & characters
Browse files Browse the repository at this point in the history
- Added `ICast`, `ICast<TMetadata>`, `ICrew`, `ICrew<TMetadata>` & `IWithCastAndCrew` to get cast and crew information for series, movies, and episodes. Works with Shoko, AniDB and TMDB, but the shoko data is an aggregate of all data linked to AniDB and TMDB.

- Added `IStudio` & `IWithStudios` to get studio information for series and movies. Works with Shoko, AniDB and TMDB, but the Shoko data is an aggregate of all studios linked to AniDB and TMDB.

- Added `ICharacter` for cross-series characters, accessible through `ICast`. For now only AniDB supports this, but if in the future either TMDB receives native character info support, or we can reliably implement the support for them locally, then it might arrive for it too.
  • Loading branch information
revam committed Feb 13, 2025
1 parent daa670d commit 8a27af2
Show file tree
Hide file tree
Showing 50 changed files with 1,596 additions and 49 deletions.
75 changes: 75 additions & 0 deletions Shoko.Plugin.Abstractions/DataModels/ICast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Shoko.Plugin.Abstractions.Enums;

namespace Shoko.Plugin.Abstractions.DataModels;

/// <summary>
/// A cast role.
/// </summary>
public interface ICast : IMetadata<string>, IWithPortraitImage
{
/// <summary>
/// Creator ID, if the cast role has a known creator.
/// </summary>
int? CreatorID { get; }

/// <summary>
/// Character ID, if the cast role has a character shared with one or more
/// other cast roles.
/// </summary>
int? CharacterID { get; }

/// <summary>
/// Parent entity ID.
/// </summary>
int ParentID { get; }

/// <summary>
/// Casted role name.
/// </summary>
string Name { get; }

/// <summary>
/// Casted role name in the original language of the media, if available
/// from
/// </summary>
string? OriginalName { get; }

/// <summary>
/// Role description, if available from the provider.
/// </summary>
string? Description { get; }

/// <summary>
/// Role type.
/// </summary>
CastRoleType RoleType { get; }

/// <summary>
/// Parent metadata entity.
/// </summary>
IMetadata<int>? Parent { get; }

/// <summary>
/// Character, if the cast role has a character shared with one or more
/// other cast roles.
/// </summary>
ICharacter? Character { get; }

/// <summary>
/// Creator. Can be null if the cast role has no known creator or if the
/// metadata is currently not locally available.
/// </summary>
ICreator? Creator { get; }
}

/// <summary>
/// A cast role for a parent entity.
/// </summary>
/// <typeparam name="TMetadata">Metadata type.</typeparam>
public interface ICast<TMetadata> : ICast where TMetadata : IMetadata<int>
{
/// <summary>
/// Parent metadata entity.
/// </summary>
TMetadata? ParentOfType { get; }
}
36 changes: 36 additions & 0 deletions Shoko.Plugin.Abstractions/DataModels/ICharacter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Collections.Generic;
using Shoko.Plugin.Abstractions.Enums;

namespace Shoko.Plugin.Abstractions.DataModels;

/// <summary>
/// Character.
/// </summary>
public interface ICharacter : IMetadata<int>, IWithDescriptions, IWithPortraitImage
{
/// <summary>
/// Casted role name.
/// </summary>
string Name { get; }

/// <summary>
/// Casted role name in the original language of the media, if available
/// from
/// </summary>
string? OriginalName { get; }

/// <summary>
/// All episode cast roles with the character.
/// </summary>
IEnumerable<ICast<IEpisode>> EpisodeCastRoles { get; }

/// <summary>
/// All movie cast roles with the character.
/// </summary>
IEnumerable<ICast<IMovie>> MovieCastRoles { get; }

/// <summary>
/// All series cast roles with the character.
/// </summary>
IEnumerable<ICast<ISeries>> SeriesCastRoles { get; }
}
56 changes: 56 additions & 0 deletions Shoko.Plugin.Abstractions/DataModels/ICreator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Collections.Generic;
using Shoko.Plugin.Abstractions.Enums;

namespace Shoko.Plugin.Abstractions.DataModels;

/// <summary>
/// Creator.
/// </summary>
public interface ICreator : IMetadata<int>, IWithDescriptions, IWithPortraitImage
{
/// <summary>
/// Casted role name.
/// </summary>
string Name { get; }

/// <summary>
/// Casted role name in the original language of the media, if available
/// from
/// </summary>
string? OriginalName { get; }

/// <summary>
/// The type of the creator.
/// </summary>
CreatorType Type { get; }

/// <summary>
/// All episode cast roles the creator have participated in.
/// </summary>
IEnumerable<ICast<IEpisode>> EpisodeCastRoles { get; }

/// <summary>
/// All movie cast roles the creator have participated in.
/// </summary>
IEnumerable<ICast<IMovie>> MovieCastRoles { get; }

/// <summary>
/// All series cast roles the creator have participated in.
/// </summary>
IEnumerable<ICast<ISeries>> SeriesCastRoles { get; }

/// <summary>
/// All episode crew roles the creator have participated in.
/// </summary>
IEnumerable<ICrew<IEpisode>> EpisodeCrewRoles { get; }

/// <summary>
/// All movie crew roles the creator have participated in.
/// </summary>
IEnumerable<ICrew<IMovie>> MovieCrewRoles { get; }

/// <summary>
/// All series crew roles the creator have participated in.
/// </summary>
IEnumerable<ICrew<ISeries>> SeriesCrewRoles { get; }
}
52 changes: 52 additions & 0 deletions Shoko.Plugin.Abstractions/DataModels/ICrew.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Shoko.Plugin.Abstractions.Enums;

namespace Shoko.Plugin.Abstractions.DataModels;

/// <summary>
/// A crew role.
/// </summary>
public interface ICrew : IMetadata<string>
{
/// <summary>
/// Creator ID.
/// </summary>
int CreatorID { get; }

/// <summary>
/// Parent entity ID.
/// </summary>
int ParentID { get; }

/// <summary>
/// Name of the crew role, in English.
/// </summary>
string Name { get; }

/// <summary>
/// Programmatic type of the crew role.
/// </summary>
CrewRoleType RoleType { get; }

/// <summary>
/// Parent metadata entity.
/// </summary>
IMetadata<int>? Parent { get; }

/// <summary>
/// Creator. Can be null if the metadata is
/// currently not locally available.
/// </summary>
ICreator? Creator { get; }
}

/// <summary>
/// A crew role for a parent entity.
/// </summary>
/// <typeparam name="TMetadata">Metadata type.</typeparam>
public interface ICrew<TMetadata> : ICrew where TMetadata : IMetadata<int>
{
/// <summary>
/// Parent metadata entity.
/// </summary>
TMetadata? ParentOfType { get; }
}
2 changes: 1 addition & 1 deletion Shoko.Plugin.Abstractions/DataModels/IEpisode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Shoko.Plugin.Abstractions.DataModels;
/// <summary>
/// Episode metadata.
/// </summary>
public interface IEpisode : IWithTitles, IWithDescriptions, IWithImages, IMetadata<int>
public interface IEpisode : IWithTitles, IWithDescriptions, IWithImages, IWithCastAndCrew, IMetadata<int>
{
/// <summary>
/// The series id.
Expand Down
2 changes: 1 addition & 1 deletion Shoko.Plugin.Abstractions/DataModels/IMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IMetadata
/// <summary>
/// Base metadata interface with an ID.
/// </summary>
public interface IMetadata<TId> : IMetadata where TId : struct
public interface IMetadata<TId> : IMetadata
{
/// <summary>
/// The ID of the metadata.
Expand Down
2 changes: 1 addition & 1 deletion Shoko.Plugin.Abstractions/DataModels/IMovie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Shoko.Plugin.Abstractions.DataModels;
/// <summary>
/// Movie metadata.
/// </summary>
public interface IMovie : IWithTitles, IWithDescriptions, IWithImages, IMetadata<int>
public interface IMovie : IWithTitles, IWithDescriptions, IWithImages, IWithCastAndCrew, IWithStudios, IMetadata<int>
{
/// <summary>
/// The shoko series ID, if we have any.
Expand Down
2 changes: 1 addition & 1 deletion Shoko.Plugin.Abstractions/DataModels/ISeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Shoko.Plugin.Abstractions.DataModels;
/// <summary>
/// Series metadata.
/// </summary>
public interface ISeries : IWithTitles, IWithDescriptions, IWithImages, IMetadata<int>
public interface ISeries : IWithTitles, IWithDescriptions, IWithImages, IWithCastAndCrew, IWithStudios, IMetadata<int>
{
/// <summary>
/// The shoko series ID, if we have any.
Expand Down
61 changes: 61 additions & 0 deletions Shoko.Plugin.Abstractions/DataModels/IStudio.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Collections.Generic;
using Shoko.Plugin.Abstractions.Enums;

namespace Shoko.Plugin.Abstractions.DataModels;

/// <summary>
/// A studio.
/// </summary>
public interface IStudio : IMetadata<int>, IWithPortraitImage
{
/// <summary>
/// Parent entity ID.
/// </summary>
int ParentID { get; }

/// <summary>
/// The name of the studio.
/// </summary>
string Name { get; }

/// <summary>
/// The original name of the studio.
/// </summary>
string? OriginalName { get; }

/// <summary>
/// The type of studio.
/// </summary>
StudioType StudioType { get; }

/// <summary>
/// Parent metadata entity.
/// </summary>
IMetadata<int>? Parent { get; }

/// <summary>
/// All locally known movie works by the studio.
/// </summary>
IEnumerable<IMovie> MovieWorks { get; }

/// <summary>
/// All locally known series works by the studio.
/// </summary>
IEnumerable<ISeries> SeriesWorks { get; }

/// <summary>
/// All locally known works by the studio.
/// </summary>
IEnumerable<IMetadata> Works { get; }
}

/// <summary>
/// A studio for a parent entity.
/// </summary>
public interface IStudio<TMetadata> : IStudio where TMetadata : IMetadata<int>
{
/// <summary>
/// Parent metadata entity.
/// </summary>
TMetadata? ParentOfType { get; }
}
20 changes: 20 additions & 0 deletions Shoko.Plugin.Abstractions/DataModels/IWithCastAndCrew.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

using System.Collections.Generic;

namespace Shoko.Plugin.Abstractions.DataModels;

/// <summary>
/// Represents an entity with cast and crew.
/// </summary>
public interface IWithCastAndCrew
{
/// <summary>
/// Cast associated with the entity.
/// </summary>
IReadOnlyList<ICast> Cast { get; }

/// <summary>
/// Crew associated with the entity.
/// </summary>
IReadOnlyList<ICrew> Crew { get; }
}
14 changes: 14 additions & 0 deletions Shoko.Plugin.Abstractions/DataModels/IWithPortraitImage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

namespace Shoko.Plugin.Abstractions.DataModels;

/// <summary>
/// Represents an entity with a portrait image.
/// </summary>
public interface IWithPortraitImage
{
/// <summary>
/// Portrait image of the casted role, if
/// available from the provider.
/// </summary>
IImageMetadata? PortraitImage { get; }
}
15 changes: 15 additions & 0 deletions Shoko.Plugin.Abstractions/DataModels/IWithStudios.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

using System.Collections.Generic;

namespace Shoko.Plugin.Abstractions.DataModels;

/// <summary>
/// Represents an entity with studios.
/// </summary>
public interface IWithStudios
{
/// <summary>
/// Studios associated with the entity.
/// </summary>
IReadOnlyList<IStudio> Studios { get; }
}
Loading

0 comments on commit 8a27af2

Please sign in to comment.