Added trailer link to movie links (#255) (#282)

* added YouTubeTrailerId to movie model
* db migration for new column

* added videos to append_to_response for tmdb
* increased height of .series-posters-item
* new handlebar helper to build the trailer url
Vlad Ilies 7 years ago committed by Tim Turner
parent af478d3799
commit 56a5b6ec89

@ -34,6 +34,7 @@ namespace NzbDrone.Api.Movie
public string RemotePoster { get; set; }
public int Year { get; set; }
public bool HasFile { get; set; }
public string YouTubeTrailerId { get; set; }
//View & Edit
public string Path { get; set; }
@ -144,7 +145,8 @@ namespace NzbDrone.Api.Movie
AddOptions = model.AddOptions,
AlternativeTitles = model.AlternativeTitles,
Ratings = model.Ratings,
MovieFile = movieFile
MovieFile = movieFile,
YouTubeTrailerId = model.YouTubeTrailerId
};
}
@ -191,7 +193,8 @@ namespace NzbDrone.Api.Movie
Added = resource.Added,
AddOptions = resource.AddOptions,
AlternativeTitles = resource.AlternativeTitles,
Ratings = resource.Ratings
Ratings = resource.Ratings,
YouTubeTrailerId = resource.YouTubeTrailerId
};
}

@ -0,0 +1,21 @@
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(119)]
public class add_youtube_trailer_id : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("Movies").AddColumn("YouTubeTrailerId").AsString().Nullable();
}
}
}

@ -66,6 +66,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook.Resource
public int vote_count { get; set; }
public AlternativeTitles alternative_titles { get; set; }
public ReleaseDatesResource release_dates { get; set; }
public VideosResource videos { get; set; }
}
public class ReleaseDatesResource
@ -130,4 +131,21 @@ namespace NzbDrone.Core.MetadataSource.SkyHook.Resource
public string iso_3166_1 { get; set; }
public string title { get; set; }
}
public class VideosResource
{
public List<Video> results { get; set; }
}
public class Video
{
public string id { get; set; }
public string iso_639_1 { get; set; }
public string iso_3166_1 { get; set; }
public string key { get; set; }
public string name { get; set; }
public string site { get; set; }
public string size { get; set; }
public string type { get; set; }
}
}

@ -73,7 +73,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
.SetSegment("route", "movie")
.SetSegment("id", TmdbId.ToString())
.SetSegment("secondaryRoute", "")
.AddQueryParam("append_to_response", "alternative_titles,release_dates")
.AddQueryParam("append_to_response", "alternative_titles,release_dates,videos")
.AddQueryParam("country", "US")
.Build();
@ -149,6 +149,18 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{
movie.Status = MovieStatusType.Announced;
}
if (resource.videos != null)
{
foreach(Video video in resource.videos.results)
{
if(video.type == "Trailer" && video.site == "YouTube")
{
movie.YouTubeTrailerId = video.key;
break;
}
}
}
return movie;
}

@ -183,6 +183,7 @@
<Compile Include="Datastore\Migration\002_remove_tvrage_imdb_unique_constraint.cs" />
<Compile Include="Datastore\Migration\003_remove_clean_title_from_scene_mapping.cs" />
<Compile Include="Datastore\Migration\004_updated_history.cs" />
<Compile Include="Datastore\Migration\119_add_youtube_trailer_id_table .cs" />
<Compile Include="Datastore\Migration\118_update_movie_slug.cs" />
<Compile Include="Datastore\Migration\117_update_movie_file.cs" />
<Compile Include="Datastore\Migration\116_update_movie_sorttitle_again.cs" />

@ -48,6 +48,7 @@ namespace NzbDrone.Core.Tv
public LazyLoaded<MovieFile> MovieFile { get; set; }
public int MovieFileId { get; set; }
public List<string> AlternativeTitles { get; set; }
public string YouTubeTrailerId{ get; set; }
public bool HasFile => MovieFileId > 0;

@ -84,6 +84,7 @@ namespace NzbDrone.Core.Tv
movie.AlternativeTitles = movieInfo.AlternativeTitles;
movie.Year = movieInfo.Year;
movie.PhysicalRelease = movieInfo.PhysicalRelease;
movie.YouTubeTrailerId = movieInfo.YouTubeTrailerId;
try
{

@ -8,4 +8,9 @@
{{#if imdbId}}
<a href="{{imdbUrl}}" class="label label-info">IMDB</a>
{{/if}}
{{#if youTubeTrailerId}}
<a href="{{youTubeTrailerUrl}}" class="label label-info">Trailer</a>
{{/if}}
</span>

@ -51,6 +51,10 @@ Handlebars.registerHelper('tmdbUrl', function() {
return 'https://www.themoviedb.org/movie/' + this.tmdbId;
});
Handlebars.registerHelper('youTubeTrailerUrl', function() {
return 'https://www.youtube.com/watch?v=' + this.youTubeTrailerId;
});
Handlebars.registerHelper('homepage', function() {
return this.website;
});

@ -33,6 +33,10 @@
{{#if imdbId}}
<a href="{{imdbUrl}}" class="label label-info">IMDB</a>
{{/if}}
{{#if youTubeTrailerId}}
<a href="{{youTubeTrailerUrl}}" class="label label-info">Trailer</a>
{{/if}}
</span>
</div>
</div>

@ -54,6 +54,10 @@
{{#if imdbId}}
<a href="{{imdbUrl}}" class="label label-info">IMDB</a>
{{/if}}
{{#if youTubeTrailerId}}
<a href="{{youTubeTrailerUrl}}" class="label label-info">Trailer</a>
{{/if}}
</span>
</div>
</div>

@ -26,7 +26,9 @@
{{#if imdbId}}
<a href="{{imdbUrl}}" class="label label-info">IMDB</a>
{{/if}}
{{#if youTubeTrailerId}}
<a href="{{youTubeTrailerUrl}}" class="label label-info">Trailer</a>
{{/if}}
</div>
</div>
</div>

@ -126,7 +126,7 @@
.card;
.clickable;
margin-bottom : 20px;
height : 324px;
height : 344px;
.center {
display : block;
@ -166,7 +166,7 @@
}
@media (max-width: @screen-xs-max) {
height : 235px;
height : 268px;
margin : 5px;
padding : 6px 5px;

Loading…
Cancel
Save