From e55ab989d2077d70568965198139793ca7c116b4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 18 Dec 2014 23:20:07 -0500 Subject: add more sync buttons --- MediaBrowser.Model/Configuration/ServerConfiguration.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'MediaBrowser.Model/Configuration/ServerConfiguration.cs') diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index b9eaf7001..59dd04f33 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -144,12 +144,6 @@ namespace MediaBrowser.Model.Configuration /// The image saving convention. public ImageSavingConvention ImageSavingConvention { get; set; } - /// - /// Gets or sets a value indicating whether [enable people prefix sub folders]. - /// - /// true if [enable people prefix sub folders]; otherwise, false. - public bool EnablePeoplePrefixSubFolders { get; set; } - /// /// Gets or sets the encoding quality. /// @@ -179,8 +173,7 @@ namespace MediaBrowser.Model.Configuration public string[] InsecureApps7 { get; set; } public bool SaveMetadataHidden { get; set; } - - public bool PlaylistImagesDeleted { get; set; } + public string H264Encoder { get; set; } /// /// Initializes a new instance of the class. @@ -195,7 +188,6 @@ namespace MediaBrowser.Model.Configuration EnableDashboardResponseCaching = true; EnableAutomaticRestart = true; - EnablePeoplePrefixSubFolders = true; EnableUPnP = true; DownMixAudioBoost = 2; @@ -225,6 +217,7 @@ namespace MediaBrowser.Model.Configuration EnableRealtimeMonitor = true; UICulture = "en-us"; + H264Encoder = "libx264"; PeopleMetadataOptions = new PeopleMetadataOptions(); -- cgit v1.2.3 From 97ae93fe5eb0f010db9835efd72954f31ccdd2cd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 21 Dec 2014 14:40:37 -0500 Subject: add standalone EncodingOptions --- MediaBrowser.Api/ApiEntryPoint.cs | 19 +++-- MediaBrowser.Api/Playback/BaseStreamingService.cs | 11 +-- .../Configuration/BaseConfigurationManager.cs | 20 +++++- .../Configuration/IConfigurationFactory.cs | 5 ++ .../MediaBrowser.Controller.csproj | 3 - .../MediaEncoding/EncodingOptions.cs | 80 ---------------------- .../MediaEncoding/EncodingResult.cs | 13 ---- .../MediaEncoding/VideoEncodingOptions.cs | 26 ------- .../Configuration/EncodingConfigurationFactory.cs | 45 ++++++++++++ .../MediaBrowser.MediaEncoding.csproj | 1 + .../MediaBrowser.Model.Portable.csproj | 3 + .../MediaBrowser.Model.net35.csproj | 3 + .../Configuration/EncodingOptions.cs | 19 +++++ .../Configuration/ServerConfiguration.cs | 13 ---- MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + .../Configuration/ServerConfigurationManager.cs | 33 --------- 16 files changed, 113 insertions(+), 182 deletions(-) delete mode 100644 MediaBrowser.Controller/MediaEncoding/EncodingOptions.cs delete mode 100644 MediaBrowser.Controller/MediaEncoding/EncodingResult.cs delete mode 100644 MediaBrowser.Controller/MediaEncoding/VideoEncodingOptions.cs create mode 100644 MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs create mode 100644 MediaBrowser.Model/Configuration/EncodingOptions.cs (limited to 'MediaBrowser.Model/Configuration/ServerConfiguration.cs') diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 95f7ef694..a05d7d1b2 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -1,7 +1,9 @@ using MediaBrowser.Api.Playback; -using MediaBrowser.Controller; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Session; using System; @@ -33,7 +35,7 @@ namespace MediaBrowser.Api /// /// The application paths /// - private readonly IServerApplicationPaths _appPaths; + private readonly IServerConfigurationManager _config; private readonly ISessionManager _sessionManager; @@ -43,13 +45,13 @@ namespace MediaBrowser.Api /// Initializes a new instance of the class. /// /// The logger. - /// The application paths. /// The session manager. - public ApiEntryPoint(ILogger logger, IServerApplicationPaths appPaths, ISessionManager sessionManager) + /// The configuration. + public ApiEntryPoint(ILogger logger, ISessionManager sessionManager, IServerConfigurationManager config) { Logger = logger; - _appPaths = appPaths; _sessionManager = sessionManager; + _config = config; Instance = this; } @@ -73,12 +75,17 @@ namespace MediaBrowser.Api } } + public EncodingOptions GetEncodingOptions() + { + return _config.GetConfiguration("encoding"); + } + /// /// Deletes the encoded media cache. /// private void DeleteEncodedMediaCache() { - foreach (var file in Directory.EnumerateFiles(_appPaths.TranscodingTempPath, "*", SearchOption.AllDirectories) + foreach (var file in Directory.EnumerateFiles(_config.ApplicationPaths.TranscodingTempPath, "*", SearchOption.AllDirectories) .ToList()) { File.Delete(file); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 203a62dfc..683a1f962 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; @@ -249,7 +250,7 @@ namespace MediaBrowser.Api.Playback protected EncodingQuality GetQualitySetting() { - var quality = ServerConfigurationManager.Configuration.MediaEncodingQuality; + var quality = ApiEntryPoint.Instance.GetEncodingOptions().MediaEncodingQuality; if (quality == EncodingQuality.Auto) { @@ -310,7 +311,7 @@ namespace MediaBrowser.Api.Playback { get { - var lib = ServerConfigurationManager.Configuration.H264Encoder; + var lib = ApiEntryPoint.Instance.GetEncodingOptions().H264Encoder; if (!string.IsNullOrWhiteSpace(lib)) { @@ -461,7 +462,7 @@ namespace MediaBrowser.Api.Playback { if (state.AudioStream != null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5) { - volParam = ",volume=" + ServerConfigurationManager.Configuration.DownMixAudioBoost.ToString(UsCulture); + volParam = ",volume=" + ApiEntryPoint.Instance.GetEncodingOptions().DownMixAudioBoost.ToString(UsCulture); } } @@ -953,7 +954,7 @@ namespace MediaBrowser.Api.Playback var transcodingId = Guid.NewGuid().ToString("N"); var commandLineArgs = GetCommandLineArguments(outputPath, transcodingId, state, true); - if (ServerConfigurationManager.Configuration.EnableDebugEncodingLogging) + if (ApiEntryPoint.Instance.GetEncodingOptions().EnableDebugLogging) { commandLineArgs = "-loglevel debug " + commandLineArgs; } diff --git a/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs b/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs index a061420d7..093010124 100644 --- a/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs +++ b/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs @@ -233,13 +233,22 @@ namespace MediaBrowser.Common.Implementations.Configuration public void SaveConfiguration(string key, object configuration) { - var configurationType = GetConfigurationType(key); + var configurationStore = GetConfigurationStore(key); + var configurationType = configurationStore.ConfigurationType; if (configuration.GetType() != configurationType) { throw new ArgumentException("Expected configuration type is " + configurationType.Name); } + var validatingStore = configurationStore as IValidatingConfiguration; + if (validatingStore != null) + { + var currentConfiguration = GetConfiguration(key); + + validatingStore.Validate(currentConfiguration, configuration); + } + EventHelper.FireEventIfNotNull(NamedConfigurationUpdating, this, new ConfigurationUpdateEventArgs { Key = key, @@ -267,9 +276,14 @@ namespace MediaBrowser.Common.Implementations.Configuration public Type GetConfigurationType(string key) { - return _configurationStores - .First(i => string.Equals(i.Key, key, StringComparison.OrdinalIgnoreCase)) + return GetConfigurationStore(key) .ConfigurationType; } + + private ConfigurationStore GetConfigurationStore(string key) + { + return _configurationStores + .First(i => string.Equals(i.Key, key, StringComparison.OrdinalIgnoreCase)); + } } } diff --git a/MediaBrowser.Common/Configuration/IConfigurationFactory.cs b/MediaBrowser.Common/Configuration/IConfigurationFactory.cs index d418d0a42..6ed638536 100644 --- a/MediaBrowser.Common/Configuration/IConfigurationFactory.cs +++ b/MediaBrowser.Common/Configuration/IConfigurationFactory.cs @@ -14,4 +14,9 @@ namespace MediaBrowser.Common.Configuration public Type ConfigurationType { get; set; } } + + public interface IValidatingConfiguration + { + void Validate(object oldConfig, object newConfig); + } } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index c198a58d4..3b9f3a5b2 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -198,16 +198,13 @@ - - - diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingOptions.cs b/MediaBrowser.Controller/MediaEncoding/EncodingOptions.cs deleted file mode 100644 index 26182ebc4..000000000 --- a/MediaBrowser.Controller/MediaEncoding/EncodingOptions.cs +++ /dev/null @@ -1,80 +0,0 @@ -using MediaBrowser.Controller.Dlna; -using MediaBrowser.Model.Dlna; - -namespace MediaBrowser.Controller.MediaEncoding -{ - public class EncodingOptions - { - /// - /// Gets or sets the item identifier. - /// - /// The item identifier. - public string ItemId { get; set; } - - /// - /// Gets or sets the media source identifier. - /// - /// The media source identifier. - public string MediaSourceId { get; set; } - - /// - /// Gets or sets the device profile. - /// - /// The device profile. - public DeviceProfile DeviceProfile { get; set; } - - /// - /// Gets or sets the output path. - /// - /// The output path. - public string OutputPath { get; set; } - - /// - /// Gets or sets the container. - /// - /// The container. - public string Container { get; set; } - - /// - /// Gets or sets the audio codec. - /// - /// The audio codec. - public string AudioCodec { get; set; } - - /// - /// Gets or sets the start time ticks. - /// - /// The start time ticks. - public long? StartTimeTicks { get; set; } - - /// - /// Gets or sets the maximum channels. - /// - /// The maximum channels. - public int? MaxAudioChannels { get; set; } - - /// - /// Gets or sets the channels. - /// - /// The channels. - public int? AudioChannels { get; set; } - - /// - /// Gets or sets the sample rate. - /// - /// The sample rate. - public int? AudioSampleRate { get; set; } - - /// - /// Gets or sets the bit rate. - /// - /// The bit rate. - public int? AudioBitRate { get; set; } - - /// - /// Gets or sets the maximum audio bit rate. - /// - /// The maximum audio bit rate. - public int? MaxAudioBitRate { get; set; } - } -} diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingResult.cs b/MediaBrowser.Controller/MediaEncoding/EncodingResult.cs deleted file mode 100644 index 75ee90e42..000000000 --- a/MediaBrowser.Controller/MediaEncoding/EncodingResult.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MediaBrowser.Controller.MediaEncoding -{ - public class EncodingResult - { - public string OutputPath { get; set; } - } -} diff --git a/MediaBrowser.Controller/MediaEncoding/VideoEncodingOptions.cs b/MediaBrowser.Controller/MediaEncoding/VideoEncodingOptions.cs deleted file mode 100644 index 773f0ea46..000000000 --- a/MediaBrowser.Controller/MediaEncoding/VideoEncodingOptions.cs +++ /dev/null @@ -1,26 +0,0 @@ - -namespace MediaBrowser.Controller.MediaEncoding -{ - public class VideoEncodingOptions : EncodingOptions - { - public string VideoCodec { get; set; } - - public string VideoProfile { get; set; } - - public double? VideoLevel { get; set; } - - public int? VideoStreamIndex { get; set; } - - public int? AudioStreamIndex { get; set; } - - public int? SubtitleStreamIndex { get; set; } - - public int? MaxWidth { get; set; } - - public int? MaxHeight { get; set; } - - public int? Height { get; set; } - - public int? Width { get; set; } - } -} diff --git a/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs new file mode 100644 index 000000000..17470d206 --- /dev/null +++ b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs @@ -0,0 +1,45 @@ +using MediaBrowser.Common.Configuration; +using MediaBrowser.Model.Configuration; +using System.Collections.Generic; +using System.IO; + +namespace MediaBrowser.MediaEncoding.Configuration +{ + public class EncodingConfigurationFactory : IConfigurationFactory + { + public IEnumerable GetConfigurations() + { + return new[] + { + new EncodingConfigurationStore() + }; + } + } + + public class EncodingConfigurationStore : ConfigurationStore, IValidatingConfiguration + { + public EncodingConfigurationStore() + { + ConfigurationType = typeof(EncodingOptions); + Key = "encoding"; + } + + public void Validate(object oldConfig, object newConfig) + { + var oldEncodingConfig = (EncodingOptions)oldConfig; + var newEncodingConfig = (EncodingOptions)newConfig; + + var newPath = newEncodingConfig.TranscodingTempPath; + + if (!string.IsNullOrWhiteSpace(newPath) + && !string.Equals(oldEncodingConfig.TranscodingTempPath ?? string.Empty, newPath)) + { + // Validate + if (!Directory.Exists(newPath)) + { + throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); + } + } + } + } +} diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj index 6f59b7bec..5c472ebc8 100644 --- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj +++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj @@ -56,6 +56,7 @@ Properties\SharedVersion.cs + diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index f18c53cd3..9900484cd 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -188,6 +188,9 @@ Configuration\DynamicDayOfWeek.cs + + Configuration\EncodingOptions.cs + Configuration\EncodingQuality.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index f17215988..bd98b5b86 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -153,6 +153,9 @@ Configuration\DynamicDayOfWeek.cs + + Configuration\EncodingOptions.cs + Configuration\EncodingQuality.cs diff --git a/MediaBrowser.Model/Configuration/EncodingOptions.cs b/MediaBrowser.Model/Configuration/EncodingOptions.cs new file mode 100644 index 000000000..f24367298 --- /dev/null +++ b/MediaBrowser.Model/Configuration/EncodingOptions.cs @@ -0,0 +1,19 @@ + +namespace MediaBrowser.Model.Configuration +{ + public class EncodingOptions + { + public EncodingQuality EncodingQuality { get; set; } + public string TranscodingTempPath { get; set; } + public double DownMixAudioBoost { get; set; } + public string H264Encoder { get; set; } + public bool EnableDebugLogging { get; set; } + + public EncodingOptions() + { + H264Encoder = "libx264"; + DownMixAudioBoost = 2; + EncodingQuality = EncodingQuality.Auto; + } + } +} diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 59dd04f33..0852e0a5c 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -144,15 +144,8 @@ namespace MediaBrowser.Model.Configuration /// The image saving convention. public ImageSavingConvention ImageSavingConvention { get; set; } - /// - /// Gets or sets the encoding quality. - /// - /// The encoding quality. - public EncodingQuality MediaEncodingQuality { get; set; } - public MetadataOptions[] MetadataOptions { get; set; } - public bool EnableDebugEncodingLogging { get; set; } public string TranscodingTempPath { get; set; } public bool EnableAutomaticRestart { get; set; } @@ -165,15 +158,12 @@ namespace MediaBrowser.Model.Configuration public string UICulture { get; set; } - public double DownMixAudioBoost { get; set; } - public PeopleMetadataOptions PeopleMetadataOptions { get; set; } public bool FindInternetTrailers { get; set; } public string[] InsecureApps7 { get; set; } public bool SaveMetadataHidden { get; set; } - public string H264Encoder { get; set; } /// /// Initializes a new instance of the class. @@ -181,7 +171,6 @@ namespace MediaBrowser.Model.Configuration public ServerConfiguration() : base() { - MediaEncodingQuality = EncodingQuality.Auto; ImageSavingConvention = ImageSavingConvention.Compatible; PublicPort = 8096; HttpServerPortNumber = 8096; @@ -190,7 +179,6 @@ namespace MediaBrowser.Model.Configuration EnableAutomaticRestart = true; EnableUPnP = true; - DownMixAudioBoost = 2; MinResumePct = 5; MaxResumePct = 90; @@ -217,7 +205,6 @@ namespace MediaBrowser.Model.Configuration EnableRealtimeMonitor = true; UICulture = "en-us"; - H264Encoder = "libx264"; PeopleMetadataOptions = new PeopleMetadataOptions(); diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 759c671e9..e1f0e78f4 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -96,6 +96,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs index b9896e9ce..704bdea29 100644 --- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -32,7 +32,6 @@ namespace MediaBrowser.Server.Implementations.Configuration : base(applicationPaths, logManager, xmlSerializer) { UpdateItemsByNamePath(); - UpdateTranscodingTempPath(); UpdateMetadataPath(); } @@ -71,7 +70,6 @@ namespace MediaBrowser.Server.Implementations.Configuration protected override void OnConfigurationUpdated() { UpdateItemsByNamePath(); - UpdateTranscodingTempPath(); UpdateMetadataPath(); base.OnConfigurationUpdated(); @@ -97,16 +95,6 @@ namespace MediaBrowser.Server.Implementations.Configuration Configuration.MetadataPath; } - /// - /// Updates the transcoding temporary path. - /// - private void UpdateTranscodingTempPath() - { - ((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(Configuration.TranscodingTempPath) ? - null : - Configuration.TranscodingTempPath; - } - /// /// Replaces the configuration. /// @@ -117,7 +105,6 @@ namespace MediaBrowser.Server.Implementations.Configuration var newConfig = (ServerConfiguration)newConfiguration; ValidateItemByNamePath(newConfig); - ValidateTranscodingTempPath(newConfig); ValidatePathSubstitutions(newConfig); ValidateMetadataPath(newConfig); @@ -157,26 +144,6 @@ namespace MediaBrowser.Server.Implementations.Configuration } } - /// - /// Validates the transcoding temporary path. - /// - /// The new configuration. - /// - private void ValidateTranscodingTempPath(ServerConfiguration newConfig) - { - var newPath = newConfig.TranscodingTempPath; - - if (!string.IsNullOrWhiteSpace(newPath) - && !string.Equals(Configuration.TranscodingTempPath ?? string.Empty, newPath)) - { - // Validate - if (!Directory.Exists(newPath)) - { - throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); - } - } - } - /// /// Validates the metadata path. /// -- cgit v1.2.3 From 498b58aad0b2df17b3caf34b04dbf3f1438742c5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 22 Dec 2014 01:50:29 -0500 Subject: added content type selection --- MediaBrowser.Api/ItemUpdateService.cs | 37 ++++++++++++---- MediaBrowser.Controller/Library/ILibraryManager.cs | 4 +- .../Configuration/CinemaModeConfiguration.cs | 1 + .../Configuration/ServerConfiguration.cs | 6 ++- .../Library/LibraryManager.cs | 49 +++++++++++++++++++--- .../Library/Resolvers/Movies/MovieResolver.cs | 4 +- 6 files changed, 82 insertions(+), 19 deletions(-) (limited to 'MediaBrowser.Model/Configuration/ServerConfiguration.cs') diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 953f7b3bb..020908ddd 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; @@ -46,12 +47,14 @@ namespace MediaBrowser.Api private readonly ILibraryManager _libraryManager; private readonly IProviderManager _providerManager; private readonly ILocalizationManager _localizationManager; + private readonly IServerConfigurationManager _config; - public ItemUpdateService(ILibraryManager libraryManager, IProviderManager providerManager, ILocalizationManager localizationManager) + public ItemUpdateService(ILibraryManager libraryManager, IProviderManager providerManager, ILocalizationManager localizationManager, IServerConfigurationManager config) { _libraryManager = libraryManager; _providerManager = providerManager; _localizationManager = localizationManager; + _config = config; } public object Get(GetMetadataEditorInfo request) @@ -70,11 +73,14 @@ namespace MediaBrowser.Api if (locationType == LocationType.FileSystem || locationType == LocationType.Offline) { - var collectionType = _libraryManager.GetInheritedContentType(item); - if (string.IsNullOrWhiteSpace(collectionType)) + if (!(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder)) { - info.ContentTypeOptions = GetContentTypeOptions(true); - info.ContentType = _libraryManager.GetContentType(item); + var collectionType = _libraryManager.GetInheritedContentType(item); + if (string.IsNullOrWhiteSpace(collectionType)) + { + info.ContentTypeOptions = GetContentTypeOptions(true); + info.ContentType = _libraryManager.GetContentType(item); + } } } @@ -83,7 +89,24 @@ namespace MediaBrowser.Api public void Post(UpdateItemContentType request) { - + var item = _libraryManager.GetItemById(request.ItemId); + var path = item.ContainingFolderPath; + + var types = _config.Configuration.ContentTypes + .Where(i => !string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase)) + .ToList(); + + if (!string.IsNullOrWhiteSpace(request.ContentType)) + { + types.Add(new NameValuePair + { + Name = path, + Value = request.ContentType + }); + } + + _config.Configuration.ContentTypes = types.ToArray(); + _config.SaveConfiguration(); } private List GetContentTypeOptions(bool isForItem) diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 7cdfb7788..8573f32e0 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -23,11 +23,9 @@ namespace MediaBrowser.Controller.Library /// /// The file information. /// The parent. - /// Type of the collection. /// BaseItem. BaseItem ResolvePath(FileSystemInfo fileInfo, - Folder parent = null, - string collectionType = null); + Folder parent = null); /// /// Resolves a set of files into a list of BaseItem diff --git a/MediaBrowser.Model/Configuration/CinemaModeConfiguration.cs b/MediaBrowser.Model/Configuration/CinemaModeConfiguration.cs index bd20713de..764a7222f 100644 --- a/MediaBrowser.Model/Configuration/CinemaModeConfiguration.cs +++ b/MediaBrowser.Model/Configuration/CinemaModeConfiguration.cs @@ -19,6 +19,7 @@ namespace MediaBrowser.Model.Configuration public CinemaModeConfiguration() { EnableIntrosParentalControl = true; + EnableIntrosFromSimilarMovies = true; TrailerLimit = 2; } } diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 0852e0a5c..730735499 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; namespace MediaBrowser.Model.Configuration { @@ -165,6 +166,8 @@ namespace MediaBrowser.Model.Configuration public bool SaveMetadataHidden { get; set; } + public NameValuePair[] ContentTypes { get; set; } + /// /// Initializes a new instance of the class. /// @@ -192,6 +195,7 @@ namespace MediaBrowser.Model.Configuration FindInternetTrailers = true; PathSubstitutions = new PathSubstitution[] { }; + ContentTypes = new NameValuePair[] { }; PreferredMetadataLanguage = "en"; MetadataCountryCode = "US"; diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index ab50c30fb..d52288f87 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -560,10 +560,9 @@ namespace MediaBrowser.Server.Implementations.Library } public BaseItem ResolvePath(FileSystemInfo fileInfo, - Folder parent = null, - string collectionType = null) + Folder parent = null) { - return ResolvePath(fileInfo, new DirectoryService(_logger), parent, collectionType); + return ResolvePath(fileInfo, new DirectoryService(_logger), parent); } private BaseItem ResolvePath(FileSystemInfo fileInfo, IDirectoryService directoryService, Folder parent = null, string collectionType = null) @@ -573,10 +572,17 @@ namespace MediaBrowser.Server.Implementations.Library throw new ArgumentNullException("fileInfo"); } + var fullPath = fileInfo.FullName; + + if (string.IsNullOrWhiteSpace(collectionType)) + { + collectionType = GetConfiguredContentType(fullPath); + } + var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, this, directoryService) { Parent = parent, - Path = fileInfo.FullName, + Path = fullPath, FileInfo = fileInfo, CollectionType = collectionType }; @@ -1548,12 +1554,43 @@ namespace MediaBrowser.Server.Implementations.Library public string GetContentType(BaseItem item) { - return GetInheritedContentType(item); + // Types cannot be overridden, so go from the top down until we find a configured content type + + var type = GetTopFolderContentType(item); + + if (!string.IsNullOrWhiteSpace(type)) + { + return type; + } + + type = GetInheritedContentType(item); + + if (!string.IsNullOrWhiteSpace(type)) + { + return type; + } + + return GetConfiguredContentType(item); } public string GetInheritedContentType(BaseItem item) { - return GetTopFolderContentType(item); + return item.Parents + .Select(GetConfiguredContentType) + .LastOrDefault(i => !string.IsNullOrWhiteSpace(i)); + } + + private string GetConfiguredContentType(BaseItem item) + { + return GetConfiguredContentType(item.ContainingFolderPath); + } + + private string GetConfiguredContentType(string path) + { + var type = ConfigurationManager.Configuration.ContentTypes + .FirstOrDefault(i => string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase) || _fileSystem.ContainsSubPath(i.Name, path)); + + return type == null ? null : type.Value; } private string GetTopFolderContentType(BaseItem item) diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 58b5dbc6a..01dc4db8a 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -79,7 +79,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies return ResolveVideos /// The path. - public string Path { get; set; } + public string[] Path { get; set; } /// /// Gets or sets the type of the image. /// diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs index 5acec2d6b..52ec5c9b1 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs @@ -1,7 +1,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Connect; -using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Plugins; using MediaBrowser.Model.Logging; using System; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs index d97ccb9bd..386c16513 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller; -using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Plugins; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs index 098a1d2bd..fcc664011 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs @@ -1,8 +1,6 @@ using MediaBrowser.Common; using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.Implementations.Security; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Logging; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs index 940be6d02..36ba55828 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Controller.Net; namespace MediaBrowser.Server.Implementations.EntryPoints { diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index b754a943a..c3228db92 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -1,7 +1,6 @@ using Funq; using MediaBrowser.Common; using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.Net; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations.HttpServer.NetListener; @@ -205,10 +204,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer { HostContext.Config.HandlerFactoryPath = ListenerRequest.GetHandlerPathIfAny(UrlPrefixes.First()); - _listener = _supportsNativeWebSocket && NativeWebSocket.IsSupported - //? _listener = new HttpListenerServer(_logger, OnRequestReceived) - ? _listener = new WebSocketSharpListener(_logger, OnRequestReceived) - : _listener = new WebSocketSharpListener(_logger, OnRequestReceived); + _listener = GetListener(); _listener.WebSocketHandler = WebSocketHandler; _listener.ErrorHandler = ErrorHandler; @@ -217,6 +213,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer _listener.Start(UrlPrefixes); } + private IHttpListener GetListener() + { + if (_supportsNativeWebSocket && NativeWebSocket.IsSupported) + { + return new HttpListenerServer(_logger, OnRequestReceived); + } + + return new WebSocketSharpListener(_logger, OnRequestReceived); + } + private void WebSocketHandler(WebSocketConnectEventArgs args) { if (WebSocketConnected != null) diff --git a/MediaBrowser.Server.Implementations/HttpServer/IHttpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/IHttpListener.cs index dfde34e25..e77600e93 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/IHttpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/IHttpListener.cs @@ -1,9 +1,8 @@ -using System.Threading.Tasks; -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net; using ServiceStack.Web; using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.HttpServer { diff --git a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs index f8e8bb9dd..cac2f8e09 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs @@ -1,10 +1,9 @@ -using System.Text; -using MediaBrowser.Common.Events; -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Events; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using System; using System.Net.WebSockets; +using System.Text; using System.Threading; using System.Threading.Tasks; using WebSocketMessageType = MediaBrowser.Model.Net.WebSocketMessageType; diff --git a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs index 9635854d4..31c0e87b3 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using ServiceStack; using ServiceStack.Host.HttpListener; diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs index 354b1e20f..401d49325 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs @@ -1,12 +1,9 @@ -using System.Text; -using MediaBrowser.Common.Events; -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Events; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using System; using System.Threading; using System.Threading.Tasks; -using WebSocketMessageType = MediaBrowser.Model.Net.WebSocketMessageType; using WebSocketState = MediaBrowser.Model.Net.WebSocketState; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index ffaecc0d5..4d2d57b6e 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using ServiceStack; using ServiceStack.Web; diff --git a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs index a8950da89..9f75d522c 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Events; -using MediaBrowser.Common.Net; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; diff --git a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs index 0788ed2ce..8eb129876 100644 --- a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs +++ b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index a9e257a8c..22d0ee5e7 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -32,12 +32,12 @@ namespace MediaBrowser.Server.Implementations.Sync private readonly IImageProcessor _imageProcessor; private readonly ILogger _logger; private readonly IUserManager _userManager; - private readonly IDtoService _dtoService; + private readonly Func _dtoService; private readonly IApplicationHost _appHost; private ISyncProvider[] _providers = { }; - public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, IDtoService dtoService, IApplicationHost appHost) + public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func dtoService, IApplicationHost appHost) { _libraryManager = libraryManager; _repo = repo; @@ -323,9 +323,8 @@ namespace MediaBrowser.Server.Implementations.Sync return _repo.GetJobItems(query); } - public SyncedItem GetJobItemInfo(string id) + private SyncedItem GetJobItemInfo(SyncJobItem jobItem) { - var jobItem = GetJobItem(id); var job = _repo.GetJob(jobItem.JobId); var libraryItem = _libraryManager.GetItemById(jobItem.ItemId); @@ -338,7 +337,7 @@ namespace MediaBrowser.Server.Implementations.Sync UserId = job.UserId }; - syncedItem.Item = _dtoService.GetBaseItemDto(libraryItem, new DtoOptions()); + syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, new DtoOptions()); // TODO: this should be the media source of the transcoded output syncedItem.Item.MediaSources = syncedItem.Item.MediaSources @@ -365,5 +364,16 @@ namespace MediaBrowser.Server.Implementations.Sync { return Task.FromResult(true); } + + public List GetReadySyncItems(string targetId) + { + var jobItemResult = GetJobItems(new SyncJobItemQuery + { + TargetId = targetId, + //Status = SyncJobItemStatus.Transferring + }); + + return jobItemResult.Items.Select(GetJobItemInfo).ToList(); + } } } diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index 2ff6d7ae6..a981ffc57 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Sync public async Task Initialize() { - var dbFile = Path.Combine(_appPaths.DataPath, "sync7.db"); + var dbFile = Path.Combine(_appPaths.DataPath, "sync8.db"); _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false); @@ -298,7 +298,8 @@ namespace MediaBrowser.Server.Implementations.Sync _deleteJobCommand.Transaction = transaction; _deleteJobCommand.ExecuteNonQuery(); - _deleteJobItemsCommand.GetParameter(index++).Value = new Guid(id); + index = 0; + _deleteJobItemsCommand.GetParameter(index++).Value = id; _deleteJobItemsCommand.Transaction = transaction; _deleteJobItemsCommand.ExecuteNonQuery(); @@ -607,11 +608,16 @@ namespace MediaBrowser.Server.Implementations.Sync var info = new SyncJobItem { Id = reader.GetGuid(0).ToString("N"), - ItemId = reader.GetString(1), - MediaSourceId = reader.GetString(2), - JobId = reader.GetString(3) + ItemId = reader.GetString(1) }; + if (!reader.IsDBNull(2)) + { + info.MediaSourceId = reader.GetString(2); + } + + info.JobId = reader.GetString(3); + if (!reader.IsDBNull(4)) { info.OutputPath = reader.GetString(4); diff --git a/MediaBrowser.Server.Implementations/Udp/UdpServer.cs b/MediaBrowser.Server.Implementations/Udp/UdpServer.cs index d80e0b66e..91a4940ae 100644 --- a/MediaBrowser.Server.Implementations/Udp/UdpServer.cs +++ b/MediaBrowser.Server.Implementations/Udp/UdpServer.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller; -using MediaBrowser.Controller.Net; using MediaBrowser.Model.ApiClient; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; diff --git a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs index a2c860413..576b5b75f 100644 --- a/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs +++ b/MediaBrowser.Server.Mac/Native/BaseMonoApp.cs @@ -67,7 +67,7 @@ namespace MediaBrowser.Server.Mac return list; } - public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory) + public void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory) { } diff --git a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs index 227c32242..7f61570a4 100644 --- a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs +++ b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.IsoMounter; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Mono.Networking; @@ -84,7 +83,7 @@ namespace MediaBrowser.Server.Mono.Native return list; } - public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory) + public void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory) { } diff --git a/MediaBrowser.Server.Mono/Networking/NetworkManager.cs b/MediaBrowser.Server.Mono/Networking/NetworkManager.cs index d76a7c7ee..60c250115 100644 --- a/MediaBrowser.Server.Mono/Networking/NetworkManager.cs +++ b/MediaBrowser.Server.Mono/Networking/NetworkManager.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Implementations.Networking; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 06d63b355..8398c63cb 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -224,7 +224,7 @@ namespace MediaBrowser.Server.Startup.Common private readonly StartupOptions _startupOptions; private readonly string _remotePackageName; - private readonly bool _supportsNativeWebSocket; + private bool _supportsNativeWebSocket; internal INativeApp NativeApp { get; set; } @@ -454,6 +454,18 @@ namespace MediaBrowser.Server.Startup.Common RegisterSingleInstance(() => new SearchEngine(LogManager, LibraryManager, UserManager)); + if (IsFirstRun) + { + ServerConfigurationManager.Configuration.EnableWin8HttpListener = false; + ServerConfigurationManager.SaveConfiguration(); + _supportsNativeWebSocket = false; + } + + if (!ServerConfigurationManager.Configuration.EnableWin8HttpListener) + { + _supportsNativeWebSocket = false; + } + HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", _supportsNativeWebSocket); RegisterSingleInstance(HttpServer, false); progress.Report(10); @@ -470,7 +482,7 @@ namespace MediaBrowser.Server.Startup.Common ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder); RegisterSingleInstance(ImageProcessor); - SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, DtoService, this); + SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this); RegisterSingleInstance(SyncManager); DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this); @@ -735,7 +747,7 @@ namespace MediaBrowser.Server.Startup.Common ServerManager.AddWebSocketListeners(GetExports(false)); - StartServer(true); + StartServer(); LibraryManager.AddParts(GetExports(), GetExports(), @@ -773,8 +785,7 @@ namespace MediaBrowser.Server.Startup.Common /// /// Starts the server. /// - /// if set to true [retry on failure]. - private void StartServer(bool retryOnFailure) + private void StartServer() { try { @@ -784,16 +795,7 @@ namespace MediaBrowser.Server.Startup.Common { Logger.ErrorException("Error starting http server", ex); - if (retryOnFailure) - { - RegisterServerWithAdministratorAccess(); - - StartServer(false); - } - else - { - throw; - } + throw; } } @@ -1070,9 +1072,8 @@ namespace MediaBrowser.Server.Startup.Common try { NativeApp.AuthorizeServer( - ServerConfigurationManager.Configuration.HttpServerPortNumber, - HttpServerUrlPrefixes.First(), UdpServerEntryPoint.PortNumber, + ServerConfigurationManager.Configuration.HttpServerPortNumber, ConfigurationManager.CommonApplicationPaths.TempDirectory); } catch (Exception ex) diff --git a/MediaBrowser.Server.Startup.Common/INativeApp.cs b/MediaBrowser.Server.Startup.Common/INativeApp.cs index cf0135fa8..4abea57fb 100644 --- a/MediaBrowser.Server.Startup.Common/INativeApp.cs +++ b/MediaBrowser.Server.Startup.Common/INativeApp.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; using System.Collections.Generic; using System.Reflection; @@ -17,11 +16,10 @@ namespace MediaBrowser.Server.Startup.Common /// /// Authorizes the server. /// - /// The HTTP server port. - /// The HTTP server URL prefix. /// The UDP port. + /// The HTTP server port. /// The temporary directory. - void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory); + void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory); /// /// Gets the environment. diff --git a/MediaBrowser.ServerApplication/Native/RegisterServer.bat b/MediaBrowser.ServerApplication/Native/RegisterServer.bat index 350412344..3346ecb31 100644 --- a/MediaBrowser.ServerApplication/Native/RegisterServer.bat +++ b/MediaBrowser.ServerApplication/Native/RegisterServer.bat @@ -1,21 +1,15 @@ -rem %1 = http server port -rem %2 = http server url -rem %3 = udp server port +rem %1 = udp server port +rem %2 = http server port if [%1]==[] GOTO DONE -netsh advfirewall firewall delete rule name="Port %1" protocol=TCP localport=%1 -netsh advfirewall firewall add rule name="Port %1" dir=in action=allow protocol=TCP localport=%1 +netsh advfirewall firewall delete rule name="Port %1" protocol=UDP localport=%1 +netsh advfirewall firewall add rule name="Port %1" dir=in action=allow protocol=UDP localport=%1 if [%2]==[] GOTO DONE -netsh http del urlacl url="%2" user="NT AUTHORITY\Authenticated Users" -netsh http add urlacl url="%2" user="NT AUTHORITY\Authenticated Users" - -if [%3]==[] GOTO DONE - -netsh advfirewall firewall delete rule name="Port %3" protocol=UDP localport=%3 -netsh advfirewall firewall add rule name="Port %3" dir=in action=allow protocol=UDP localport=%3 +netsh advfirewall firewall delete rule name="Port %2" protocol=TCP localport=%2 +netsh advfirewall firewall add rule name="Port %2" dir=in action=allow protocol=TCP localport=%2 :DONE diff --git a/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs b/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs index e5989db3b..d9063aa58 100644 --- a/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs +++ b/MediaBrowser.ServerApplication/Native/ServerAuthorization.cs @@ -13,11 +13,10 @@ namespace MediaBrowser.ServerApplication.Native /// /// Authorizes the server. /// - /// The HTTP server port. - /// The HTTP server URL prefix. /// The UDP port. + /// The HTTP server port. /// The temp directory. - public static void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory) + public static void AuthorizeServer(int udpPort, int httpServerPort, string tempDirectory) { Directory.CreateDirectory(tempDirectory); @@ -37,9 +36,7 @@ namespace MediaBrowser.ServerApplication.Native { FileName = tmpFile, - Arguments = string.Format("{0} {1} {2}", httpServerPort, - httpServerUrlPrefix, - udpPort), + Arguments = string.Format("{0} {1}", udpPort, httpServerPort), CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.cs index 071216418..0970d6537 100644 --- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs +++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.IsoMounter; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Startup.Common; @@ -22,9 +21,9 @@ namespace MediaBrowser.ServerApplication.Native return list; } - public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory) + public void AuthorizeServer(int httpServerPort, int udpPort, string tempDirectory) { - ServerAuthorization.AuthorizeServer(httpServerPort, httpServerUrlPrefix, udpPort, tempDirectory); + ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, tempDirectory); } public NativeEnvironment Environment diff --git a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs index 4dbe0f347..fc4d26363 100644 --- a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs +++ b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Implementations.Networking; using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 3fd559a4d..80e2f32f7 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.532 + 3.0.533 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 84eec30d6..8c22ebb5d 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.532 + 3.0.533 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index ad3bd826d..f313bd7a5 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.532 + 3.0.533 MediaBrowser.Model - Signed Edition Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 191ab9e88..a31f8023b 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.532 + 3.0.533 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From e27040f61b1fb80593a5ed99757b1ebdd69cf5d4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 4 Jan 2015 00:55:34 -0500 Subject: don't save metadata when video content type is unset --- MediaBrowser.Controller/Entities/BaseItem.cs | 5 +++++ MediaBrowser.Controller/Entities/Movies/Movie.cs | 2 +- MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs | 13 ++++++++++++- .../Configuration/ServerConfiguration.cs | 6 ++++++ .../Channels/ChannelManager.cs | 20 +++++++++----------- .../LiveTv/LiveTvManager.cs | 12 ++++++------ .../Localization/JavaScript/javascript.json | 4 ++-- .../Localization/Server/server.json | 2 ++ .../ApplicationHost.cs | 12 +++++++++++- MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs | 2 +- MediaBrowser.XbmcMetadata/Savers/ArtistNfoSaver.cs | 2 +- MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs | 13 +++++++++++++ MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs | 2 +- MediaBrowser.XbmcMetadata/Savers/MovieNfoSaver.cs | 12 +++++++++--- MediaBrowser.XbmcMetadata/Savers/SeasonNfoSaver.cs | 2 +- MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs | 2 +- 16 files changed, 81 insertions(+), 30 deletions(-) (limited to 'MediaBrowser.Model/Configuration/ServerConfiguration.cs') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 90427de75..ee562d8b4 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1577,6 +1577,11 @@ namespace MediaBrowser.Controller.Entities foreach (var newImage in images) { + if (newImage == null) + { + throw new ArgumentException("null image found in list"); + } + var existing = existingImages .FirstOrDefault(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase)); diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 4c1aac700..b3774cfe0 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -1,6 +1,7 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Users; using System; using System.Collections.Generic; using System.IO; @@ -8,7 +9,6 @@ using System.Linq; using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Entities.Movies { diff --git a/MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs index 6fe9f88f0..cad08e638 100644 --- a/MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs @@ -19,11 +19,13 @@ namespace MediaBrowser.LocalMetadata.Savers { private readonly IItemRepository _itemRepository; private readonly IServerConfigurationManager _config; + private readonly ILibraryManager _libraryManager; - public MovieXmlSaver(IItemRepository itemRepository, IServerConfigurationManager config) + public MovieXmlSaver(IItemRepository itemRepository, IServerConfigurationManager config, ILibraryManager libraryManager) { _itemRepository = itemRepository; _config = config; + _libraryManager = libraryManager; } public string Name @@ -52,6 +54,15 @@ namespace MediaBrowser.LocalMetadata.Savers // Check parent for null to avoid running this against things like video backdrops if (video != null && !(item is Episode) && !video.IsOwnedItem) { + // If it's a plain video, skip if content type is unset (unless editing) + if (video.GetType() == typeof(Video)) + { + if (updateType < ItemUpdateType.MetadataEdit && string.IsNullOrEmpty(_libraryManager.GetContentType(video))) + { + return false; + } + } + return updateType >= ItemUpdateType.MetadataDownload; } diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index ba5b6a122..6c941e804 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -32,6 +32,12 @@ namespace MediaBrowser.Model.Configuration /// true if [enable internet providers]; otherwise, false. public bool EnableInternetProviders { get; set; } + /// + /// Gets or sets a value indicating whether this instance is port authorized. + /// + /// true if this instance is port authorized; otherwise, false. + public bool IsPortAuthorized { get; set; } + /// /// Gets or sets the item by name path. /// diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index d88625396..c12a1161b 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -1,6 +1,4 @@ -using System.Net; -using System.Text; -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Channels; @@ -10,7 +8,6 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; using MediaBrowser.Controller.Providers; -using MediaBrowser.Controller.Resolvers; using MediaBrowser.Model.Channels; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; @@ -24,9 +21,10 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net; +using System.Text; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Server.Implementations.Library; namespace MediaBrowser.Server.Implementations.Channels { @@ -1293,16 +1291,16 @@ namespace MediaBrowser.Server.Implementations.Channels } } - private async Task RefreshIfNeeded(BaseItem program, CancellationToken cancellationToken) + private readonly Task _cachedTask = Task.FromResult(true); + private Task RefreshIfNeeded(BaseItem program, CancellationToken cancellationToken) { - if (_refreshedItems.ContainsKey(program.Id)) + if (!_refreshedItems.ContainsKey(program.Id)) { - return; + _refreshedItems.TryAdd(program.Id, true); + return program.RefreshMetadata(cancellationToken); } - await program.RefreshMetadata(cancellationToken).ConfigureAwait(false); - - _refreshedItems.TryAdd(program.Id, true); + return _cachedTask; } internal IChannel GetChannelProvider(Channel channel) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index ac742f04a..96498563e 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -309,16 +309,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv return Task.FromResult(true); } - private async Task RefreshIfNeeded(LiveTvProgram program, CancellationToken cancellationToken) + private readonly Task _cachedTask = Task.FromResult(true); + private Task RefreshIfNeeded(LiveTvProgram program, CancellationToken cancellationToken) { - if (_refreshedPrograms.ContainsKey(program.Id)) + if (!_refreshedPrograms.ContainsKey(program.Id)) { - return; + _refreshedPrograms.TryAdd(program.Id, true); + return program.RefreshMetadata(cancellationToken); } - _refreshedPrograms.TryAdd(program.Id, true); - - await program.RefreshMetadata(cancellationToken).ConfigureAwait(false); + return _cachedTask; } public async Task GetInternalRecording(string id, CancellationToken cancellationToken) diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 02fdf9b93..aff630846 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -294,7 +294,7 @@ "LabelNewProgram": "NEW", "LabelPremiereProgram": "PREMIERE", "LabelHDProgram": "HD", - "HeaderChangeFolderType": "Change Folder Type", + "HeaderChangeFolderType": "Change Content Type", "HeaderChangeFolderTypeHelp": "To change the type, please remove and rebuild the folder with the new type.", "HeaderAlert": "Alert", "MessagePleaseRestart": "Please restart to finish updating.", @@ -627,7 +627,7 @@ "MessageInvitationSentToUser": "An email has been sent to {0}, inviting them to accept your sharing invitation.", "MessageInvitationSentToNewUser": "An email has been sent to {0} inviting them to sign up with Media Browser.", "HeaderConnectionFailure": "Connection Failure", - "MessageUnableToConnectToServer": "We're unable to connect to the selected server right now. Please try again later.", + "MessageUnableToConnectToServer": "We're unable to connect to the selected server right now. Please ensure it is running and try again.", "ButtonSelectServer": "Select server", "MessagePluginConfigurationRequiresLocalAccess": "To configure this plugin please sign in to your local server directly.", "MessageLoggedOutParentalControl": "Access is currently restricted. Please try again later.", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index e07c9adb7..2d00f3c76 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -241,10 +241,12 @@ "VisitMediaBrowserWebsite": "Visit the Media Browser Web Site", "VisitMediaBrowserWebsiteLong": "Visit the Media Browser Web site to catch the latest news and keep up with the developer blog.", "OptionHideUser": "Hide this user from login screens", + "OptionHideUserFromLoginHelp": "Useful for private or hidden administrator accounts. The user will need to sign in manually by entering their username and password.", "OptionDisableUser": "Disable this user", "OptionDisableUserHelp": "If disabled the server will not allow any connections from this user. Existing connections will be abruptly terminated.", "HeaderAdvancedControl": "Advanced Control", "LabelName": "Name:", + "ButtonHelp": "Help", "OptionAllowUserToManageServer": "Allow this user to manage the server", "HeaderFeatureAccess": "Feature Access", "OptionAllowMediaPlayback": "Allow media playback", diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 41f0a2806..bbdb89ac3 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -750,7 +750,14 @@ namespace MediaBrowser.Server.Startup.Common /// protected override void FindParts() { - if (IsFirstRun) + // TODO: Remove after next release + if (!IsFirstRun && !ServerConfigurationManager.Configuration.IsPortAuthorized) + { + ServerConfigurationManager.Configuration.IsPortAuthorized = true; + ConfigurationManager.SaveConfiguration(); + } + + if (!ServerConfigurationManager.Configuration.IsPortAuthorized) { RegisterServerWithAdministratorAccess(); } @@ -824,6 +831,9 @@ namespace MediaBrowser.Server.Startup.Common if (!HttpServer.UrlPrefixes.SequenceEqual(HttpServerUrlPrefixes, StringComparer.OrdinalIgnoreCase)) { + ServerConfigurationManager.Configuration.IsPortAuthorized = false; + ServerConfigurationManager.SaveConfiguration(); + NotifyPendingRestart(); } } diff --git a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs index 583255891..9bd9ac65e 100644 --- a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.XbmcMetadata.Savers return false; } - return item is MusicAlbum && updateType >= ItemUpdateType.ImageUpdate; + return item is MusicAlbum && updateType >= MinimumUpdateType; } protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer) diff --git a/MediaBrowser.XbmcMetadata/Savers/ArtistNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/ArtistNfoSaver.cs index 1ef0304fe..c592ec4b7 100644 --- a/MediaBrowser.XbmcMetadata/Savers/ArtistNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/ArtistNfoSaver.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.XbmcMetadata.Savers return false; } - return item is MusicArtist && updateType >= ItemUpdateType.ImageUpdate; + return item is MusicArtist && updateType >= MinimumUpdateType; } protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer) diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index 0f1d53ea6..da5126676 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -119,6 +119,19 @@ namespace MediaBrowser.XbmcMetadata.Savers protected IUserDataManager UserDataManager { get; private set; } protected ILogger Logger { get; private set; } + protected ItemUpdateType MinimumUpdateType + { + get + { + if (ConfigurationManager.GetNfoConfiguration().SaveImagePathsInNfo) + { + return ItemUpdateType.ImageUpdate; + } + + return ItemUpdateType.MetadataDownload; + } + } + public string Name { get diff --git a/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs index 090d41015..6fd396e40 100644 --- a/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs @@ -35,7 +35,7 @@ namespace MediaBrowser.XbmcMetadata.Savers return false; } - return item is Episode && updateType >= ItemUpdateType.ImageUpdate; + return item is Episode && updateType >= MinimumUpdateType; } protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer) diff --git a/MediaBrowser.XbmcMetadata/Savers/MovieNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/MovieNfoSaver.cs index bfb2b916e..d049843f3 100644 --- a/MediaBrowser.XbmcMetadata/Savers/MovieNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/MovieNfoSaver.cs @@ -55,7 +55,15 @@ namespace MediaBrowser.XbmcMetadata.Savers // Check parent for null to avoid running this against things like video backdrops if (video != null && !(item is Episode) && !video.IsOwnedItem) { - return updateType >= ItemUpdateType.ImageUpdate; + // If it's a plain video, skip if content type is unset (unless editing) + if (video.GetType() == typeof (Video)) + { + if (updateType < ItemUpdateType.MetadataEdit && string.IsNullOrEmpty(LibraryManager.GetContentType(video))) + { + return false; + } + } + return updateType >= MinimumUpdateType; } return false; @@ -95,8 +103,6 @@ namespace MediaBrowser.XbmcMetadata.Savers } } - private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - protected override List GetTagsUsed() { var list = new List diff --git a/MediaBrowser.XbmcMetadata/Savers/SeasonNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/SeasonNfoSaver.cs index 99a53fd9e..49ace7702 100644 --- a/MediaBrowser.XbmcMetadata/Savers/SeasonNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/SeasonNfoSaver.cs @@ -39,7 +39,7 @@ namespace MediaBrowser.XbmcMetadata.Savers return false; } - return updateType >= ItemUpdateType.ImageUpdate || (updateType >= ItemUpdateType.MetadataImport && File.Exists(GetSavePath(item))); + return updateType >= MinimumUpdateType || (updateType >= ItemUpdateType.MetadataImport && File.Exists(GetSavePath(item))); } protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer) diff --git a/MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs index 0498919ae..099e8dbd7 100644 --- a/MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs @@ -35,7 +35,7 @@ namespace MediaBrowser.XbmcMetadata.Savers return false; } - return item is Series && updateType >= ItemUpdateType.ImageUpdate; + return item is Series && updateType >= MinimumUpdateType; } protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer) -- cgit v1.2.3