Apply review suggestion

This commit is contained in:
Shadowghost
2024-05-16 19:36:49 +02:00
parent af4b732080
commit dc93cc13b5
2 changed files with 17 additions and 14 deletions

View File

@@ -214,16 +214,14 @@ namespace MediaBrowser.Controller.Entities.TV
public Dictionary<int, string> GetSeasonNames()
{
if (_seasonNames.Count == 0)
{
var childSeasons = Children.OfType<Season>()
.Where(s => s.IndexNumber.HasValue)
.DistinctBy(s => s.IndexNumber);
var newSeasons = Children.OfType<Season>()
.Where(s => s.IndexNumber.HasValue)
.Where(s => !_seasonNames.ContainsKey(s.IndexNumber.Value))
.DistinctBy(s => s.IndexNumber);
foreach (var season in childSeasons)
{
_seasonNames[season.IndexNumber.Value] = season.Name;
}
foreach (var season in newSeasons)
{
SetSeasonName(season.IndexNumber.Value, season.Name);
}
return _seasonNames;