jellyfin-server/MediaBrowser.LocalMetadata/Savers/PersonXmlSaver.cs

58 lines
1.8 KiB
C#
Raw Normal View History

using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using System.Collections.Generic;
2013-06-23 17:56:11 +00:00
using System.IO;
2016-10-30 07:02:23 +00:00
using System.Xml;
2016-10-25 19:02:04 +00:00
using MediaBrowser.Model.IO;
2016-10-30 07:02:23 +00:00
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Xml;
2013-06-23 17:56:11 +00:00
namespace MediaBrowser.LocalMetadata.Savers
2013-06-23 17:56:11 +00:00
{
/// <summary>
/// Class PersonXmlSaver
/// </summary>
2016-10-30 07:02:23 +00:00
public class PersonXmlSaver : BaseXmlSaver
2013-06-23 17:56:11 +00:00
{
2016-10-30 07:02:23 +00:00
public override bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
2014-02-02 13:36:31 +00:00
{
2016-10-30 07:02:23 +00:00
if (!item.SupportsLocalMetadata)
2014-02-02 13:36:31 +00:00
{
2016-10-30 07:02:23 +00:00
return false;
2014-02-02 13:36:31 +00:00
}
2016-10-30 07:02:23 +00:00
return item is Person && updateType >= ItemUpdateType.MetadataDownload;
}
2016-10-30 07:02:23 +00:00
protected override List<string> GetTagsUsed()
2013-06-23 17:56:11 +00:00
{
2016-10-30 07:02:23 +00:00
var list = new List<string>
2014-02-08 20:02:35 +00:00
{
2016-10-30 07:02:23 +00:00
"PlaceOfBirth"
};
2014-02-08 20:02:35 +00:00
2016-10-30 07:02:23 +00:00
return list;
2013-06-23 17:56:11 +00:00
}
2016-10-30 07:02:23 +00:00
protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer)
2013-06-23 17:56:11 +00:00
{
2014-02-02 13:36:31 +00:00
var person = (Person)item;
2016-10-09 07:18:43 +00:00
if (person.ProductionLocations.Count > 0)
{
2016-10-30 07:02:23 +00:00
writer.WriteElementString("PlaceOfBirth", person.ProductionLocations[0]);
}
2013-06-23 17:56:11 +00:00
}
2016-10-30 07:02:23 +00:00
protected override string GetLocalSavePath(IHasMetadata item)
2013-06-23 17:56:11 +00:00
{
return Path.Combine(item.Path, "person.xml");
}
2016-10-30 07:02:23 +00:00
public PersonXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger, IXmlReaderSettingsFactory xmlReaderSettingsFactory) : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger, xmlReaderSettingsFactory)
{
}
2013-06-23 17:56:11 +00:00
}
}