fixed duplicated episodes coming in from Tvdb

pull/4/head
kay.one 14 years ago
parent 3d3e864094
commit 7560a70dd4

@ -84,6 +84,21 @@ namespace NzbDrone.Core.Test
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 @@ namespace NzbDrone.Core.Providers
}
}
//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…
Cancel
Save