diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs index eed846b7f..23cdf00b6 100644 --- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs @@ -23,97 +23,116 @@ using MediaBrowser.Model.Xml; namespace MediaBrowser.LocalMetadata.Savers { - public abstract class BaseNfoSaver : IMetadataFileSaver + public abstract class BaseXmlSaver : IMetadataFileSaver { private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); private static readonly Dictionary CommonTags = new[] { - "plot", - "customrating", - "lockdata", - "type", - "dateadded", - "title", - "rating", - "year", - "sorttitle", - "mpaa", - "mpaadescription", - "aspectratio", - "website", - "collectionnumber", - "tmdbid", - "rottentomatoesid", - "language", - "tvcomid", - "budget", - "revenue", - "tagline", - "studio", - "genre", - "tag", - "runtime", - "actor", - "criticratingsummary", - "criticrating", - "fileinfo", - "director", - "writer", - "trailer", - "premiered", - "releasedate", - "outline", - "id", - "votes", - "credits", - "originaltitle", - "watched", - "playcount", - "lastplayed", - "art", - "resume", - "biography", - "formed", - "review", - "style", - "imdbid", - "imdb_id", - "plotkeyword", - "country", - "audiodbalbumid", - "audiodbartistid", - "awardsummary", - "enddate", - "lockedfields", - "metascore", - "zap2itid", - "tvrageid", - "gamesdbid", + "Added", + "AspectRatio", + "AudioDbAlbumId", + "AudioDbArtistId", + "AwardSummary", + "BirthDate", + "Budget", + + // Deprecated. No longer saving in this field. + "certification", - "musicbrainzartistid", - "musicbrainzalbumartistid", - "musicbrainzalbumid", - "musicbrainzreleasegroupid", - "tvdbid", - "collectionitem", + "Chapters", + "ContentRating", + "Countries", + "CustomRating", + "CriticRating", + "CriticRatingSummary", + "DeathDate", + "DisplayOrder", + "EndDate", + "Genres", + "Genre", + "GamesDbId", + + // Deprecated. No longer saving in this field. + "IMDB_ID", - "isuserfavorite", - "userrating", + "IMDB", + + // Deprecated. No longer saving in this field. + "IMDbId", - "countrycode" + "Language", + "LocalTitle", + "OriginalTitle", + "LockData", + "LockedFields", + "Format3D", + "Metascore", + + // Deprecated. No longer saving in this field. + "MPAARating", + + "MPAADescription", + + "MusicBrainzArtistId", + "MusicBrainzAlbumArtistId", + "MusicBrainzAlbumId", + "MusicBrainzReleaseGroupId", + + // Deprecated. No longer saving in this field. + "MusicbrainzId", + + "Overview", + "ShortOverview", + "Persons", + "PlotKeywords", + "PremiereDate", + "ProductionYear", + "Rating", + "Revenue", + "RottenTomatoesId", + "RunningTime", + + // Deprecated. No longer saving in this field. + "Runtime", + + "SortTitle", + "Studios", + "Tags", + + // Deprecated. No longer saving in this field. + "TagLine", + + "Taglines", + "TMDbCollectionId", + "TMDbId", + + // Deprecated. No longer saving in this field. + "Trailer", + + "Trailers", + "TVcomId", + "TvDbId", + "Type", + "TVRageId", + "VoteCount", + "Website", + "Zap2ItId", + "CollectionItems", + "PlaylistItems", + "Shares" }.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); - protected BaseNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger, IXmlReaderSettingsFactory xmlReaderSettingsFactory) + public BaseXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger, IXmlReaderSettingsFactory xmlReaderSettingsFactory) { + FileSystem = fileSystem; + ConfigurationManager = configurationManager; + LibraryManager = libraryManager; + UserManager = userManager; + UserDataManager = userDataManager; Logger = logger; XmlReaderSettingsFactory = xmlReaderSettingsFactory; - UserDataManager = userDataManager; - UserManager = userManager; - LibraryManager = libraryManager; - ConfigurationManager = configurationManager; - FileSystem = fileSystem; } protected IFileSystem FileSystem { get; private set; } @@ -136,15 +155,7 @@ namespace MediaBrowser.LocalMetadata.Savers { get { - return SaverName; - } - } - - public static string SaverName - { - get - { - return "Emby Xml"; + return XmlProviderUtils.Name; } } diff --git a/MediaBrowser.LocalMetadata/Savers/FolderXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/FolderXmlSaver.cs index 2d8576aa3..b51bd5b91 100644 --- a/MediaBrowser.LocalMetadata/Savers/FolderXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/FolderXmlSaver.cs @@ -9,40 +9,28 @@ using System.Collections.Generic; using System.IO; using System.Text; using System.Threading; +using System.Xml; using MediaBrowser.Common.IO; using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; +using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Xml; namespace MediaBrowser.LocalMetadata.Savers { - public class FolderXmlSaver : IMetadataFileSaver + public class FolderXmlSaver : BaseXmlSaver { - public string Name + protected override string GetLocalSavePath(IHasMetadata item) { - get - { - return XmlProviderUtils.Name; - } + return Path.Combine(item.Path, "folder.xml"); } - private readonly IServerConfigurationManager _config; - private readonly ILibraryManager _libraryManager; - private readonly IFileSystem _fileSystem; - - public FolderXmlSaver(IServerConfigurationManager config, ILibraryManager libraryManager, IFileSystem fileSystem) + protected override string GetRootElementName(IHasMetadata item) { - _config = config; - _libraryManager = libraryManager; - _fileSystem = fileSystem; + return "Item"; } - /// - /// Determines whether [is enabled for] [the specified item]. - /// - /// The item. - /// Type of the update. - /// true if [is enabled for] [the specified item]; otherwise, false. - public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) + public override bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) { if (!item.SupportsLocalMetadata) { @@ -63,35 +51,12 @@ namespace MediaBrowser.LocalMetadata.Savers return false; } - /// - /// Saves the specified item. - /// - /// The item. - /// The cancellation token. - /// Task. - public void Save(IHasMetadata item, CancellationToken cancellationToken) + protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer) { - var builder = new StringBuilder(); - - builder.Append(""); - - XmlSaverHelpers.AddCommonNodes((Folder)item, _libraryManager, builder); - - builder.Append(""); - - var xmlFilePath = GetSavePath(item); - - XmlSaverHelpers.Save(builder, xmlFilePath, new List(), _config, _fileSystem); } - /// - /// Gets the save path. - /// - /// The item. - /// System.String. - public string GetSavePath(IHasMetadata item) + public FolderXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger, IXmlReaderSettingsFactory xmlReaderSettingsFactory) : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger, xmlReaderSettingsFactory) { - return Path.Combine(item.Path, "folder.xml"); } } }