From 62d98551edf421ba50f2eadf95d6c3d1fb1d20ae Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 29 Jun 2014 23:32:43 -0400 Subject: [PATCH] remove obsolete markings --- .../Configuration/ServerConfiguration.cs | 3 -- .../ApplicationHost.cs | 4 +-- MediaBrowser.XbmcMetadata/EntryPoint.cs | 35 ++++++++++++------- .../Savers/AlbumXmlSaver.cs | 12 ++----- .../Savers/ArtistXmlSaver.cs | 12 ++----- .../Savers/EpisodeXmlSaver.cs | 12 ++----- .../Savers/MovieXmlSaver.cs | 18 ++++------ .../Savers/SeasonXmlSaver.cs | 11 +++--- .../Savers/SeriesXmlSaver.cs | 12 ++----- 9 files changed, 43 insertions(+), 76 deletions(-) diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index af09a25ac..a5d19b5cb 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -199,7 +199,6 @@ namespace MediaBrowser.Model.Configuration public string UICulture { get; set; } - [Obsolete] public DlnaOptions DlnaOptions { get; set; } public double DownMixAudioBoost { get; set; } @@ -213,10 +212,8 @@ namespace MediaBrowser.Model.Configuration public ChannelOptions ChannelOptions { get; set; } - [Obsolete] public ChapterOptions ChapterOptions { get; set; } - [Obsolete] public bool DefaultMetadataSettingsApplied { get; set; } /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index eeab8ee2e..5c84b92af 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -289,7 +289,7 @@ namespace MediaBrowser.ServerApplication DeleteDeprecatedModules(); MigrateModularConfigurations(); - ApplyDefaultXbmcSettings(); + ApplyDefaultMetadataSettings(); } private void MigrateModularConfigurations() @@ -316,7 +316,7 @@ namespace MediaBrowser.ServerApplication } } - private void ApplyDefaultXbmcSettings() + private void ApplyDefaultMetadataSettings() { if (!ServerConfigurationManager.Configuration.DefaultMetadataSettingsApplied) { diff --git a/MediaBrowser.XbmcMetadata/EntryPoint.cs b/MediaBrowser.XbmcMetadata/EntryPoint.cs index 2d978781f..a7015e41f 100644 --- a/MediaBrowser.XbmcMetadata/EntryPoint.cs +++ b/MediaBrowser.XbmcMetadata/EntryPoint.cs @@ -36,22 +36,39 @@ namespace MediaBrowser.XbmcMetadata void _libraryManager_ItemUpdated(object sender, ItemChangeEventArgs e) { - if (e.UpdateReason == ItemUpdateType.ImageUpdate && e.Item is Person) + // TODO: Need a more accurate check here to see if xbmc metadata saving is enabled. + // This is probably good enough, but no guarantee + var userId = _config.GetNfoConfiguration().UserId; + if (string.IsNullOrWhiteSpace(userId)) { - var person = e.Item.Name; + return; + } - var items = _libraryManager.RootFolder - .GetRecursiveChildren(i => !i.IsFolder && i.People.Any(p => string.Equals(p.Name, person, StringComparison.OrdinalIgnoreCase))); + if (e.UpdateReason == ItemUpdateType.ImageUpdate) + { + var person = e.Item as Person; - foreach (var item in items) + if (person != null) { - SaveMetadataForItem(item, ItemUpdateType.MetadataEdit); + var items = _libraryManager.RootFolder.RecursiveChildren; + items = person.GetTaggedItems(items).ToList(); + + foreach (var item in items) + { + SaveMetadataForItem(item, ItemUpdateType.MetadataEdit); + } } } } void _userDataManager_UserDataSaved(object sender, UserDataSaveEventArgs e) { + var userId = _config.GetNfoConfiguration().UserId; + if (string.IsNullOrWhiteSpace(userId)) + { + return; + } + if (e.SaveReason == UserDataSaveReason.PlaybackFinished || e.SaveReason == UserDataSaveReason.TogglePlayed) { var item = e.Item as BaseItem; @@ -73,12 +90,6 @@ namespace MediaBrowser.XbmcMetadata private async void SaveMetadataForItem(BaseItem item, ItemUpdateType updateReason) { - var userId = _config.GetNfoConfiguration().UserId; - if (string.IsNullOrWhiteSpace(userId)) - { - return; - } - var locationType = item.LocationType; if (locationType == LocationType.Remote || locationType == LocationType.Virtual) diff --git a/MediaBrowser.XbmcMetadata/Savers/AlbumXmlSaver.cs b/MediaBrowser.XbmcMetadata/Savers/AlbumXmlSaver.cs index 121514cdd..0f4d25dde 100644 --- a/MediaBrowser.XbmcMetadata/Savers/AlbumXmlSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/AlbumXmlSaver.cs @@ -95,20 +95,12 @@ namespace MediaBrowser.XbmcMetadata.Savers public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) { - var locationType = item.LocationType; - if (locationType == LocationType.Remote || locationType == LocationType.Virtual) + if (!item.SupportsLocalMetadata) { return false; } - // If new metadata has been downloaded or metadata was manually edited, proceed - if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload - || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit) - { - return item is MusicAlbum; - } - - return false; + return item is MusicAlbum && updateType >= ItemUpdateType.MetadataDownload; } private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); diff --git a/MediaBrowser.XbmcMetadata/Savers/ArtistXmlSaver.cs b/MediaBrowser.XbmcMetadata/Savers/ArtistXmlSaver.cs index f47785155..937d702d3 100644 --- a/MediaBrowser.XbmcMetadata/Savers/ArtistXmlSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/ArtistXmlSaver.cs @@ -85,20 +85,12 @@ namespace MediaBrowser.XbmcMetadata.Savers public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) { - var locationType = item.LocationType; - if (locationType == LocationType.Remote || locationType == LocationType.Virtual) + if (!item.SupportsLocalMetadata) { return false; } - // If new metadata has been downloaded or metadata was manually edited, proceed - if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload - || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit) - { - return item is MusicArtist; - } - - return false; + return item is MusicArtist && updateType >= ItemUpdateType.MetadataDownload; } private void AddAlbums(IEnumerable albums, StringBuilder builder) diff --git a/MediaBrowser.XbmcMetadata/Savers/EpisodeXmlSaver.cs b/MediaBrowser.XbmcMetadata/Savers/EpisodeXmlSaver.cs index a03eacdc4..1b5c24aad 100644 --- a/MediaBrowser.XbmcMetadata/Savers/EpisodeXmlSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/EpisodeXmlSaver.cs @@ -130,20 +130,12 @@ namespace MediaBrowser.XbmcMetadata.Savers public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) { - var locationType = item.LocationType; - if (locationType == LocationType.Remote || locationType == LocationType.Virtual) + if (!item.SupportsLocalMetadata) { return false; } - // If new metadata has been downloaded or metadata was manually edited, proceed - if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload - || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit) - { - return item is Episode; - } - - return false; + return item is Episode && updateType >= ItemUpdateType.MetadataDownload; } } } diff --git a/MediaBrowser.XbmcMetadata/Savers/MovieXmlSaver.cs b/MediaBrowser.XbmcMetadata/Savers/MovieXmlSaver.cs index 586cefe65..fa2155e30 100644 --- a/MediaBrowser.XbmcMetadata/Savers/MovieXmlSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/MovieXmlSaver.cs @@ -118,23 +118,17 @@ namespace MediaBrowser.XbmcMetadata.Savers public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) { - var locationType = item.LocationType; - if (locationType == LocationType.Remote || locationType == LocationType.Virtual) + if (!item.SupportsLocalMetadata) { return false; } - // If new metadata has been downloaded or metadata was manually edited, proceed - if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload - || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit) - { - var video = item as Video; + var video = item as Video; - // Check parent for null to avoid running this against things like video backdrops - if (video != null && !(item is Episode) && !video.IsOwnedItem) - { - return true; - } + // Check parent for null to avoid running this against things like video backdrops + if (video != null && !(item is Episode) && !video.IsOwnedItem) + { + return updateType >= ItemUpdateType.MetadataDownload; } return false; diff --git a/MediaBrowser.XbmcMetadata/Savers/SeasonXmlSaver.cs b/MediaBrowser.XbmcMetadata/Savers/SeasonXmlSaver.cs index 9de589e55..1b6c7a340 100644 --- a/MediaBrowser.XbmcMetadata/Savers/SeasonXmlSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/SeasonXmlSaver.cs @@ -71,20 +71,17 @@ namespace MediaBrowser.XbmcMetadata.Savers public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) { - var locationType = item.LocationType; - if (locationType == LocationType.Remote || locationType == LocationType.Virtual) + if (!item.SupportsLocalMetadata) { return false; } - // If new metadata has been downloaded or metadata was manually edited, proceed - if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload - || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit) + if (!(item is Season)) { - return item is Season; + return false; } - return false; + return updateType >= ItemUpdateType.MetadataDownload || (updateType >= ItemUpdateType.MetadataImport && File.Exists(GetSavePath(item))); } } } diff --git a/MediaBrowser.XbmcMetadata/Savers/SeriesXmlSaver.cs b/MediaBrowser.XbmcMetadata/Savers/SeriesXmlSaver.cs index 9c99cc33d..94d46f61d 100644 --- a/MediaBrowser.XbmcMetadata/Savers/SeriesXmlSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/SeriesXmlSaver.cs @@ -111,20 +111,12 @@ namespace MediaBrowser.XbmcMetadata.Savers public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) { - var locationType = item.LocationType; - if (locationType == LocationType.Remote || locationType == LocationType.Virtual) + if (!item.SupportsLocalMetadata) { return false; } - // If new metadata has been downloaded or metadata was manually edited, proceed - if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload - || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit) - { - return item is Series; - } - - return false; + return item is Series && updateType >= ItemUpdateType.MetadataDownload; } } }