Merge pull request #1668 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-04-19 22:38:52 -04:00
commit 0a1e9299d3
3 changed files with 39 additions and 8 deletions

View File

@ -762,7 +762,6 @@ namespace MediaBrowser.Providers.Manager
var resultList = new List<RemoteSearchResult>(); var resultList = new List<RemoteSearchResult>();
var foundProviderIds = new Dictionary<Tuple<string, string>, RemoteSearchResult>(); var foundProviderIds = new Dictionary<Tuple<string, string>, RemoteSearchResult>();
var foundTitleYearStrings = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var provider in providers) foreach (var provider in providers)
{ {

View File

@ -74,7 +74,6 @@ namespace MediaBrowser.Providers.Omdb
episodeSearchInfo.SeriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out imdbId); episodeSearchInfo.SeriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out imdbId);
} }
var name = searchInfo.Name; var name = searchInfo.Name;
var year = searchInfo.Year; var year = searchInfo.Year;
@ -107,6 +106,7 @@ namespace MediaBrowser.Providers.Omdb
else else
{ {
url += "&i=" + imdbId; url += "&i=" + imdbId;
isSearch = false;
} }
if (type == "episode") if (type == "episode")

View File

@ -24,7 +24,7 @@ namespace MediaBrowser.Providers.TV
{ {
public class MovieDbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>, IHasOrder public class MovieDbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>, 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"); private readonly CultureInfo _usCulture = new CultureInfo("en-US");
internal static MovieDbSeriesProvider Current { get; private set; } internal static MovieDbSeriesProvider Current { get; private set; }
@ -168,7 +168,7 @@ namespace MediaBrowser.Providers.TV
{ {
cancellationToken.ThrowIfCancellationRequested(); 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; result.HasMetadata = result.Item != null;
} }
@ -176,7 +176,7 @@ namespace MediaBrowser.Providers.TV
return result; return result;
} }
private async Task<Series> FetchMovieData(string tmdbId, string language, CancellationToken cancellationToken) private async Task<Series> FetchMovieData(string tmdbId, string language, string preferredCountryCode, CancellationToken cancellationToken)
{ {
string dataFilePath = null; string dataFilePath = null;
RootObject seriesInfo = null; RootObject seriesInfo = null;
@ -201,12 +201,12 @@ namespace MediaBrowser.Providers.TV
var item = new Series(); var item = new Series();
ProcessMainInfo(item, seriesInfo); ProcessMainInfo(item, seriesInfo, preferredCountryCode);
return item; return item;
} }
private void ProcessMainInfo(Series series, RootObject seriesInfo) private void ProcessMainInfo(Series series, RootObject seriesInfo, string preferredCountryCode)
{ {
series.Name = seriesInfo.name; series.Name = seriesInfo.name;
series.SetProviderId(MetadataProviders.Tmdb, seriesInfo.id.ToString(_usCulture)); 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)); series.SetProviderId(MetadataProviders.Tvdb, ids.tvdb_id.ToString(_usCulture));
} }
} }
var contentRatings = (seriesInfo.content_ratings ?? new ContentRatings()).results ?? new List<ContentRating>();
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) internal static string GetSeriesDataPath(IApplicationPaths appPaths, string tmdbId)
@ -481,6 +501,7 @@ namespace MediaBrowser.Providers.TV
public class Season public class Season
{ {
public string air_date { get; set; } public string air_date { get; set; }
public int episode_count { get; set; }
public int id { get; set; } public int id { get; set; }
public string poster_path { get; set; } public string poster_path { get; set; }
public int season_number { get; set; } public int season_number { get; set; }
@ -528,7 +549,6 @@ namespace MediaBrowser.Providers.TV
public double aspect_ratio { get; set; } public double aspect_ratio { get; set; }
public string file_path { get; set; } public string file_path { get; set; }
public int height { get; set; } public int height { get; set; }
public string id { get; set; }
public string iso_639_1 { get; set; } public string iso_639_1 { get; set; }
public double vote_average { get; set; } public double vote_average { get; set; }
public int vote_count { get; set; } public int vote_count { get; set; }
@ -560,6 +580,17 @@ namespace MediaBrowser.Providers.TV
public List<object> results { get; set; } public List<object> results { get; set; }
} }
public class ContentRating
{
public string iso_3166_1 { get; set; }
public string rating { get; set; }
}
public class ContentRatings
{
public List<ContentRating> results { get; set; }
}
public class RootObject public class RootObject
{ {
public string backdrop_path { get; set; } public string backdrop_path { get; set; }
@ -590,6 +621,7 @@ namespace MediaBrowser.Providers.TV
public Keywords keywords { get; set; } public Keywords keywords { get; set; }
public ExternalIds external_ids { get; set; } public ExternalIds external_ids { get; set; }
public Videos videos { get; set; } public Videos videos { get; set; }
public ContentRatings content_ratings { get; set; }
} }
public int Order public int Order