Merge pull request #59 from galli-leo/feature/release-dates

Physical release dates now are retreived and stored.
pull/2/head
Leonardo Galli 8 years ago committed by GitHub
commit f35fae109b

@ -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<MediaCover> 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

@ -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();
}
}
}

@ -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<ReleaseDates> 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<ReleaseDate> release_dates { get; set; }
}
public class Belongs_To_Collection

@ -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;

@ -286,6 +286,7 @@
<Compile Include="Datastore\Migration\098_remove_titans_of_tv.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Datastore\Migration\110_add_physical_release_to_table.cs" />
<Compile Include="Datastore\Migration\109_add_movie_formats_to_naming_config.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.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> Profile { get; set; }
public HashSet<int> Tags { get; set; }
public AddMovieOptions AddOptions { get; set; }

@ -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
{

@ -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() {

Loading…
Cancel
Save