Keivan Beigi 10 years ago
parent ab264b3c06
commit f44fd5fcbd

@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
@ -50,6 +51,7 @@ namespace NzbDrone.Common.EnvironmentInfo
[DllImport("libc")]
static extern int uname(IntPtr buf);
[DebuggerStepThrough]
static bool IsRunningOnMac()
{
var buf = IntPtr.Zero;

@ -103,8 +103,8 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
{
episodes.Should().NotBeEmpty();
episodes.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"))
.Max(e => e.Count()).Should().Be(1);
var episodeGroup= episodes.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"));
episodeGroup.Should().OnlyContain(c=>c.Count() == 1);
episodes.Should().Contain(c => c.SeasonNumber > 0);
episodes.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Overview));

@ -110,22 +110,21 @@ namespace NzbDrone.Core.MetadataSource
var response = _httpClient.Get<Show>(request).Resource;
/*
var episodes = response.seasons.SelectMany(c => c.episodes).Select(MapEpisode);
var client = BuildClient("show", "summary");
var restRequest = new RestRequest(tvdbSeriesId + "/extended");
var response = client.ExecuteAndValidate<Show>(restRequest);*/
var episodes = response.seasons.SelectMany(c => c.episodes).Select(MapEpisode).ToList();
episodes = RemoveDuplicates(episodes);
var series = MapSeries(response);
return new Tuple<Series, List<Episode>>(series, episodes);
return new Tuple<Series, List<Episode>>(series, episodes.ToList());
}
private static IEnumerable<Episode> RemoveDuplicates(IEnumerable<Episode> episodes)
{
//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 IRestClient BuildClient(string resource, string method)
{
return RestClientFactory.BuildClient(string.Format("http://api.trakt.tv/{0}/{1}.json/bc3c2c460f22cbb01c264022b540e191", resource, method));
}*/
private static Series MapSeries(Show show)
{

Loading…
Cancel
Save