diff --git a/src/NzbDrone.Api/Series/MovieResource.cs b/src/NzbDrone.Api/Series/MovieResource.cs index 4038792d7..32bf495a5 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; } public bool Downloaded { get; set; } @@ -89,7 +90,8 @@ namespace NzbDrone.Api.Movie //AlternateTitles SortTitle = model.SortTitle, InCinemas = model.InCinemas, - + PhysicalRelease = model.PhysicalRelease, + Downloaded = model.MovieFile.Value != null, //TotalEpisodeCount //EpisodeCount @@ -140,6 +142,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..f37184518 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,27 @@ 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) + { + if (movie.PhysicalRelease.HasValue) + { + if (movie.PhysicalRelease.Value.After(DateTime.Parse(releaseDate.release_date))) + { + movie.PhysicalRelease = DateTime.Parse(releaseDate.release_date); //Use oldest release date available. + } + } + else + { + 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; } diff --git a/src/NzbDrone.Core/Tv/RefreshMovieService.cs b/src/NzbDrone.Core/Tv/RefreshMovieService.cs index a4ac0d8ec..a0b4a56a9 100644 --- a/src/NzbDrone.Core/Tv/RefreshMovieService.cs +++ b/src/NzbDrone.Core/Tv/RefreshMovieService.cs @@ -83,6 +83,7 @@ namespace NzbDrone.Core.Tv movie.Website = movieInfo.Website; movie.AlternativeTitles = movieInfo.AlternativeTitles; movie.Year = movieInfo.Year; + movie.PhysicalRelease = movieInfo.PhysicalRelease; try { diff --git a/src/UI/Handlebars/Helpers/Series.js b/src/UI/Handlebars/Helpers/Series.js index 41c2d641a..fa642e39f 100644 --- a/src/UI/Handlebars/Helpers/Series.js +++ b/src/UI/Handlebars/Helpers/Series.js @@ -166,10 +166,17 @@ Handlebars.registerHelper('inCinemas', function() { var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; + if (this.physicalRelease) { + var d = new Date(this.physicalRelease); + var day = d.getDate(); + var month = monthNames[d.getMonth()]; + var year = d.getFullYear(); + return "Available: " + day + ". " + month + " " + year; + } var cinemasDate = new Date(this.inCinemas); var year = cinemasDate.getFullYear(); var month = monthNames[cinemasDate.getMonth()]; - return "In Cinemas " + month + " " + year; + return "In Cinemas: " + month + " " + year; }); Handlebars.registerHelper('tvRageUrl', function() {