fixes #397 - WB web client - Missing person metadata field

This commit is contained in:
Luke Pulverenti 2013-07-29 14:33:48 -04:00
parent 2646ce696b
commit f7bce0bc3c
6 changed files with 70 additions and 17 deletions

View File

@ -225,6 +225,7 @@ namespace MediaBrowser.Api
item.EndDate = request.EndDate.HasValue ? request.EndDate.Value.ToUniversalTime() : (DateTime?)null;
item.PremiereDate = request.PremiereDate.HasValue ? request.PremiereDate.Value.ToUniversalTime() : (DateTime?)null;
item.ProductionYear = request.ProductionYear;
item.ProductionLocations = request.ProductionLocations;
item.AspectRatio = request.AspectRatio;
item.Language = request.Language;
item.OfficialRating = request.OfficialRating;

View File

@ -1279,11 +1279,6 @@ namespace MediaBrowser.Controller.Entities
throw new ArgumentNullException("location");
}
if (ProductionLocations == null)
{
ProductionLocations = new List<string>();
}
if (!ProductionLocations.Contains(location, StringComparer.OrdinalIgnoreCase))
{
ProductionLocations.Add(location);

View File

@ -211,6 +211,18 @@ namespace MediaBrowser.Controller.Providers
break;
}
case "PlaceOfBirth":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
item.ProductionLocations = new List<string> { val };
}
break;
}
case "Website":
{
var val = reader.ReadElementContentAsString();
@ -465,6 +477,24 @@ namespace MediaBrowser.Controller.Providers
break;
}
case "DeathDate":
case "EndDate":
{
var firstAired = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(firstAired))
{
DateTime airDate;
if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
{
item.EndDate = airDate.ToUniversalTime();
}
}
break;
}
case "TvDbId":
var tvdbId = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(tvdbId))

View File

@ -23,7 +23,7 @@ namespace MediaBrowser.Providers.Movies
public class TmdbPersonProvider : BaseMetadataProvider
{
protected readonly IProviderManager ProviderManager;
public TmdbPersonProvider(IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(logManager, configurationManager)
{
@ -74,12 +74,12 @@ namespace MediaBrowser.Providers.Movies
return ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataDownload;
}
}
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
if (HasAltMeta(item))
return false;
return base.NeedsRefreshInternal(item, providerInfo);
}
@ -87,7 +87,7 @@ namespace MediaBrowser.Providers.Movies
{
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName("person.xml");
}
/// <summary>
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
/// </summary>
@ -146,7 +146,7 @@ namespace MediaBrowser.Providers.Movies
}
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
/// <summary>
/// Gets the TMDB id.
/// </summary>
@ -233,11 +233,14 @@ namespace MediaBrowser.Providers.Movies
person.HomePageUrl = searchResult.homepage;
}
if (!string.IsNullOrEmpty(searchResult.place_of_birth))
if (!person.LockedFields.Contains(MetadataFields.ProductionLocations))
{
person.AddProductionLocation(searchResult.place_of_birth);
if (!string.IsNullOrEmpty(searchResult.place_of_birth))
{
person.ProductionLocations = new List<string> { searchResult.place_of_birth };
}
}
person.SetProviderId(MetadataProviders.Tmdb, searchResult.id.ToString(UsCulture));
}

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using System.Security;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Providers.Movies;
using System;
@ -23,7 +24,7 @@ namespace MediaBrowser.Providers.Savers
{
var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
// If new metadata has been downloaded or metadata was manually edited, proceed
if ((wasMetadataEdited || wasMetadataDownloaded))
{
@ -47,11 +48,19 @@ namespace MediaBrowser.Providers.Savers
XmlSaverHelpers.AddCommonNodes(item, builder);
if (item.ProductionLocations.Count > 0)
{
builder.Append("<PlaceOfBirth>" + SecurityElement.Escape(item.ProductionLocations[0]) + "</PlaceOfBirth>");
}
builder.Append("</Item>");
var xmlFilePath = GetSavePath(item);
XmlSaverHelpers.Save(builder, xmlFilePath, new string[] { });
XmlSaverHelpers.Save(builder, xmlFilePath, new[]
{
"PlaceOfBirth"
});
// Set last refreshed so that the provider doesn't trigger after the file save
PersonProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow);

View File

@ -47,6 +47,7 @@ namespace MediaBrowser.Providers.Savers
"LocalTitle",
"SortTitle",
"PremiereDate",
"EndDate",
"Budget",
"Revenue",
"Rating",
@ -74,7 +75,9 @@ namespace MediaBrowser.Providers.Savers
"Trailer",
"CriticRating",
"CriticRatingSummary",
"GamesDbId"
"GamesDbId",
"BirthDate",
"DeathDate"
});
var position = xml.ToString().LastIndexOf("</", StringComparison.OrdinalIgnoreCase);
@ -210,6 +213,18 @@ namespace MediaBrowser.Providers.Savers
}
}
if (item.EndDate.HasValue)
{
if (item is Person)
{
builder.Append("<DeathDate>" + SecurityElement.Escape(item.EndDate.Value.ToString("yyyy-MM-dd")) + "</DeathDate>");
}
else if (!(item is Episode))
{
builder.Append("<EndDate>" + SecurityElement.Escape(item.EndDate.Value.ToString("yyyy-MM-dd")) + "</EndDate>");
}
}
if (item.RemoteTrailers.Count > 0)
{
builder.Append("<Trailer>" + SecurityElement.Escape(item.RemoteTrailers[0].Url) + "</Trailer>");