From cc1ba34b4f0e35a32b7f9b4f12965a859d8fea5e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 4 Jul 2014 23:17:24 -0400 Subject: [PATCH] grab more info from the movie db for tv --- .../Movies/MovieDbProvider.cs | 16 +++---- .../TV/MovieDbSeasonProvider.cs | 1 + .../TV/MovieDbSeriesProvider.cs | 45 ++++++++++++++++++- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index d812abe9f6..65fe32a991 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.Movies private readonly ILocalizationManager _localization; private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - + public MovieDbProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILogger logger, ILocalizationManager localization) { _jsonSerializer = jsonSerializer; @@ -90,7 +90,7 @@ namespace MediaBrowser.Providers.Movies remoteResult.ProductionYear = remoteResult.PremiereDate.Value.Year; } } - + remoteResult.SetProviderId(MetadataProviders.Tmdb, obj.id.ToString(_usCulture)); if (!string.IsNullOrWhiteSpace(obj.imdb_id)) @@ -286,8 +286,9 @@ namespace MediaBrowser.Providers.Movies url += string.Format("&language={0}", language); } + var includeImageLanguageParam = string.Join(",", imageLanguages.ToArray()); // Get images in english and with no language - url += "&include_image_language=" + string.Join(",", imageLanguages.ToArray()); + url += "&include_image_language=" + includeImageLanguageParam; CompleteMovieData mainResult; @@ -312,7 +313,7 @@ namespace MediaBrowser.Providers.Movies { _logger.Info("MovieDbProvider couldn't find meta for language " + language + ". Trying English..."); - url = string.Format(GetMovieInfo3, id, ApiKey) + "&include_image_language=en,null&language=en"; + url = string.Format(GetMovieInfo3, id, ApiKey) + "&include_image_language=" + includeImageLanguageParam + "&language=en"; using (var json = await GetMovieDbResponse(new HttpRequestOptions { @@ -324,14 +325,9 @@ namespace MediaBrowser.Providers.Movies { mainResult = _jsonSerializer.DeserializeFromStream(json); } - - if (String.IsNullOrEmpty(mainResult.overview)) - { - _logger.Error("MovieDbProvider - Unable to find information for (id:" + id + ")"); - return null; - } } } + return mainResult; } diff --git a/MediaBrowser.Providers/TV/MovieDbSeasonProvider.cs b/MediaBrowser.Providers/TV/MovieDbSeasonProvider.cs index 990252455c..0c5eec06cb 100644 --- a/MediaBrowser.Providers/TV/MovieDbSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/MovieDbSeasonProvider.cs @@ -79,6 +79,7 @@ namespace MediaBrowser.Providers.TV } result.Item.PremiereDate = seasonInfo.air_date; + result.Item.ProductionYear = result.Item.PremiereDate.Value.Year; } return result; diff --git a/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs b/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs index fc53d4c151..ec02d3add9 100644 --- a/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/MovieDbSeriesProvider.cs @@ -23,7 +23,7 @@ namespace MediaBrowser.Providers.TV { public class MovieDbSeriesProvider : IRemoteMetadataProvider, IHasOrder { - private const string GetTvInfo3 = @"http://api.themoviedb.org/3/tv/{0}?api_key={1}&append_to_response=casts,images,keywords,external_ids"; + private const string GetTvInfo3 = @"http://api.themoviedb.org/3/tv/{0}?api_key={1}&append_to_response=credits,images,keywords,external_ids,videos"; private readonly CultureInfo _usCulture = new CultureInfo("en-US"); internal static MovieDbSeriesProvider Current { get; private set; } @@ -349,7 +349,7 @@ namespace MediaBrowser.Providers.TV if (fileInfo.Exists) { // If it's recent or automatic updates are enabled, don't re-download - if ((DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 7) + if ((DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 3) { return _cachedTask; } @@ -464,10 +464,37 @@ namespace MediaBrowser.Providers.TV public class Season { public string air_date { get; set; } + public int id { get; set; } public string poster_path { get; set; } public int season_number { get; set; } } + public class Cast + { + public string character { get; set; } + public string credit_id { get; set; } + public int id { get; set; } + public string name { get; set; } + public string profile_path { get; set; } + public int order { get; set; } + } + + public class Crew + { + public string credit_id { get; set; } + public string department { get; set; } + public int id { get; set; } + public string name { get; set; } + public string job { get; set; } + public string profile_path { get; set; } + } + + public class Credits + { + public List cast { get; set; } + public List crew { get; set; } + } + public class Backdrop { public double aspect_ratio { get; set; } @@ -484,6 +511,7 @@ namespace MediaBrowser.Providers.TV public double aspect_ratio { get; set; } public string file_path { get; set; } public int height { get; set; } + public string id { get; set; } public string iso_639_1 { get; set; } public double vote_average { get; set; } public int vote_count { get; set; } @@ -496,6 +524,11 @@ namespace MediaBrowser.Providers.TV public List posters { get; set; } } + public class Keywords + { + public List results { get; set; } + } + public class ExternalIds { public string imdb_id { get; set; } @@ -505,6 +538,11 @@ namespace MediaBrowser.Providers.TV public int tvrage_id { get; set; } } + public class Videos + { + public List results { get; set; } + } + public class RootObject { public string backdrop_path { get; set; } @@ -530,8 +568,11 @@ namespace MediaBrowser.Providers.TV public string status { get; set; } public double vote_average { get; set; } public int vote_count { get; set; } + public Credits credits { get; set; } public Images images { get; set; } + public Keywords keywords { get; set; } public ExternalIds external_ids { get; set; } + public Videos videos { get; set; } } public int Order