diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj index 8ff94211a..7694cf32b 100644 --- a/NzbDrone.Api/NzbDrone.Api.csproj +++ b/NzbDrone.Api/NzbDrone.Api.csproj @@ -112,8 +112,6 @@ - - diff --git a/NzbDrone.Api/Resolvers/EndTimeResolver.cs b/NzbDrone.Api/Resolvers/EndTimeResolver.cs deleted file mode 100644 index 6e078c52f..000000000 --- a/NzbDrone.Api/Resolvers/EndTimeResolver.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using AutoMapper; -using NzbDrone.Api.QualityProfiles; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Api.Resolvers -{ - public class EndTimeResolver : ValueResolver - { - protected override DateTime ResolveCore(Episode source) - { - return source.AirDate.Value.AddMinutes(source.Series.Runtime); - } - } -} diff --git a/NzbDrone.Api/Resolvers/NextAiringResolver.cs b/NzbDrone.Api/Resolvers/NextAiringResolver.cs deleted file mode 100644 index a159b8239..000000000 --- a/NzbDrone.Api/Resolvers/NextAiringResolver.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Linq; -using AutoMapper; - -namespace NzbDrone.Api.Resolvers -{ - public class NextAiringResolver : ValueResolver - { - protected override DateTime? ResolveCore(Core.Tv.Series source) - { - if (String.IsNullOrWhiteSpace(source.AirTime) || !source.NextAiring.HasValue) - return source.NextAiring; - - return source.NextAiring.Value.Add(Convert.ToDateTime(source.AirTime).TimeOfDay) - .AddHours(source.UtcOffset * -1); - } - } -} diff --git a/NzbDrone.Core.Test/MetadataSourceTests/TracktProxyFixture.cs b/NzbDrone.Core.Test/MetadataSourceTests/TracktProxyFixture.cs index e1e30136d..0a73855b4 100644 --- a/NzbDrone.Core.Test/MetadataSourceTests/TracktProxyFixture.cs +++ b/NzbDrone.Core.Test/MetadataSourceTests/TracktProxyFixture.cs @@ -4,6 +4,7 @@ using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Tv; namespace NzbDrone.Core.Test.MetadataSourceTests { @@ -18,6 +19,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests var result = Subject.SearchForNewSeries(title); result.Should().NotBeEmpty(); + result[0].Title.Should().Be(title); } @@ -34,28 +36,51 @@ namespace NzbDrone.Core.Test.MetadataSourceTests { var details = Subject.GetSeriesInfo(75978); - details.Should().NotBeNull(); - details.Images.Should().NotBeEmpty(); + ValidateSeries(details); } - [Test] - public void none_unique_season_episode_number() - { - var result = Subject.GetEpisodeInfo(75978);//Family guy - - result.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000")) - .Max(e => e.Count()).Should().Be(1); - - result.Select(c => c.TvDbEpisodeId).Should().OnlyHaveUniqueItems(); - } - - - [Test] public void should_be_able_to_get_list_of_episodes() { var details = Subject.GetEpisodeInfo(75978); + details.Should().NotBeEmpty(); + + details.GroupBy(e => e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000")) + .Max(e => e.Count()).Should().Be(1); + + details.Select(c => c.TvDbEpisodeId).Should().OnlyHaveUniqueItems(); + + details.Should().Contain(c => c.SeasonNumber > 0); + details.Should().Contain(c => !string.IsNullOrWhiteSpace(c.Overview)); + + foreach (var episode in details) + { + episode.AirDate.Should().HaveValue(); + episode.AirDate.Value.Kind.Should().Be(DateTimeKind.Utc); + episode.EpisodeNumber.Should().NotBe(0); + episode.Title.Should().NotBeBlank(); + episode.TvDbEpisodeId.Should().NotBe(0); + } + } + + + + private void ValidateSeries(Series series) + { + series.Should().NotBeNull(); + series.Title.Should().NotBeBlank(); + series.Overview.Should().NotBeBlank(); + series.AirTime.Should().NotBeBlank(); + series.FirstAired.Should().HaveValue(); + series.FirstAired.Value.Kind.Should().Be(DateTimeKind.Utc); + series.Images.Should().NotBeEmpty(); + series.ImdbId.Should().NotBeBlank(); + series.Network.Should().NotBeBlank(); + series.Runtime.Should().BeGreaterThan(0); + series.TitleSlug.Should().NotBeBlank(); + series.TvRageId.Should().BeGreaterThan(0); + series.TvdbId.Should().BeGreaterThan(0); } } } diff --git a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs b/NzbDrone.Core/Datastore/Migration/Migration20130324.cs index c0b5685bf..46055442d 100644 --- a/NzbDrone.Core/Datastore/Migration/Migration20130324.cs +++ b/NzbDrone.Core/Datastore/Migration/Migration20130324.cs @@ -40,7 +40,6 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Network").AsString().Nullable() .WithColumn("CustomStartDate").AsDateTime().Nullable() .WithColumn("UseSceneNumbering").AsBoolean() - .WithColumn("UtcOffSet").AsInt32() .WithColumn("FirstAired").AsDateTime().Nullable() .WithColumn("NextAiring").AsDateTime().Nullable(); diff --git a/NzbDrone.Core/MetadataSource/Trakt/Actor.cs b/NzbDrone.Core/MetadataSource/Trakt/Actor.cs deleted file mode 100644 index 2c0922770..000000000 --- a/NzbDrone.Core/MetadataSource/Trakt/Actor.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class Actor - { - public string name { get; set; } - public string character { get; set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/MetadataSource/Trakt/Episode.cs b/NzbDrone.Core/MetadataSource/Trakt/Episode.cs index 03eaa8c67..7045f31cb 100644 --- a/NzbDrone.Core/MetadataSource/Trakt/Episode.cs +++ b/NzbDrone.Core/MetadataSource/Trakt/Episode.cs @@ -1,6 +1,4 @@ -using System; - -namespace NzbDrone.Core.MetadataSource.Trakt +namespace NzbDrone.Core.MetadataSource.Trakt { public class Episode { @@ -10,9 +8,10 @@ namespace NzbDrone.Core.MetadataSource.Trakt public int tvdb_id { get; set; } public string title { get; set; } public string overview { get; set; } - public DateTime? first_aired { get; set; } + public int first_aired { get; set; } + public string first_aired_iso { get; set; } + public int first_aired_utc { get; set; } public string url { get; set; } public string screen { get; set; } - public Ratings ratings { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Core/MetadataSource/Trakt/People.cs b/NzbDrone.Core/MetadataSource/Trakt/People.cs deleted file mode 100644 index 5a4a97755..000000000 --- a/NzbDrone.Core/MetadataSource/Trakt/People.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; - -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class People - { - public List actors { get; set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/MetadataSource/Trakt/Ratings.cs b/NzbDrone.Core/MetadataSource/Trakt/Ratings.cs deleted file mode 100644 index 7ca617121..000000000 --- a/NzbDrone.Core/MetadataSource/Trakt/Ratings.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class Ratings - { - public int percentage { get; set; } - public int votes { get; set; } - public int loved { get; set; } - public int hated { get; set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/MetadataSource/Trakt/Show.cs b/NzbDrone.Core/MetadataSource/Trakt/Show.cs index dde25f9d4..bf7745d43 100644 --- a/NzbDrone.Core/MetadataSource/Trakt/Show.cs +++ b/NzbDrone.Core/MetadataSource/Trakt/Show.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace NzbDrone.Core.MetadataSource.Trakt { @@ -8,14 +7,18 @@ namespace NzbDrone.Core.MetadataSource.Trakt public string title { get; set; } public int year { get; set; } public string url { get; set; } - public DateTime? first_aired { get; set; } + public int first_aired { get; set; } + public string first_aired_iso { get; set; } + public int first_aired_utc { get; set; } public string country { get; set; } public string overview { get; set; } public int runtime { get; set; } public string status { get; set; } public string network { get; set; } public string air_day { get; set; } + public string air_day_utc { get; set; } public string air_time { get; set; } + public string air_time_utc { get; set; } public string certification { get; set; } public string imdb_id { get; set; } public int tvdb_id { get; set; } @@ -23,11 +26,6 @@ namespace NzbDrone.Core.MetadataSource.Trakt public int last_updated { get; set; } public string poster { get; set; } public Images images { get; set; } - public List top_watchers { get; set; } - public List top_episodes { get; set; } - public Ratings ratings { get; set; } - public Stats stats { get; set; } - public People people { get; set; } public List genres { get; set; } public List seasons { get; set; } } diff --git a/NzbDrone.Core/MetadataSource/Trakt/Stats.cs b/NzbDrone.Core/MetadataSource/Trakt/Stats.cs deleted file mode 100644 index ed0243b33..000000000 --- a/NzbDrone.Core/MetadataSource/Trakt/Stats.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class Stats - { - public int watchers { get; set; } - public int plays { get; set; } - public int scrobbles { get; set; } - public int scrobbles_unique { get; set; } - public int checkins { get; set; } - public int checkins_unique { get; set; } - public int collection { get; set; } - public int collection_unique { get; set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/MetadataSource/Trakt/TopEpisode.cs b/NzbDrone.Core/MetadataSource/Trakt/TopEpisode.cs deleted file mode 100644 index 2db3d173e..000000000 --- a/NzbDrone.Core/MetadataSource/Trakt/TopEpisode.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class TopEpisode - { - public int plays { get; set; } - public int season { get; set; } - public int number { get; set; } - public string title { get; set; } - public string url { get; set; } - public int first_aired { get; set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/MetadataSource/Trakt/TopWatcher.cs b/NzbDrone.Core/MetadataSource/Trakt/TopWatcher.cs deleted file mode 100644 index 5dbffdc2e..000000000 --- a/NzbDrone.Core/MetadataSource/Trakt/TopWatcher.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace NzbDrone.Core.MetadataSource.Trakt -{ - public class TopWatcher - { - public int plays { get; set; } - public string username { get; set; } - public bool @protected { get; set; } - public object full_name { get; set; } - public object gender { get; set; } - public string age { get; set; } - public object location { get; set; } - public object about { get; set; } - public int joined { get; set; } - public string avatar { get; set; } - public string url { get; set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/MetadataSource/TraktProxy.cs b/NzbDrone.Core/MetadataSource/TraktProxy.cs index e895050f0..96763657c 100644 --- a/NzbDrone.Core/MetadataSource/TraktProxy.cs +++ b/NzbDrone.Core/MetadataSource/TraktProxy.cs @@ -52,11 +52,11 @@ namespace NzbDrone.Core.MetadataSource series.TvRageId = show.tvrage_id; series.ImdbId = show.imdb_id; series.Title = show.title; - series.FirstAired = show.first_aired; + series.FirstAired =FromEpoc(show.first_aired_utc); series.Overview = show.overview; series.Runtime = show.runtime; series.Network = show.network; - series.AirTime = show.air_time; + series.AirTime = show.air_time_utc; series.TitleSlug = show.url.ToLower().Replace("http://trakt.tv/show/", ""); series.Status = GetSeriesStatus(show.status); @@ -75,14 +75,14 @@ namespace NzbDrone.Core.MetadataSource episode.EpisodeNumber = traktEpisode.number; episode.TvDbEpisodeId = traktEpisode.tvdb_id; episode.Title = traktEpisode.title; - episode.AirDate = traktEpisode.first_aired; + episode.AirDate =FromEpoc(traktEpisode.first_aired_utc); return episode; } private static string GetPosterThumbnailUrl(string posterUrl) { - if(posterUrl.Contains("poster-small.jpg")) return posterUrl; + if (posterUrl.Contains("poster-small.jpg")) return posterUrl; var extension = Path.GetExtension(posterUrl); var withoutExtension = posterUrl.Substring(0, posterUrl.Length - extension.Length); @@ -95,5 +95,12 @@ namespace NzbDrone.Core.MetadataSource if (status.Equals("Ended", StringComparison.InvariantCultureIgnoreCase)) return SeriesStatusType.Ended; return SeriesStatusType.Continuing; } + + private static DateTime? FromEpoc(long ticks) + { + if (ticks == 0) return null; + + return new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(ticks); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 08de40cd8..3483e533a 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -304,16 +304,10 @@ - - - - - - diff --git a/NzbDrone.Core/Tv/Episode.cs b/NzbDrone.Core/Tv/Episode.cs index cb70473bb..962459a11 100644 --- a/NzbDrone.Core/Tv/Episode.cs +++ b/NzbDrone.Core/Tv/Episode.cs @@ -44,17 +44,6 @@ namespace NzbDrone.Core.Tv } } - public DateTime? EndTime - { - get - { - if (!AirDate.HasValue) return null; - if (Series == null) return null; - - return AirDate.Value.AddMinutes(Series.Runtime); - } - } - public String SeriesTitle { get; private set; } public Series Series { get; set; } diff --git a/NzbDrone.Core/Tv/EpisodeService.cs b/NzbDrone.Core/Tv/EpisodeService.cs index c3e9f0549..12d68ab8a 100644 --- a/NzbDrone.Core/Tv/EpisodeService.cs +++ b/NzbDrone.Core/Tv/EpisodeService.cs @@ -172,17 +172,10 @@ namespace NzbDrone.Core.Tv episodeToUpdate.TvDbEpisodeId = episode.TvDbEpisodeId; episodeToUpdate.EpisodeNumber = episode.EpisodeNumber; episodeToUpdate.SeasonNumber = episode.SeasonNumber; - episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber; episodeToUpdate.Title = episode.Title; episodeToUpdate.Overview = episode.Overview; episodeToUpdate.AirDate = episode.AirDate; - if (!String.IsNullOrWhiteSpace(series.AirTime) && episodeToUpdate.AirDate.HasValue) - { - episodeToUpdate.AirDate = episodeToUpdate.AirDate.Value.Add(Convert.ToDateTime(series.AirTime).TimeOfDay) - .AddHours(series.UtcOffset * -1); - } - successCount++; } catch (Exception e) diff --git a/NzbDrone.Core/Tv/Series.cs b/NzbDrone.Core/Tv/Series.cs index 000243606..54887e409 100644 --- a/NzbDrone.Core/Tv/Series.cs +++ b/NzbDrone.Core/Tv/Series.cs @@ -55,11 +55,7 @@ namespace NzbDrone.Core.Tv } } - //Todo: This should be a double since there are timezones that aren't on a full hour offset - public int UtcOffset { get; set; } - public DateTime? FirstAired { get; set; } public LazyLoaded QualityProfile { get; set; } - public DateTime? NextAiring { get; set; } } } \ No newline at end of file