Add braces to if's and other minor style changes

pull/776/head
Claus Vium 6 years ago
parent 935c7231eb
commit 18231fedef

@ -129,8 +129,7 @@ namespace MediaBrowser.Providers.TV
IReadOnlyCollection<(int SeasonNumber, int Episodenumber, DateTime FirstAired)> episodeLookup, IReadOnlyCollection<(int SeasonNumber, int Episodenumber, DateTime FirstAired)> episodeLookup,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var existingEpisodes = allItems.OfType<Episode>() var existingEpisodes = allItems.OfType<Episode>().ToList();
.ToList();
var seasonCounts = episodeLookup.GroupBy(e => e.SeasonNumber).ToDictionary(g => g.Key, g => g.Count()); var seasonCounts = episodeLookup.GroupBy(e => e.SeasonNumber).ToDictionary(g => g.Key, g => g.Count());
@ -280,15 +279,7 @@ namespace MediaBrowser.Providers.TV
} }
// If the season no longer exists in the remote lookup, delete it, but only if an existing episode doesn't require it // If the season no longer exists in the remote lookup, delete it, but only if an existing episode doesn't require it
if (episodeLookup.All(e => e.SeasonNumber != seasonNumber)) return episodeLookup.All(e => e.SeasonNumber != seasonNumber) && allEpisodes.All(s => s.ParentIndexNumber != seasonNumber || s.IsInSeasonFolder);
{
if (allEpisodes.All(s => s.ParentIndexNumber != seasonNumber || s.IsInSeasonFolder))
{
return true;
}
}
return false;
} }
// Season does not have a number // Season does not have a number
@ -354,9 +345,9 @@ namespace MediaBrowser.Providers.TV
/// </summary> /// </summary>
/// <param name="existingEpisodes">The existing episodes.</param> /// <param name="existingEpisodes">The existing episodes.</param>
/// <param name="seasonCounts"></param> /// <param name="seasonCounts"></param>
/// <param name="tuple">The tuple.</param> /// <param name="episodeTuple"></param>
/// <returns>Episode.</returns> /// <returns>Episode.</returns>
private Episode GetExistingEpisode(IList<Episode> existingEpisodes, Dictionary<int, int> seasonCounts, (int SeasonNumber, int EpisodeNumber, DateTime FirstAired) episodeTuple) private Episode GetExistingEpisode(IList<Episode> existingEpisodes, IReadOnlyDictionary<int, int> seasonCounts, (int SeasonNumber, int EpisodeNumber, DateTime FirstAired) episodeTuple)
{ {
var seasonNumber = episodeTuple.SeasonNumber; var seasonNumber = episodeTuple.SeasonNumber;
var episodeNumber = episodeTuple.EpisodeNumber; var episodeNumber = episodeTuple.EpisodeNumber;
@ -365,15 +356,21 @@ namespace MediaBrowser.Providers.TV
{ {
var episode = GetExistingEpisode(existingEpisodes, seasonNumber, episodeNumber); var episode = GetExistingEpisode(existingEpisodes, seasonNumber, episodeNumber);
if (episode != null) if (episode != null)
{
return episode; return episode;
}
seasonNumber--; seasonNumber--;
if (seasonCounts.ContainsKey(seasonNumber)) if (seasonCounts.ContainsKey(seasonNumber))
{
episodeNumber += seasonCounts[seasonNumber]; episodeNumber += seasonCounts[seasonNumber];
}
else else
{
break; break;
} }
}
return null; return null;
} }

Loading…
Cancel
Save