Skip to content

Commit

Permalink
chore: rename Default* to * on IBaseItemInfo
Browse files Browse the repository at this point in the history
Rename `DefaultTitle` and `DefaultOverview` to just `Title` and `Overview` on the `IBaseItemInfo` interface, and also add summaries for the properties of the interface and the interface itself.
  • Loading branch information
revam committed Dec 8, 2024
1 parent 2949d67 commit 71e7dc2
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 74 deletions.
8 changes: 4 additions & 4 deletions Shokofin/API/Info/CollectionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public class CollectionInfo(ShokoGroup group, string? mainSeasonId, List<ShowInf
/// <summary>
/// Collection Name.
/// </summary>
public string DefaultTitle { get; init; } = group.Name;
public string Title { get; init; } = group.Name;

public IReadOnlyList<Title> Titles { get; init; } = [];

/// <summary>
/// Collection Description.
/// </summary>
public string DefaultOverview { get; init; } = group.Description;
public string Overview { get; init; } = group.Description;

public IReadOnlyList<TextOverview> Overviews { get; init; } = [];

Expand Down Expand Up @@ -74,9 +74,9 @@ public class CollectionInfo(ShokoGroup group, string? mainSeasonId, List<ShowInf

public CollectionInfo(ShokoGroup group, ShokoSeries series, string? mainSeasonId, List<ShowInfo> shows, List<CollectionInfo> subCollections) : this(group, mainSeasonId, shows, subCollections)
{
DefaultTitle = series.Name;
Title = series.Name;
Titles = series.AniDB.Titles;
DefaultOverview = series.Description == series.AniDB.Description
Overview = series.Description == series.AniDB.Description
? Text.SanitizeAnidbDescription(series.Description)
: series.Description;
Overviews = [
Expand Down
16 changes: 8 additions & 8 deletions Shokofin/API/Info/EpisodeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public class EpisodeInfo : IExtendedItemInfo {

public int EpisodeNumber { get; init; }

public string DefaultTitle { get; init; }
public string Title { get; init; }

public IReadOnlyList<Title> Titles { get; init; }

public string? DefaultOverview { get; init; }
public string? Overview { get; init; }

public IReadOnlyList<TextOverview> Overviews { get; init; }

Expand Down Expand Up @@ -119,12 +119,12 @@ public EpisodeInfo(
SeasonNumber = null;
EpisodeNumber = episode.AniDB.EpisodeNumber;
ExtraType = Ordering.GetExtraType(episode.AniDB);
DefaultTitle = episode.Name;
Title = episode.Name;
Titles = [
..episode.AniDB.Titles,
..(tmdbEntity?.Titles ?? []),
];
DefaultOverview = episode.Description == episode.AniDB.Description
Overview = episode.Description == episode.AniDB.Description
? Text.SanitizeAnidbDescription(episode.Description)
: episode.Description;
Overviews = [
Expand Down Expand Up @@ -232,9 +232,9 @@ public EpisodeInfo(ShokoApiClient client, TmdbEpisode tmdbEpisode, TmdbShow tmdb
IsStandalone = false;
SeasonNumber = tmdbEpisode.SeasonNumber;
EpisodeNumber = tmdbEpisode.EpisodeNumber;
DefaultTitle = tmdbEpisode.Title;
Title = tmdbEpisode.Title;
Titles = tmdbEpisode.Titles;
DefaultOverview = tmdbEpisode.Overview;
Overview = tmdbEpisode.Overview;
Overviews = tmdbEpisode.Overviews;
OriginalLanguageCode = tmdbShow.OriginalLanguage;
ExtraType = null;
Expand Down Expand Up @@ -284,9 +284,9 @@ public EpisodeInfo(ShokoApiClient client, TmdbMovie tmdbMovie) {
IsStandalone = true;
SeasonNumber = null;
EpisodeNumber = 1;
DefaultTitle = tmdbMovie.Title;
Title = tmdbMovie.Title;
Titles = tmdbMovie.Titles;
DefaultOverview = tmdbMovie.Overview;
Overview = tmdbMovie.Overview;
Overviews = tmdbMovie.Overviews;
OriginalLanguageCode = tmdbMovie.OriginalLanguage;
ExtraType = null;
Expand Down
25 changes: 23 additions & 2 deletions Shokofin/API/Info/IBaseItemInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,37 @@

namespace Shokofin.API.Info;

/// <summary>
/// Information about a base item.
/// </summary>
public interface IBaseItemInfo {
/// <summary>
/// Unique identifier for the base item.
/// </summary>
string Id { get; }

string DefaultTitle { get; }
/// <summary>
/// Preferred title according to title settings on the server for the base item type.
/// </summary>
string Title { get; }

/// <summary>
/// List of all available titles for the base item.
/// </summary>
IReadOnlyList<Title> Titles { get; }

string? DefaultOverview { get; }
/// <summary>
/// Preferred overview according to description settings on the server.
/// </summary>
string? Overview { get; }

/// <summary>
/// List of all available overviews for the base item.
/// </summary>
IReadOnlyList<TextOverview> Overviews { get; }

/// <summary>
/// Original language code for the base item if available.
/// </summary>
string? OriginalLanguageCode { get; }
}
20 changes: 10 additions & 10 deletions Shokofin/API/Info/SeasonInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public class SeasonInfo : IExtendedItemInfo {

public bool IsRestricted { get; init; }

public string DefaultTitle { get; init; }
public string Title { get; init; }

public IReadOnlyList<Title> Titles { get; init; }

public string? DefaultOverview { get; init; }
public string? Overview { get; init; }

public IReadOnlyList<TextOverview> Overviews { get; init; }

Expand Down Expand Up @@ -300,12 +300,12 @@ IReadOnlyDictionary<string, SeriesConfiguration> seriesConfigurationMap
Type = type;
IsMultiEntry = type is SeriesType.Movie && series.Sizes.Total.Episodes > 1;
IsRestricted = series.AniDB.Restricted;
DefaultTitle = series.Name;
Title = series.Name;
Titles = [
..series.AniDB.Titles,
..(tmdbEntity?.Titles ?? []),
];
DefaultOverview = series.Description == series.AniDB.Description
Overview = series.Description == series.AniDB.Description
? Text.SanitizeAnidbDescription(series.Description)
: series.Description;
Overviews = [
Expand Down Expand Up @@ -369,9 +369,9 @@ public SeasonInfo(ShokoApiClient client, TmdbSeason tmdbSeason, TmdbShow tmdbSho
Type = SeriesType.TV;
IsMultiEntry = true;
IsRestricted = tmdbShow.IsRestricted;
DefaultTitle = tmdbShow.Title;
Title = tmdbShow.Title;
Titles = tmdbSeason.Titles;
DefaultOverview = tmdbSeason.Overview;
Overview = tmdbSeason.Overview;
Overviews = tmdbSeason.Overviews;
OriginalLanguageCode = tmdbShow.OriginalLanguage;
CommunityRating = tmdbShow.UserRating;
Expand Down Expand Up @@ -409,9 +409,9 @@ public SeasonInfo(ShokoApiClient client, TmdbMovie tmdbMovie, EpisodeInfo episod
Type = SeriesType.Movie;
IsMultiEntry = false;
IsRestricted = tmdbMovie.IsRestricted;
DefaultTitle = tmdbMovie.Title;
Title = tmdbMovie.Title;
Titles = tmdbMovie.Titles;
DefaultOverview = tmdbMovie.Overview;
Overview = tmdbMovie.Overview;
Overviews = tmdbMovie.Overviews;
OriginalLanguageCode = tmdbMovie.OriginalLanguage;
CommunityRating = episodeInfo.CommunityRating;
Expand Down Expand Up @@ -445,9 +445,9 @@ public SeasonInfo(ShokoApiClient client, TmdbMovieCollection tmdbMovieCollection
Type = SeriesType.Movie;
IsMultiEntry = true;
IsRestricted = movies.Any(movie => movie.IsRestricted);
DefaultTitle = tmdbMovieCollection.Title;
Title = tmdbMovieCollection.Title;
Titles = tmdbMovieCollection.Titles;
DefaultOverview = tmdbMovieCollection.Overview;
Overview = tmdbMovieCollection.Overview;
Overviews = tmdbMovieCollection.Overviews;
OriginalLanguageCode = movies[0].OriginalLanguage;
CommunityRating = episodes[0].CommunityRating;
Expand Down
24 changes: 12 additions & 12 deletions Shokofin/API/Info/ShowInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public class ShowInfo : IExtendedItemInfo {
/// </summary>
public string? CollectionId { get; init; }

public string DefaultTitle { get; init; }
public string Title { get; init; }

public IReadOnlyList<Title> Titles { get; init; }

public string? DefaultOverview { get; init; }
public string? Overview { get; init; }

public IReadOnlyList<TextOverview> Overviews { get; init; }

Expand Down Expand Up @@ -175,9 +175,9 @@ public ShowInfo(ShokoApiClient client, SeasonInfo seasonInfo, string? collection
CollectionId = collectionId ?? seasonInfo.ShokoGroupId;
IsMovieCollection = seasonInfo.Type is SeriesType.Movie;
IsStandalone = true;
DefaultTitle = seasonInfo.DefaultTitle;
Title = seasonInfo.Title;
Titles = seasonInfo.Titles;
DefaultOverview = seasonInfo.DefaultOverview;
Overview = seasonInfo.Overview;
Overviews = seasonInfo.Overviews;
OriginalLanguageCode = seasonInfo.OriginalLanguageCode;
Tags = seasonInfo.Tags;
Expand Down Expand Up @@ -278,12 +278,12 @@ bool useGroupIdForCollection
TmdbId = tmdbShow.Id.ToString();
TvdbId = tmdbShow.TvdbId?.ToString();
}
DefaultTitle = group.Name;
Title = group.Name;
Titles = [
..defaultSeason.Titles.Where(t => t.Source is "AniDB"),
..(tmdbEntity?.Titles ?? []),
];
DefaultOverview = Text.SanitizeAnidbDescription(group.Description) == defaultSeason.Overviews.FirstOrDefault(t => t.Source is "AniDB")?.Value
Overview = Text.SanitizeAnidbDescription(group.Description) == defaultSeason.Overviews.FirstOrDefault(t => t.Source is "AniDB")?.Value
? Text.SanitizeAnidbDescription(group.Description)
: group.Description;
Overviews = [
Expand Down Expand Up @@ -365,9 +365,9 @@ public ShowInfo(ShokoApiClient client, TmdbShow tmdbShow, IReadOnlyList<SeasonIn
TvdbId = tmdbShow.TvdbId?.ToString();
IsMovieCollection = false;
IsStandalone = true;
DefaultTitle = tmdbShow.Title;
Title = tmdbShow.Title;
Titles = tmdbShow.Titles;
DefaultOverview = tmdbShow.Overview;
Overview = tmdbShow.Overview;
Overviews = tmdbShow.Overviews;
OriginalLanguageCode = tmdbShow.OriginalLanguage;
PremiereDate = tmdbShow.FirstAiredAt?.ToDateTime(TimeOnly.Parse("00:00:00", CultureInfo.InvariantCulture), DateTimeKind.Local);
Expand Down Expand Up @@ -402,9 +402,9 @@ public ShowInfo(ShokoApiClient client, TmdbMovie tmdbMovie, SeasonInfo seasonInf
CollectionId = ShokoGroupId;
IsMovieCollection = true;
IsStandalone = true;
DefaultTitle = tmdbMovie.Title;
Title = tmdbMovie.Title;
Titles = tmdbMovie.Titles;
DefaultOverview = tmdbMovie.Overview;
Overview = tmdbMovie.Overview;
Overviews = tmdbMovie.Overviews;
OriginalLanguageCode = tmdbMovie.OriginalLanguage;
PremiereDate = releasedAt;
Expand Down Expand Up @@ -473,9 +473,9 @@ public ShowInfo(ShokoApiClient client, TmdbMovieCollection tmdbMovieCollection,
CollectionId = ShokoGroupId;
IsMovieCollection = seasonList.Count is 1;
IsStandalone = false;
DefaultTitle = tmdbMovieCollection.Title;
Title = tmdbMovieCollection.Title;
Titles = tmdbMovieCollection.Titles;
DefaultOverview = tmdbMovieCollection.Overview;
Overview = tmdbMovieCollection.Overview;
Overviews = tmdbMovieCollection.Overviews;
OriginalLanguageCode = defaultSeason.OriginalLanguageCode;
Tags = seasonList.SelectMany(s => s.Tags).Distinct().ToArray();
Expand Down
Loading

0 comments on commit 71e7dc2

Please sign in to comment.