diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
index e2d0562377..3ad8b93714 100644
--- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
@@ -258,7 +258,7 @@ namespace MediaBrowser.Api.Playback.Progressive
// webm
if (videoCodec.Equals("libvpx", StringComparison.OrdinalIgnoreCase))
{
- args = "-quality realtime -speed 0 -qmin 0 -qmax 30 -profile:v 0 -slices 8";
+ args = "-speed 16 -quality good -profile:v 0 -slices 8";
}
// asf/wmv
diff --git a/MediaBrowser.Controller/Entities/UserItemData.cs b/MediaBrowser.Controller/Entities/UserItemData.cs
index 8328e385b4..c039f40149 100644
--- a/MediaBrowser.Controller/Entities/UserItemData.cs
+++ b/MediaBrowser.Controller/Entities/UserItemData.cs
@@ -22,8 +22,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the users 0-10 rating
///
/// The rating.
- /// A 0-10 rating is required for UserItemData.
- /// A 0-10 rating is required for UserItemData.
+ /// Rating;A 0 to 10 rating is required for UserItemData.
public float? Rating
{
get
@@ -36,7 +35,7 @@ namespace MediaBrowser.Controller.Entities
{
if (value.Value < 0 || value.Value > 10)
{
- throw new ArgumentOutOfRangeException("A 0-10 rating is required for UserItemData.");
+ throw new ArgumentOutOfRangeException("value", "A 0 to 10 rating is required for UserItemData.");
}
}
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index cb7f635adf..8c1cc5163b 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -116,8 +116,8 @@
+
-
diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs
index 1747f3003f..9bd1e2811a 100644
--- a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs
+++ b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs
@@ -148,7 +148,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
///
/// The val.
/// System.String[][].
- private string[] Split(string val)
+ private IEnumerable Split(string val)
{
// Only use the comma as a delimeter if there are no slashes or pipes.
// We want to be careful not to split names that have commas in them
diff --git a/MediaBrowser.Controller/Providers/Movies/RottenTomatoesMovieReviewsProvider.cs b/MediaBrowser.Controller/Providers/Movies/OpenMovieDatabaseProvider.cs
similarity index 58%
rename from MediaBrowser.Controller/Providers/Movies/RottenTomatoesMovieReviewsProvider.cs
rename to MediaBrowser.Controller/Providers/Movies/OpenMovieDatabaseProvider.cs
index 3e2a5b558c..10ddb4516c 100644
--- a/MediaBrowser.Controller/Providers/Movies/RottenTomatoesMovieReviewsProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/OpenMovieDatabaseProvider.cs
@@ -7,21 +7,15 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using System;
-using System.Collections.Generic;
-using System.Linq;
+using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Providers.Movies
{
- ///
- /// Class RottenTomatoesMovieProvider
- ///
- public class RottenTomatoesMovieReviewsProvider : BaseMetadataProvider
+ public class OpenMovieDatabaseProvider : BaseMetadataProvider
{
- // http://developer.rottentomatoes.com/iodocs
-
- private const string MoviesReviews = @"movies/{1}/reviews.json?review_type=top_critic&page_limit=10&page=1&country=us&apikey={0}";
+ private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);
///
/// Gets the json serializer.
@@ -35,14 +29,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// The HTTP client.
protected IHttpClient HttpClient { get; private set; }
- ///
- /// Initializes a new instance of the class.
- ///
- /// The log manager.
- /// The configuration manager.
- /// The json serializer.
- /// The HTTP client.
- public RottenTomatoesMovieReviewsProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
+ public OpenMovieDatabaseProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
: base(logManager, configurationManager)
{
JsonSerializer = jsonSerializer;
@@ -57,7 +44,7 @@ namespace MediaBrowser.Controller.Providers.Movies
{
get
{
- return "5";
+ return "6";
}
}
@@ -92,15 +79,14 @@ namespace MediaBrowser.Controller.Providers.Movies
/// true if XXXX, false otherwise
public override bool Supports(BaseItem item)
{
- return false;
var trailer = item as Trailer;
+ // Don't support local trailers
if (trailer != null)
{
return !trailer.IsLocalTrailer;
}
- // Don't support local trailers
return item is Movie;
}
@@ -136,7 +122,7 @@ namespace MediaBrowser.Controller.Providers.Movies
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
// Refresh if rt id has changed
- if (providerInfo.Data != GetComparisonData(item.GetProviderId(MetadataProviders.RottenTomatoes)))
+ if (providerInfo.Data != GetComparisonData(item.GetProviderId(MetadataProviders.Imdb)))
{
return true;
}
@@ -144,13 +130,8 @@ namespace MediaBrowser.Controller.Providers.Movies
return base.NeedsRefreshInternal(item, providerInfo);
}
- ///
- /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
- ///
- /// The item.
- /// if set to true [force].
- /// The cancellation token.
- /// Task{System.Boolean}.
+ protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
+
public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
BaseProviderInfo data;
@@ -161,76 +142,85 @@ namespace MediaBrowser.Controller.Providers.Movies
item.ProviderData[Id] = data;
}
- var rottenTomatoesId = item.GetProviderId(MetadataProviders.RottenTomatoes);
+ var imdbId = item.GetProviderId(MetadataProviders.Imdb);
-
- if (string.IsNullOrEmpty(rottenTomatoesId))
+ if (string.IsNullOrEmpty(imdbId))
{
- data.Data = GetComparisonData(rottenTomatoesId);
+ data.Data = GetComparisonData(imdbId);
data.LastRefreshStatus = ProviderRefreshStatus.Success;
return true;
}
+ var imdbParam = imdbId.StartsWith("tt", StringComparison.OrdinalIgnoreCase) ? imdbId : "tt" + imdbId;
+
+ var url = string.Format("http://www.omdbapi.com/?i={0}&tomatoes=true", imdbParam);
+
using (var stream = await HttpClient.Get(new HttpRequestOptions
{
- Url = GetMovieReviewsUrl(rottenTomatoesId),
- ResourcePool = RottenTomatoesMovieProvider.Current.RottenTomatoesResourcePool,
+ Url = url,
+ ResourcePool = _resourcePool,
CancellationToken = cancellationToken,
EnableResponseCache = true
}).ConfigureAwait(false))
{
+ var result = JsonSerializer.DeserializeFromStream(stream);
- var result = JsonSerializer.DeserializeFromStream(stream);
+ int tomatoMeter;
- item.CriticReviews = result.reviews.Select(rtReview => new ItemReview
+ if (!string.IsNullOrEmpty(result.tomatoMeter) && int.TryParse(result.tomatoMeter, NumberStyles.Integer, UsCulture, out tomatoMeter))
{
- ReviewerName = rtReview.critic,
- Publisher = rtReview.publication,
- Date = DateTime.Parse(rtReview.date).ToUniversalTime(),
- Caption = rtReview.quote,
- Url = rtReview.links.review,
- Likes = string.Equals(rtReview.freshness, "fresh", StringComparison.OrdinalIgnoreCase)
-
- }).ToList();
- }
+ item.CriticRating = tomatoMeter;
+ }
- data.Data = GetComparisonData(rottenTomatoesId);
+ if (!string.IsNullOrEmpty(result.tomatoConsensus)
+ && !string.Equals(result.tomatoConsensus, "n/a", StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase))
+ {
+ item.CriticRatingSummary = result.tomatoConsensus;
+ }
+ }
+
+ data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Imdb));
data.LastRefreshStatus = ProviderRefreshStatus.Success;
SetLastRefreshed(item, DateTime.UtcNow);
return true;
}
- // Utility functions to get the URL of the API calls
-
- private string GetMovieReviewsUrl(string rtId)
- {
- return RottenTomatoesMovieProvider.BasicUrl + string.Format(MoviesReviews, RottenTomatoesMovieProvider.ApiKey, rtId);
- }
-
- // Data contract classes for use with the Rotten Tomatoes API
-
- protected class RTReviewList
- {
- public int total { get; set; }
- public List reviews { get; set; }
- }
-
- protected class RTReview
- {
- public string critic { get; set; }
- public string date { get; set; }
- public string freshness { get; set; }
- public string publication { get; set; }
- public string quote { get; set; }
- public RTReviewLink links { get; set; }
- public string original_score { get; set; }
- }
- protected class RTReviewLink
+ protected class RootObject
{
- public string review { get; set; }
+ public string Title { get; set; }
+ public string Year { get; set; }
+ public string Rated { get; set; }
+ public string Released { get; set; }
+ public string Runtime { get; set; }
+ public string Genre { get; set; }
+ public string Director { get; set; }
+ public string Writer { get; set; }
+ public string Actors { get; set; }
+ public string Plot { get; set; }
+ public string Poster { get; set; }
+ public string imdbRating { get; set; }
+ public string imdbVotes { get; set; }
+ public string imdbID { get; set; }
+ public string Type { get; set; }
+ public string tomatoMeter { get; set; }
+ public string tomatoImage { get; set; }
+ public string tomatoRating { get; set; }
+ public string tomatoReviews { get; set; }
+ public string tomatoFresh { get; set; }
+ public string tomatoRotten { get; set; }
+ public string tomatoConsensus { get; set; }
+ public string tomatoUserMeter { get; set; }
+ public string tomatoUserRating { get; set; }
+ public string tomatoUserReviews { get; set; }
+ public string DVD { get; set; }
+ public string BoxOffice { get; set; }
+ public string Production { get; set; }
+ public string Website { get; set; }
+ public string Response { get; set; }
}
}
-}
\ No newline at end of file
+}
diff --git a/MediaBrowser.Controller/Providers/Movies/RottenTomatoesMovieProvider.cs b/MediaBrowser.Controller/Providers/Movies/RottenTomatoesMovieProvider.cs
index acf8c8da6a..1ddc8d72c8 100644
--- a/MediaBrowser.Controller/Providers/Movies/RottenTomatoesMovieProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/RottenTomatoesMovieProvider.cs
@@ -17,23 +17,18 @@ namespace MediaBrowser.Controller.Providers.Movies
///
/// Class RottenTomatoesMovieProvider
///
- public class RottenTomatoesMovieProvider : BaseMetadataProvider
+ public class RottenTomatoesProvider : BaseMetadataProvider
{
// http://developer.rottentomatoes.com/iodocs
- ///
- /// The API key
- ///
- internal const string ApiKey = "x9wjnvv39ntjmt9zs95nm7bg";
- internal const string BasicUrl = @"http://api.rottentomatoes.com/api/public/v1.0/";
- private const string MovieImdb = @"movie_alias.json?id={1}&type=imdb&apikey={0}";
+ private const string MoviesReviews = @"movies/{1}/reviews.json?review_type=top_critic&page_limit=10&page=1&country=us&apikey={0}";
- internal static RottenTomatoesMovieProvider Current { get; private set; }
+ private const string ApiKey = "x9wjnvv39ntjmt9zs95nm7bg";
- ///
- /// The _rotten tomatoes resource pool
- ///
- internal readonly SemaphoreSlim RottenTomatoesResourcePool = new SemaphoreSlim(1, 1);
+ private const string BasicUrl = @"http://api.rottentomatoes.com/api/public/v1.0/";
+ private const string MovieImdb = @"movie_alias.json?id={1}&type=imdb&apikey={0}";
+
+ private readonly SemaphoreSlim _rottenTomatoesResourcePool = new SemaphoreSlim(1, 1);
///
/// Gets the json serializer.
@@ -54,12 +49,11 @@ namespace MediaBrowser.Controller.Providers.Movies
/// The configuration manager.
/// The json serializer.
/// The HTTP client.
- public RottenTomatoesMovieProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
+ public RottenTomatoesProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
: base(logManager, configurationManager)
{
JsonSerializer = jsonSerializer;
HttpClient = httpClient;
- Current = this;
}
///
@@ -136,7 +130,7 @@ namespace MediaBrowser.Controller.Providers.Movies
get
{
// Run after moviedb and xml providers
- return MetadataProviderPriority.Third;
+ return MetadataProviderPriority.Last;
}
}
@@ -148,7 +142,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// true if XXXX, false otherwise
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
- // Refresh if imdb id has changed
+ // Refresh if rt id has changed
if (providerInfo.Data != GetComparisonData(item.GetProviderId(MetadataProviders.Imdb)))
{
return true;
@@ -175,7 +169,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
var imdbId = item.GetProviderId(MetadataProviders.Imdb);
-
+
if (string.IsNullOrEmpty(imdbId))
{
data.Data = GetComparisonData(imdbId);
@@ -183,11 +177,54 @@ namespace MediaBrowser.Controller.Providers.Movies
return true;
}
+ await FetchRottenTomatoesId(item, cancellationToken).ConfigureAwait(false);
+
+ using (var stream = await HttpClient.Get(new HttpRequestOptions
+ {
+ Url = GetMovieReviewsUrl(item.GetProviderId(MetadataProviders.RottenTomatoes)),
+ ResourcePool = _rottenTomatoesResourcePool,
+ CancellationToken = cancellationToken,
+ EnableResponseCache = true
+
+ }).ConfigureAwait(false))
+ {
+
+ var result = JsonSerializer.DeserializeFromStream(stream);
+
+ item.CriticReviews = result.reviews.Select(rtReview => new ItemReview
+ {
+ ReviewerName = rtReview.critic,
+ Publisher = rtReview.publication,
+ Date = DateTime.Parse(rtReview.date).ToUniversalTime(),
+ Caption = rtReview.quote,
+ Url = rtReview.links.review,
+ Likes = string.Equals(rtReview.freshness, "fresh", StringComparison.OrdinalIgnoreCase)
+
+ }).ToList();
+ }
+
+ data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Imdb));
+ data.LastRefreshStatus = ProviderRefreshStatus.Success;
+ SetLastRefreshed(item, DateTime.UtcNow);
+
+ return true;
+ }
+
+ ///
+ /// Fetches the rotten tomatoes id.
+ ///
+ /// The item.
+ /// The cancellation token.
+ /// Task.
+ private async Task FetchRottenTomatoesId(BaseItem item, CancellationToken cancellationToken)
+ {
+ var imdbId = item.GetProviderId(MetadataProviders.Imdb);
+
// Have IMDB Id
using (var stream = await HttpClient.Get(new HttpRequestOptions
{
Url = GetMovieImdbUrl(imdbId),
- ResourcePool = RottenTomatoesResourcePool,
+ ResourcePool = _rottenTomatoesResourcePool,
CancellationToken = cancellationToken,
EnableResponseCache = true
@@ -201,23 +238,18 @@ namespace MediaBrowser.Controller.Providers.Movies
item.CriticRatingSummary = hit.critics_consensus;
item.CriticRating = float.Parse(hit.ratings.critics_score);
- data.Data = GetComparisonData(hit.alternate_ids.imdb);
-
- item.SetProviderId(MetadataProviders.Imdb, hit.alternate_ids.imdb);
item.SetProviderId(MetadataProviders.RottenTomatoes, hit.id);
}
}
-
- data.Data = GetComparisonData(imdbId);
- data.LastRefreshStatus = ProviderRefreshStatus.Success;
-
- SetLastRefreshed(item, DateTime.UtcNow);
-
- return true;
}
+
// Utility functions to get the URL of the API calls
+ private string GetMovieReviewsUrl(string rtId)
+ {
+ return BasicUrl + string.Format(MoviesReviews, ApiKey, rtId);
+ }
private string GetMovieImdbUrl(string imdbId)
{
return BasicUrl + string.Format(MovieImdb, ApiKey, imdbId.TrimStart('t'));
@@ -225,6 +257,28 @@ namespace MediaBrowser.Controller.Providers.Movies
// Data contract classes for use with the Rotten Tomatoes API
+ protected class RTReviewList
+ {
+ public int total { get; set; }
+ public List reviews { get; set; }
+ }
+
+ protected class RTReview
+ {
+ public string critic { get; set; }
+ public string date { get; set; }
+ public string freshness { get; set; }
+ public string publication { get; set; }
+ public string quote { get; set; }
+ public RTReviewLink links { get; set; }
+ public string original_score { get; set; }
+ }
+
+ protected class RTReviewLink
+ {
+ public string review { get; set; }
+ }
+
protected class RTSearchResults
{
public int total { get; set; }
@@ -263,5 +317,6 @@ namespace MediaBrowser.Controller.Providers.Movies
{
public string imdb { get; set; }
}
+
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs
index 03c5b1fa80..2993d39da1 100644
--- a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs
@@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Providers.Movies
///
/// The meta file name
///
- protected const string MetaFileName = "mbperson.json";
+ protected const string MetaFileName = "tmdb3.json";
protected readonly IProviderManager ProviderManager;
@@ -66,6 +66,22 @@ namespace MediaBrowser.Controller.Providers.Movies
return item is Person;
}
+ protected override bool RefreshOnVersionChange
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ protected override string ProviderVersion
+ {
+ get
+ {
+ return "2";
+ }
+ }
+
///
/// Needses the refresh internal.
///
@@ -74,6 +90,11 @@ namespace MediaBrowser.Controller.Providers.Movies
/// true if XXXX, false otherwise
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
+ if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
+ {
+ return true;
+ }
+
//we fetch if either info or image needed and haven't already tried recently
return (string.IsNullOrEmpty(item.PrimaryImagePath) || !item.ResolveArgs.ContainsMetaFileByName(MetaFileName))
&& DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
@@ -91,7 +112,6 @@ namespace MediaBrowser.Controller.Providers.Movies
cancellationToken.ThrowIfCancellationRequested();
var person = (Person)item;
- var tasks = new List();
var id = person.GetProviderId(MetadataProviders.Tmdb);
@@ -105,20 +125,7 @@ namespace MediaBrowser.Controller.Providers.Movies
if (!string.IsNullOrEmpty(id))
{
- //get info only if not already saved
- if (!item.ResolveArgs.ContainsMetaFileByName(MetaFileName))
- {
- tasks.Add(FetchInfo(person, id, cancellationToken));
- }
-
- //get image only if not already there
- if (string.IsNullOrEmpty(item.PrimaryImagePath))
- {
- tasks.Add(FetchImages(person, id, cancellationToken));
- }
-
- //and wait for them to complete
- await Task.WhenAll(tasks).ConfigureAwait(false);
+ await FetchInfo(person, id, cancellationToken).ConfigureAwait(false);
}
else
{
@@ -150,6 +157,8 @@ namespace MediaBrowser.Controller.Providers.Movies
}
}
+ protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
+
///
/// Gets the TMDB id.
///
@@ -180,7 +189,7 @@ namespace MediaBrowser.Controller.Providers.Movies
{
}
- return searchResult != null && searchResult.Total_Results > 0 ? searchResult.Results[0].Id.ToString() : null;
+ return searchResult != null && searchResult.Total_Results > 0 ? searchResult.Results[0].Id.ToString(UsCulture) : null;
}
///
@@ -192,12 +201,12 @@ namespace MediaBrowser.Controller.Providers.Movies
/// Task.
private async Task FetchInfo(Person person, string id, CancellationToken cancellationToken)
{
- string url = string.Format(@"http://api.themoviedb.org/3/person/{1}?api_key={0}", MovieDbProvider.ApiKey, id);
+ string url = string.Format(@"http://api.themoviedb.org/3/person/{1}?api_key={0}&append_to_response=credits,images", MovieDbProvider.ApiKey, id);
PersonResult searchResult = null;
try
{
- using (Stream json = await HttpClient.Get(new HttpRequestOptions
+ using (var json = await HttpClient.Get(new HttpRequestOptions
{
Url = url,
CancellationToken = cancellationToken,
@@ -207,10 +216,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}).ConfigureAwait(false))
{
- if (json != null)
- {
- searchResult = JsonSerializer.DeserializeFromStream(json);
- }
+ searchResult = JsonSerializer.DeserializeFromStream(json);
}
}
catch (HttpException)
@@ -219,7 +225,7 @@ namespace MediaBrowser.Controller.Providers.Movies
cancellationToken.ThrowIfCancellationRequested();
- if (searchResult != null && searchResult.Biography != null)
+ if (searchResult != null)
{
ProcessInfo(person, searchResult);
@@ -231,6 +237,8 @@ namespace MediaBrowser.Controller.Providers.Movies
await ProviderManager.SaveToLibraryFilesystem(person, Path.Combine(person.MetaLocation, MetaFileName), memoryStream, cancellationToken);
Logger.Debug("TmdbPersonProvider downloaded and saved information for {0}", person.Name);
+
+ await FetchImages(person, searchResult.images, cancellationToken).ConfigureAwait(false);
}
}
@@ -241,99 +249,73 @@ namespace MediaBrowser.Controller.Providers.Movies
/// The search result.
protected void ProcessInfo(Person person, PersonResult searchResult)
{
- person.Overview = searchResult.Biography;
+ person.Overview = searchResult.biography;
DateTime date;
- if (DateTime.TryParseExact(searchResult.Birthday, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out date))
+ if (DateTime.TryParseExact(searchResult.birthday, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out date))
{
person.PremiereDate = date.ToUniversalTime();
}
- if (DateTime.TryParseExact(searchResult.Deathday, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out date))
+ if (DateTime.TryParseExact(searchResult.deathday, "yyyy-MM-dd", new CultureInfo("en-US"), DateTimeStyles.None, out date))
{
person.EndDate = date.ToUniversalTime();
}
- if (!string.IsNullOrEmpty(searchResult.Homepage))
+ if (!string.IsNullOrEmpty(searchResult.homepage))
{
- person.HomePageUrl = searchResult.Homepage;
+ person.HomePageUrl = searchResult.homepage;
}
- if (!string.IsNullOrEmpty(searchResult.Place_Of_Birth))
+ if (!string.IsNullOrEmpty(searchResult.place_of_birth))
{
- person.AddProductionLocation(searchResult.Place_Of_Birth);
+ person.AddProductionLocation(searchResult.place_of_birth);
}
- person.SetProviderId(MetadataProviders.Tmdb, searchResult.Id.ToString());
+ person.SetProviderId(MetadataProviders.Tmdb, searchResult.id.ToString(UsCulture));
}
///
/// Fetches the images.
///
/// The person.
- /// The id.
+ /// The search result.
/// The cancellation token.
/// Task.
- private async Task FetchImages(Person person, string id, CancellationToken cancellationToken)
+ private async Task FetchImages(Person person, Images searchResult, CancellationToken cancellationToken)
{
- string url = string.Format(@"http://api.themoviedb.org/3/person/{1}/images?api_key={0}", MovieDbProvider.ApiKey, id);
-
- PersonImages searchResult = null;
-
- try
- {
- using (Stream json = await HttpClient.Get(new HttpRequestOptions
- {
- Url = url,
- CancellationToken = cancellationToken,
- ResourcePool = MovieDbProvider.Current.MovieDbResourcePool,
- AcceptHeader = MovieDbProvider.AcceptHeader,
- EnableResponseCache = true
-
- }).ConfigureAwait(false))
- {
- if (json != null)
- {
- searchResult = JsonSerializer.DeserializeFromStream(json);
- }
- }
- }
- catch (HttpException)
- {
- }
-
- if (searchResult != null && searchResult.Profiles.Count > 0)
+ if (searchResult != null && searchResult.profiles.Count > 0)
{
//get our language
var profile =
- searchResult.Profiles.FirstOrDefault(
+ searchResult.profiles.FirstOrDefault(
p =>
- !string.IsNullOrEmpty(p.Iso_639_1) &&
- p.Iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage,
+ !string.IsNullOrEmpty(GetIso639(p)) &&
+ GetIso639(p).Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage,
StringComparison.OrdinalIgnoreCase));
if (profile == null)
{
//didn't find our language - try first null one
profile =
- searchResult.Profiles.FirstOrDefault(
+ searchResult.profiles.FirstOrDefault(
p =>
- !string.IsNullOrEmpty(p.Iso_639_1) &&
- p.Iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage,
+ !string.IsNullOrEmpty(GetIso639(p)) &&
+ GetIso639(p).Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage,
StringComparison.OrdinalIgnoreCase));
}
if (profile == null)
{
//still nothing - just get first one
- profile = searchResult.Profiles[0];
+ profile = searchResult.profiles[0];
}
if (profile != null)
{
var tmdbSettings = await MovieDbProvider.Current.TmdbSettings.ConfigureAwait(false);
- var img = await DownloadAndSaveImage(person, tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedProfileSize + profile.File_Path,
- "folder" + Path.GetExtension(profile.File_Path), cancellationToken).ConfigureAwait(false);
+ var img = await DownloadAndSaveImage(person, tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedProfileSize + profile.file_path,
+ "folder" + Path.GetExtension(profile.file_path), cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(img))
{
@@ -343,6 +325,11 @@ namespace MediaBrowser.Controller.Providers.Movies
}
}
+ private string GetIso639(Profile p)
+ {
+ return p.iso_639_1 == null ? string.Empty : p.iso_639_1.ToString();
+ }
+
///
/// Downloads the and save image.
///
@@ -373,7 +360,7 @@ namespace MediaBrowser.Controller.Providers.Movies
///
/// Class PersonSearchResult
///
- public class PersonSearchResult
+ protected class PersonSearchResult
{
///
/// Gets or sets a value indicating whether this is adult.
@@ -400,7 +387,7 @@ namespace MediaBrowser.Controller.Providers.Movies
///
/// Class PersonSearchResults
///
- public class PersonSearchResults
+ protected class PersonSearchResults
{
///
/// Gets or sets the page.
@@ -424,110 +411,65 @@ namespace MediaBrowser.Controller.Providers.Movies
public int Total_Results { get; set; }
}
- ///
- /// Class PersonResult
- ///
- public class PersonResult
+ protected class Cast
{
- ///
- /// Gets or sets a value indicating whether this is adult.
- ///
- /// true if adult; otherwise, false.
- public bool Adult { get; set; }
- ///
- /// Gets or sets the also_ known_ as.
- ///
- /// The also_ known_ as.
- public List