diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index 06db8a2378..3199ed12b9 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -762,7 +762,6 @@ namespace MediaBrowser.Providers.Manager var resultList = new List(); var foundProviderIds = new Dictionary, RemoteSearchResult>(); - var foundTitleYearStrings = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (var provider in providers) { diff --git a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs index 894750c812..1b8ecd5211 100644 --- a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs @@ -74,7 +74,6 @@ namespace MediaBrowser.Providers.Omdb episodeSearchInfo.SeriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out imdbId); } - var name = searchInfo.Name; var year = searchInfo.Year; @@ -107,6 +106,7 @@ namespace MediaBrowser.Providers.Omdb else { url += "&i=" + imdbId; + isSearch = false; } if (type == "episode") diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs index 05b1ebc80c..98580396d2 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs @@ -24,7 +24,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=credits,images,keywords,external_ids,videos"; + private const string GetTvInfo3 = @"http://api.themoviedb.org/3/tv/{0}?api_key={1}&append_to_response=credits,images,keywords,external_ids,videos,content_ratings"; private readonly CultureInfo _usCulture = new CultureInfo("en-US"); internal static MovieDbSeriesProvider Current { get; private set; } @@ -168,7 +168,7 @@ namespace MediaBrowser.Providers.TV { cancellationToken.ThrowIfCancellationRequested(); - result.Item = await FetchMovieData(tmdbId, info.MetadataLanguage, cancellationToken).ConfigureAwait(false); + result.Item = await FetchMovieData(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 FetchMovieData(string tmdbId, string language, CancellationToken cancellationToken) + private async Task FetchMovieData(string tmdbId, string language, string preferredCountryCode, CancellationToken cancellationToken) { string dataFilePath = null; RootObject seriesInfo = null; @@ -201,12 +201,12 @@ namespace MediaBrowser.Providers.TV var item = new Series(); - ProcessMainInfo(item, seriesInfo); + ProcessMainInfo(item, seriesInfo, preferredCountryCode); return item; } - private void ProcessMainInfo(Series series, RootObject seriesInfo) + private void ProcessMainInfo(Series series, RootObject seriesInfo, string preferredCountryCode) { series.Name = seriesInfo.name; series.SetProviderId(MetadataProviders.Tmdb, seriesInfo.id.ToString(_usCulture)); @@ -265,6 +265,26 @@ namespace MediaBrowser.Providers.TV series.SetProviderId(MetadataProviders.Tvdb, ids.tvdb_id.ToString(_usCulture)); } } + + var contentRatings = (seriesInfo.content_ratings ?? new ContentRatings()).results ?? new List(); + + var ourRelease = contentRatings.FirstOrDefault(c => string.Equals(c.iso_3166_1, preferredCountryCode, StringComparison.OrdinalIgnoreCase)); + var usRelease = contentRatings.FirstOrDefault(c => string.Equals(c.iso_3166_1, "US", StringComparison.OrdinalIgnoreCase)); + var minimumRelease = contentRatings.FirstOrDefault(); + + if (ourRelease != null) + { + series.OfficialRating = ourRelease.rating; + } + else if (usRelease != null) + { + series.OfficialRating = usRelease.rating; + } + else if (minimumRelease != null) + { + series.OfficialRating = minimumRelease.rating; + } + } internal static string GetSeriesDataPath(IApplicationPaths appPaths, string tmdbId) @@ -481,6 +501,7 @@ namespace MediaBrowser.Providers.TV public class Season { public string air_date { get; set; } + public int episode_count { get; set; } public int id { get; set; } public string poster_path { get; set; } public int season_number { get; set; } @@ -528,7 +549,6 @@ 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; } @@ -560,6 +580,17 @@ namespace MediaBrowser.Providers.TV public List results { get; set; } } + public class ContentRating + { + public string iso_3166_1 { get; set; } + public string rating { get; set; } + } + + public class ContentRatings + { + public List results { get; set; } + } + public class RootObject { public string backdrop_path { get; set; } @@ -590,6 +621,7 @@ namespace MediaBrowser.Providers.TV public Keywords keywords { get; set; } public ExternalIds external_ids { get; set; } public Videos videos { get; set; } + public ContentRatings content_ratings { get; set; } } public int Order