From 55f4a81dee4c0fae75c3512ab9ea3998edee64d2 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Sun, 8 Jan 2017 12:58:39 +0100 Subject: [PATCH] Adding first implementation of release_dates for movies. --- src/NzbDrone.Api/Series/MovieResource.cs | 3 +++ .../110_add_physical_release_to_table.cs | 23 +++++++++++++++++++ .../SkyHook/Resource/TMDBResources.cs | 21 +++++++++++++++++ .../MetadataSource/SkyHook/SkyHookProxy.cs | 13 ++++++++++- src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + src/NzbDrone.Core/Tv/Movie.cs | 1 + 6 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Core/Datastore/Migration/110_add_physical_release_to_table.cs diff --git a/src/NzbDrone.Api/Series/MovieResource.cs b/src/NzbDrone.Api/Series/MovieResource.cs index b1924629d..733adbf95 100644 --- a/src/NzbDrone.Api/Series/MovieResource.cs +++ b/src/NzbDrone.Api/Series/MovieResource.cs @@ -27,6 +27,7 @@ namespace NzbDrone.Api.Movie public MovieStatusType Status { get; set; } public string Overview { get; set; } public DateTime? InCinemas { get; set; } + public DateTime? PhysicalRelease { get; set; } public List Images { get; set; } public string Website { get; set; } @@ -87,6 +88,7 @@ namespace NzbDrone.Api.Movie //AlternateTitles SortTitle = model.SortTitle, InCinemas = model.InCinemas, + PhysicalRelease = model.PhysicalRelease, //TotalEpisodeCount //EpisodeCount //EpisodeFileCount @@ -134,6 +136,7 @@ namespace NzbDrone.Api.Movie //AlternateTitles SortTitle = resource.SortTitle, InCinemas = resource.InCinemas, + PhysicalRelease = resource.PhysicalRelease, //TotalEpisodeCount //EpisodeCount //EpisodeFileCount diff --git a/src/NzbDrone.Core/Datastore/Migration/110_add_physical_release_to_table.cs b/src/NzbDrone.Core/Datastore/Migration/110_add_physical_release_to_table.cs new file mode 100644 index 000000000..945fde4ad --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/110_add_physical_release_to_table.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; +using System.Data; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(110)] + public class add_phyiscal_release : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("Movies").AddColumn("PhysicalRelease").AsDateTime().Nullable(); + + } + + + + } +} diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/TMDBResources.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/TMDBResources.cs index d6076d3fd..9c346057a 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/TMDBResources.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/TMDBResources.cs @@ -61,6 +61,27 @@ namespace NzbDrone.Core.MetadataSource.SkyHook.Resource public float vote_average { get; set; } public int vote_count { get; set; } public AlternativeTitles alternative_titles { get; set; } + public ReleaseDatesResource release_dates { get; set; } + } + + public class ReleaseDatesResource + { + public List results { get; set; } + } + + public class ReleaseDate + { + public string certification { get; set; } + public string iso_639_1 { get; set; } + public string note { get; set; } + public string release_date { get; set; } + public int type { get; set; } + } + + public class ReleaseDates + { + public string iso_3166_1 { get; set; } + public List release_dates { get; set; } } public class Belongs_To_Collection diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 14957c0ef..4e8420337 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -70,7 +70,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook .SetSegment("route", "movie") .SetSegment("id", TmdbId.ToString()) .SetSegment("secondaryRoute", "") - .AddQueryParam("append_to_response", "alternative_titles") + .AddQueryParam("append_to_response", "alternative_titles,release_dates") .AddQueryParam("country", "US") .Build(); @@ -102,6 +102,17 @@ namespace NzbDrone.Core.MetadataSource.SkyHook movie.AlternativeTitles.Add(title.title); } + foreach(ReleaseDates releaseDates in resource.release_dates.results) + { + foreach(ReleaseDate releaseDate in releaseDates.release_dates) + { + if (releaseDate.type == 5 || releaseDate.type == 4) + { + movie.PhysicalRelease = DateTime.Parse(releaseDate.release_date); + } + } + } + movie.Ratings = new Ratings(); movie.Ratings.Votes = resource.vote_count; movie.Ratings.Value = (decimal)resource.vote_average; diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 8720a43ff..a4a24ed0e 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -286,6 +286,7 @@ Code + diff --git a/src/NzbDrone.Core/Tv/Movie.cs b/src/NzbDrone.Core/Tv/Movie.cs index e31a66896..24329b987 100644 --- a/src/NzbDrone.Core/Tv/Movie.cs +++ b/src/NzbDrone.Core/Tv/Movie.cs @@ -41,6 +41,7 @@ namespace NzbDrone.Core.Tv public string RootFolderPath { get; set; } public DateTime Added { get; set; } public DateTime? InCinemas { get; set; } + public DateTime? PhysicalRelease { get; set; } public LazyLoaded Profile { get; set; } public HashSet Tags { get; set; } public AddMovieOptions AddOptions { get; set; }