MovieDbSeriesProvider and MovieDbEpisodeProvider: Add support for trailers
This commit is contained in:
parent
79128e6d85
commit
75840c7065
|
@ -114,6 +114,22 @@ namespace MediaBrowser.Providers.TV
|
|||
item.CommunityRating = (float)response.vote_average;
|
||||
item.VoteCount = response.vote_count;
|
||||
|
||||
if (response.videos != null && response.videos.results != null)
|
||||
{
|
||||
foreach (var video in response.videos.results)
|
||||
{
|
||||
if (video.type.Equals("trailer", System.StringComparison.OrdinalIgnoreCase)
|
||||
|| video.type.Equals("clip", System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (video.site.Equals("youtube", System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var videoUrl = string.Format("http://www.youtube.com/watch?v={0}", video.key);
|
||||
item.AddTrailerUrl(videoUrl, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.ResetPeople();
|
||||
|
||||
var credits = response.credits;
|
||||
|
|
|
@ -210,7 +210,19 @@ namespace MediaBrowser.Providers.TV
|
|||
|
||||
public class Videos
|
||||
{
|
||||
public List<object> results { get; set; }
|
||||
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; }
|
||||
}
|
||||
|
||||
public class RootObject
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace MediaBrowser.Providers.TV
|
|||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
result.Item = await FetchMovieData(tmdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||
result.Item = await FetchSeriesData(tmdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
result.HasMetadata = result.Item != null;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ namespace MediaBrowser.Providers.TV
|
|||
return result;
|
||||
}
|
||||
|
||||
private async Task<Series> FetchMovieData(string tmdbId, string language, string preferredCountryCode, CancellationToken cancellationToken)
|
||||
private async Task<Series> FetchSeriesData(string tmdbId, string language, string preferredCountryCode, CancellationToken cancellationToken)
|
||||
{
|
||||
string dataFilePath = null;
|
||||
RootObject seriesInfo = null;
|
||||
|
@ -285,6 +285,21 @@ namespace MediaBrowser.Providers.TV
|
|||
series.OfficialRating = minimumRelease.rating;
|
||||
}
|
||||
|
||||
if (seriesInfo.videos != null && seriesInfo.videos.results != null)
|
||||
{
|
||||
foreach (var video in seriesInfo.videos.results)
|
||||
{
|
||||
if (video.type.Equals("trailer", System.StringComparison.OrdinalIgnoreCase)
|
||||
|| video.type.Equals("clip", System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (video.site.Equals("youtube", System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var videoUrl = string.Format("http://www.youtube.com/watch?v={0}", video.key);
|
||||
series.AddTrailerUrl(videoUrl, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetSeriesDataPath(IApplicationPaths appPaths, string tmdbId)
|
||||
|
@ -555,7 +570,19 @@ namespace MediaBrowser.Providers.TV
|
|||
|
||||
public class Videos
|
||||
{
|
||||
public List<object> results { get; set; }
|
||||
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; }
|
||||
}
|
||||
|
||||
public class ContentRating
|
||||
|
|
Loading…
Reference in New Issue
Block a user