fixes #540 - Get tv genres from Imdb via Omdb

pull/702/head
Luke Pulverenti 11 years ago
parent 17d22c0130
commit 333f1ea6a4

@ -1,4 +1,5 @@
using MediaBrowser.Common.Net;
using System.Linq;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
@ -45,7 +46,7 @@ namespace MediaBrowser.Providers.Movies
{
get
{
return "6";
return "8";
}
}
@ -173,6 +174,8 @@ namespace MediaBrowser.Providers.Movies
{
item.CommunityRating = imdbRating;
}
ParseAdditionalMetadata(item, result);
}
data.LastRefreshStatus = ProviderRefreshStatus.Success;
@ -181,6 +184,27 @@ namespace MediaBrowser.Providers.Movies
return true;
}
private void ParseAdditionalMetadata(BaseItem item, RootObject result)
{
// Grab series genres because imdb data is better than tvdb. Leave movies alone
// But only do it if english is the preferred language because this data will not be localized
if (!item.LockedFields.Contains(MetadataFields.Genres) &&
item is Series &&
!string.IsNullOrWhiteSpace(result.Genre) &&
!string.Equals(result.Genre, "n/a", StringComparison.OrdinalIgnoreCase)
&& string.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage, "en"))
{
item.Genres.Clear();
foreach (var genre in result.Genre
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(i => i.Trim())
.Where(i => !string.IsNullOrWhiteSpace(i)))
{
item.AddGenre(genre);
}
}
}
protected class RootObject
{

Loading…
Cancel
Save