From 9dee1d6fad400f4868db058e93f51cde50f68904 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Sat, 20 May 2017 14:31:38 +0200 Subject: [PATCH] Discovery of upcoming movies points to our server now. Discovery results now show physical release date (if present). All physical release dates now should show a note (if available) detailing what kind of release date it is (e.g. Netflix, DVD, Streaming, etc.) --- src/NzbDrone.Api/Series/MovieResource.cs | 3 +++ .../138_add_physical_release_note.cs | 16 +++++++++++++++ .../SkyHook/Resource/TMDBResources.cs | 2 ++ .../MetadataSource/SkyHook/SkyHookProxy.cs | 20 +++++++++++++++---- src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + src/NzbDrone.Core/Tv/Movie.cs | 1 + src/UI/AddMovies/SearchResultViewTemplate.hbs | 8 +++++--- src/UI/Movies/Details/InfoViewTemplate.hbs | 2 +- 8 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 src/NzbDrone.Core/Datastore/Migration/138_add_physical_release_note.cs diff --git a/src/NzbDrone.Api/Series/MovieResource.cs b/src/NzbDrone.Api/Series/MovieResource.cs index 5491c636a..fcd71aa8f 100644 --- a/src/NzbDrone.Api/Series/MovieResource.cs +++ b/src/NzbDrone.Api/Series/MovieResource.cs @@ -28,6 +28,7 @@ public MovieResource() public string Overview { get; set; } public DateTime? InCinemas { get; set; } public DateTime? PhysicalRelease { get; set; } + public string PhysicalReleaseNote { get; set; } public List Images { get; set; } public string Website { get; set; } public bool Downloaded { get; set; } @@ -116,6 +117,7 @@ public static MovieResource ToResource(this Core.Tv.Movie model) SortTitle = model.SortTitle, InCinemas = model.InCinemas, PhysicalRelease = model.PhysicalRelease, + PhysicalReleaseNote = model.PhysicalReleaseNote, HasFile = model.HasFile, Downloaded = downloaded, //TotalEpisodeCount @@ -176,6 +178,7 @@ public static Core.Tv.Movie ToModel(this MovieResource resource) SortTitle = resource.SortTitle, InCinemas = resource.InCinemas, PhysicalRelease = resource.PhysicalRelease, + PhysicalReleaseNote = resource.PhysicalReleaseNote, //TotalEpisodeCount //EpisodeCount //EpisodeFileCount diff --git a/src/NzbDrone.Core/Datastore/Migration/138_add_physical_release_note.cs b/src/NzbDrone.Core/Datastore/Migration/138_add_physical_release_note.cs new file mode 100644 index 000000000..f24c8dcf9 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/138_add_physical_release_note.cs @@ -0,0 +1,16 @@ +using System.Data; +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(138)] + public class add_physical_release_note : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("Movies").AddColumn("PhysicalReleaseNote").AsString().Nullable(); + } + } +} diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/TMDBResources.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/TMDBResources.cs index b3aa65ac2..05bd960dc 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/TMDBResources.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/TMDBResources.cs @@ -36,6 +36,8 @@ public class MovieResult public float vote_average { get; set; } public string trailer_key { get; set; } public string trailer_site { get; set; } + public string physical_release { get; set; } + public string physical_release_note { get; set; } } diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 2f7b5f2a6..ee968bbdd 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -191,11 +191,13 @@ public Movie GetMovieInfo(int TmdbId, Profile profile = null, bool hasPreDBEntry if (movie.PhysicalRelease.Value.After(DateTime.Parse(releaseDate.release_date))) { movie.PhysicalRelease = DateTime.Parse(releaseDate.release_date); //Use oldest release date available. + movie.PhysicalReleaseNote = releaseDate.note; } } else { movie.PhysicalRelease = DateTime.Parse(releaseDate.release_date); + movie.PhysicalReleaseNote = releaseDate.note; } } } @@ -363,7 +365,7 @@ public List DiscoverNewMovies(string action) HttpRequest request; List results; - if (action == "upcoming") + /*if (action == "upcoming") { var lastWeek = DateTime.Now.AddDays(-7); var threeWeeks = DateTime.Now.AddDays(7 * 3); @@ -388,7 +390,7 @@ public List DiscoverNewMovies(string action) results = response.Resource.results.ToList(); } else - { + {*/ request = new HttpRequestBuilder("https://radarr.video/api/{action}/").SetSegment("action", action).Build(); request.AllowAutoRedirect = true; @@ -404,7 +406,7 @@ public List DiscoverNewMovies(string action) } results = response.Resource; - } + //} results = results.Where(m => allMovies.None(mo => mo.TmdbId == m.id) && allExclusions.None(ex => ex.TmdbId == m.id)).ToList(); @@ -577,7 +579,17 @@ private Movie MapMovie(MovieResult result) imdbMovie.Year = imdbMovie.InCinemas.Value.Year; } - var now = DateTime.Now; + if (result.physical_release.IsNotNullOrWhiteSpace()) + { + imdbMovie.PhysicalRelease = DateTime.Parse(result.physical_release); + if (result.physical_release_note.IsNotNullOrWhiteSpace()) + { + imdbMovie.PhysicalReleaseNote = result.physical_release_note; + } + } + + + var now = DateTime.Now; //handle the case when we have both theatrical and physical release dates if (imdbMovie.InCinemas.HasValue && imdbMovie.PhysicalRelease.HasValue) { diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index d25400946..6218e92f2 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -1284,6 +1284,7 @@ + diff --git a/src/NzbDrone.Core/Tv/Movie.cs b/src/NzbDrone.Core/Tv/Movie.cs index 5a859a847..8e22eb096 100644 --- a/src/NzbDrone.Core/Tv/Movie.cs +++ b/src/NzbDrone.Core/Tv/Movie.cs @@ -45,6 +45,7 @@ public Movie() public DateTime Added { get; set; } public DateTime? InCinemas { get; set; } public DateTime? PhysicalRelease { get; set; } + public String PhysicalReleaseNote { get; set; } public LazyLoaded Profile { get; set; } public HashSet Tags { get; set; } public AddMovieOptions AddOptions { get; set; } diff --git a/src/UI/AddMovies/SearchResultViewTemplate.hbs b/src/UI/AddMovies/SearchResultViewTemplate.hbs index 901654547..cdc6f9c24 100644 --- a/src/UI/AddMovies/SearchResultViewTemplate.hbs +++ b/src/UI/AddMovies/SearchResultViewTemplate.hbs @@ -29,9 +29,11 @@ {{ratings.value}} {{#if youTubeTrailerId}} - - Trailer - + Trailer + {{/if}} + + {{#if physicalRelease}} + {{inCinemas}} {{/if}} diff --git a/src/UI/Movies/Details/InfoViewTemplate.hbs b/src/UI/Movies/Details/InfoViewTemplate.hbs index e8051dc34..c986989a2 100644 --- a/src/UI/Movies/Details/InfoViewTemplate.hbs +++ b/src/UI/Movies/Details/InfoViewTemplate.hbs @@ -20,7 +20,7 @@ {{#if_eq status compare="announced"}} {{inCinemas}} {{else}} - {{inCinemas}} + {{inCinemas}} {{/if_eq}} {{DownloadedStatus}}