|
@@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.Omdb
|
|
}
|
|
}
|
|
|
|
|
|
public async Task Fetch<T>(MetadataResult<T> itemResult, string imdbId, string language, string country, CancellationToken cancellationToken)
|
|
public async Task Fetch<T>(MetadataResult<T> itemResult, string imdbId, string language, string country, CancellationToken cancellationToken)
|
|
- where T :BaseItem
|
|
|
|
|
|
+ where T : BaseItem
|
|
{
|
|
{
|
|
if (string.IsNullOrWhiteSpace(imdbId))
|
|
if (string.IsNullOrWhiteSpace(imdbId))
|
|
{
|
|
{
|
|
@@ -48,25 +48,25 @@ namespace MediaBrowser.Providers.Omdb
|
|
|
|
|
|
var result = await GetRootObject(imdbId, cancellationToken);
|
|
var result = await GetRootObject(imdbId, cancellationToken);
|
|
|
|
|
|
- // Only take the name and rating if the user's language is set to english, since Omdb has no localization
|
|
|
|
- if (string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
|
|
|
|
- {
|
|
|
|
- item.Name = result.Title;
|
|
|
|
|
|
+ // Only take the name and rating if the user's language is set to english, since Omdb has no localization
|
|
|
|
+ if (string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
|
|
|
|
+ {
|
|
|
|
+ item.Name = result.Title;
|
|
|
|
|
|
- if (string.Equals(country, "us", StringComparison.OrdinalIgnoreCase))
|
|
|
|
- {
|
|
|
|
- item.OfficialRating = result.Rated;
|
|
|
|
- }
|
|
|
|
|
|
+ if (string.Equals(country, "us", StringComparison.OrdinalIgnoreCase))
|
|
|
|
+ {
|
|
|
|
+ item.OfficialRating = result.Rated;
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- int year;
|
|
|
|
|
|
+ int year;
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4
|
|
|
|
- && int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out year)
|
|
|
|
- && year >= 0)
|
|
|
|
- {
|
|
|
|
- item.ProductionYear = year;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4
|
|
|
|
+ && int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out year)
|
|
|
|
+ && year >= 0)
|
|
|
|
+ {
|
|
|
|
+ item.ProductionYear = year;
|
|
|
|
+ }
|
|
|
|
|
|
// Seeing some bogus RT data on omdb for series, so filter it out here
|
|
// Seeing some bogus RT data on omdb for series, so filter it out here
|
|
// RT doesn't even have tv series
|
|
// RT doesn't even have tv series
|
|
@@ -87,33 +87,33 @@ namespace MediaBrowser.Providers.Omdb
|
|
|
|
|
|
int voteCount;
|
|
int voteCount;
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(result.imdbVotes)
|
|
|
|
- && int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount)
|
|
|
|
- && voteCount >= 0)
|
|
|
|
- {
|
|
|
|
- item.VoteCount = voteCount;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(result.imdbVotes)
|
|
|
|
+ && int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount)
|
|
|
|
+ && voteCount >= 0)
|
|
|
|
+ {
|
|
|
|
+ item.VoteCount = voteCount;
|
|
|
|
+ }
|
|
|
|
|
|
- float imdbRating;
|
|
|
|
|
|
+ float imdbRating;
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(result.imdbRating)
|
|
|
|
- && float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out imdbRating)
|
|
|
|
- && imdbRating >= 0)
|
|
|
|
- {
|
|
|
|
- item.CommunityRating = imdbRating;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(result.imdbRating)
|
|
|
|
+ && float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out imdbRating)
|
|
|
|
+ && imdbRating >= 0)
|
|
|
|
+ {
|
|
|
|
+ item.CommunityRating = imdbRating;
|
|
|
|
+ }
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(result.Website))
|
|
|
|
- {
|
|
|
|
- item.HomePageUrl = result.Website;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(result.Website))
|
|
|
|
+ {
|
|
|
|
+ item.HomePageUrl = result.Website;
|
|
|
|
+ }
|
|
|
|
|
|
- if (!string.IsNullOrWhiteSpace(result.imdbID))
|
|
|
|
- {
|
|
|
|
- item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
|
|
|
|
- }
|
|
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(result.imdbID))
|
|
|
|
+ {
|
|
|
|
+ item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
|
|
|
|
+ }
|
|
|
|
|
|
- ParseAdditionalMetadata(itemResult, result);
|
|
|
|
|
|
+ ParseAdditionalMetadata(itemResult, result);
|
|
}
|
|
}
|
|
|
|
|
|
public async Task<bool> FetchEpisodeData<T>(MetadataResult<T> itemResult, int episodeNumber, int seasonNumber, string imdbId, string language, string country, CancellationToken cancellationToken)
|
|
public async Task<bool> FetchEpisodeData<T>(MetadataResult<T> itemResult, int episodeNumber, int seasonNumber, string imdbId, string language, string country, CancellationToken cancellationToken)
|
|
@@ -135,7 +135,7 @@ namespace MediaBrowser.Providers.Omdb
|
|
|
|
|
|
RootObject result = null;
|
|
RootObject result = null;
|
|
|
|
|
|
- foreach (var episode in seasonResult.Episodes)
|
|
|
|
|
|
+ foreach (var episode in (seasonResult.Episodes ?? new RootObject[] { }))
|
|
{
|
|
{
|
|
if (episode.Episode == episodeNumber)
|
|
if (episode.Episode == episodeNumber)
|
|
{
|
|
{
|