Skip to content

Commit

Permalink
Misc: Implement requested style changes from #42
Browse files Browse the repository at this point in the history
  • Loading branch information
fearnlj01 committed Apr 13, 2024
1 parent 7415831 commit e167ba8
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions Shokofin/Utils/Text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,29 +142,23 @@ public static string GetDescription(ShowInfo show)
=> GetDescription(show.DefaultSeason);

public static string GetDescription(SeasonInfo season)
{
Dictionary<TextSourceType, string> descriptions = new() {
=> GetDescription(new Dictionary<TextSourceType, string>() {
{TextSourceType.AniDb, season.AniDB.Description ?? string.Empty},
{TextSourceType.TvDb, season.TvDB?.Description ?? string.Empty},
};
return GetDescription(descriptions);
}
});

public static string GetDescription(EpisodeInfo episode)
{
Dictionary<TextSourceType, string> descriptions = new() {
=> GetDescription(new Dictionary<TextSourceType, string>() {
{TextSourceType.AniDb, episode.AniDB.Description ?? string.Empty},
{TextSourceType.TvDb, episode.TvDB?.Description ?? string.Empty},
};
return GetDescription(descriptions);
}
});

public static string GetDescription(IEnumerable<EpisodeInfo> episodeList)
=> JoinText(episodeList.Select(episode => GetDescription(episode)));
=> JoinText(episodeList.Select(episode => GetDescription(episode))) ?? string.Empty;

private static string GetDescription(Dictionary<TextSourceType, string> descriptions)
{
string overview = string.Empty;
var overview = string.Empty;

var providerOrder = Plugin.Instance.Configuration.DescriptionSourceOrder;
var providers = Plugin.Instance.Configuration.DescriptionSourceList;
Expand Down Expand Up @@ -237,7 +231,7 @@ public static (string?, string?) GetTitles(IEnumerable<Title>? seriesTitles, IEn
);
}

public static string JoinText(IEnumerable<string?> textList)
public static string? JoinText(IEnumerable<string?> textList)
{
var filteredList = textList
.Where(title => !string.IsNullOrWhiteSpace(title))
Expand All @@ -247,7 +241,7 @@ public static string JoinText(IEnumerable<string?> textList)
.ToList();

if (filteredList.Count == 0)
return string.Empty;
return null;

var index = 1;
var outputText = filteredList[0];
Expand Down

0 comments on commit e167ba8

Please sign in to comment.