mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-12 11:15:43 +02:00
fixed duplicated episodes coming in from Tvdb
This commit is contained in:
parent
3d3e864094
commit
7560a70dd4
@ -84,6 +84,21 @@ public void no_result_title_lookup()
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void none_unique_season_episode_number()
|
||||
{
|
||||
//setup
|
||||
var tvdbProvider = new TvDbProvider();
|
||||
|
||||
//act
|
||||
var result = tvdbProvider.GetSeries(75978, true);//Family guy
|
||||
|
||||
//Asserts that when episodes are grouped by Season/Episode each group contains maximum of
|
||||
//one item.
|
||||
result.Episodes.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"))
|
||||
.Max(e => e.Count()).Should().Be(1);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void American_dad_fix()
|
||||
|
@ -105,6 +105,13 @@ public virtual TvdbSeries GetSeries(int id, bool loadEpisodes)
|
||||
}
|
||||
}
|
||||
|
||||
//Remove duplicated episodes
|
||||
var episodes = result.Episodes.OrderByDescending(e => e.FirstAired).ThenByDescending(e => e.EpisodeName)
|
||||
.GroupBy(e => e.SeriesId.ToString("000000") + e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"))
|
||||
.Select(e => e.First());
|
||||
|
||||
result.Episodes = episodes.ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user