mirror of
https://github.com/Radarr/Radarr
synced 2025-02-27 16:42:46 +00:00
Fixed: filter duplicated episodes returned from Trakt
http://support.trakt.tv/forums/188762-general/suggestions/4430690-anger-management-duplicate-episode
This commit is contained in:
parent
ab264b3c06
commit
f44fd5fcbd
3 changed files with 15 additions and 14 deletions
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ static OsInfo()
|
||||||
[DllImport("libc")]
|
[DllImport("libc")]
|
||||||
static extern int uname(IntPtr buf);
|
static extern int uname(IntPtr buf);
|
||||||
|
|
||||||
|
[DebuggerStepThrough]
|
||||||
static bool IsRunningOnMac()
|
static bool IsRunningOnMac()
|
||||||
{
|
{
|
||||||
var buf = IntPtr.Zero;
|
var buf = IntPtr.Zero;
|
||||||
|
|
|
@ -103,8 +103,8 @@ private void ValidateEpisodes(List<Episode> episodes)
|
||||||
{
|
{
|
||||||
episodes.Should().NotBeEmpty();
|
episodes.Should().NotBeEmpty();
|
||||||
|
|
||||||
episodes.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"))
|
var episodeGroup= episodes.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"));
|
||||||
.Max(e => e.Count()).Should().Be(1);
|
episodeGroup.Should().OnlyContain(c=>c.Count() == 1);
|
||||||
|
|
||||||
episodes.Should().Contain(c => c.SeasonNumber > 0);
|
episodes.Should().Contain(c => c.SeasonNumber > 0);
|
||||||
episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Overview));
|
episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Overview));
|
||||||
|
|
|
@ -110,22 +110,21 @@ public Tuple<Series, List<Episode>> GetSeriesInfo(int tvdbSeriesId)
|
||||||
|
|
||||||
var response = _httpClient.Get<Show>(request).Resource;
|
var response = _httpClient.Get<Show>(request).Resource;
|
||||||
|
|
||||||
/*
|
var episodes = response.seasons.SelectMany(c => c.episodes).Select(MapEpisode);
|
||||||
|
|
||||||
var client = BuildClient("show", "summary");
|
episodes = RemoveDuplicates(episodes);
|
||||||
var restRequest = new RestRequest(tvdbSeriesId + "/extended");
|
|
||||||
var response = client.ExecuteAndValidate<Show>(restRequest);*/
|
|
||||||
|
|
||||||
var episodes = response.seasons.SelectMany(c => c.episodes).Select(MapEpisode).ToList();
|
|
||||||
var series = MapSeries(response);
|
var series = MapSeries(response);
|
||||||
|
|
||||||
return new Tuple<Series, List<Episode>>(series, episodes);
|
return new Tuple<Series, List<Episode>>(series, episodes.ToList());
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
private static IRestClient BuildClient(string resource, string method)
|
private static IEnumerable<Episode> RemoveDuplicates(IEnumerable<Episode> episodes)
|
||||||
{
|
{
|
||||||
return RestClientFactory.BuildClient(string.Format("http://api.trakt.tv/{0}/{1}.json/bc3c2c460f22cbb01c264022b540e191", resource, method));
|
//http://support.trakt.tv/forums/188762-general/suggestions/4430690-anger-management-duplicate-episode
|
||||||
}*/
|
var episodeGroup = episodes.GroupBy(e => e.SeasonNumber.ToString("0000") + e.EpisodeNumber.ToString("0000"));
|
||||||
|
return episodeGroup.Select(g => g.First());
|
||||||
|
}
|
||||||
|
|
||||||
private static Series MapSeries(Show show)
|
private static Series MapSeries(Show show)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue