diff --git a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs index fb7596387..9071eecb2 100644 --- a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs +++ b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs @@ -235,7 +235,7 @@ namespace MediaBrowser.Dlna.ContentDirectory } else { - result.DocumentElement.AppendChild(_didlBuilder.GetItemElement(result, item, null, null, deviceId, filter)); + result.DocumentElement.AppendChild(_didlBuilder.GetItemElement(_config.GetDlnaConfiguration(), result, item, null, null, deviceId, filter)); } provided++; @@ -261,7 +261,7 @@ namespace MediaBrowser.Dlna.ContentDirectory } else { - result.DocumentElement.AppendChild(_didlBuilder.GetItemElement(result, childItem, item, serverItem.StubType, deviceId, filter)); + result.DocumentElement.AppendChild(_didlBuilder.GetItemElement(_config.GetDlnaConfiguration(), result, childItem, item, serverItem.StubType, deviceId, filter)); } } } @@ -338,7 +338,7 @@ namespace MediaBrowser.Dlna.ContentDirectory } else { - result.DocumentElement.AppendChild(_didlBuilder.GetItemElement(result, i, item, serverItem.StubType, deviceId, filter)); + result.DocumentElement.AppendChild(_didlBuilder.GetItemElement(_config.GetDlnaConfiguration(), result, i, item, serverItem.StubType, deviceId, filter)); } } diff --git a/MediaBrowser.Dlna/Didl/DidlBuilder.cs b/MediaBrowser.Dlna/Didl/DidlBuilder.cs index 40507db0c..91d1af8f4 100644 --- a/MediaBrowser.Dlna/Didl/DidlBuilder.cs +++ b/MediaBrowser.Dlna/Didl/DidlBuilder.cs @@ -19,6 +19,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Xml; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Dlna.Didl { @@ -56,7 +57,7 @@ namespace MediaBrowser.Dlna.Didl _user = user; } - public string GetItemDidl(BaseItem item, BaseItem context, string deviceId, Filter filter, StreamInfo streamInfo) + public string GetItemDidl(DlnaOptions options, BaseItem item, BaseItem context, string deviceId, Filter filter, StreamInfo streamInfo) { var result = new XmlDocument(); @@ -73,12 +74,12 @@ namespace MediaBrowser.Dlna.Didl result.AppendChild(didl); - result.DocumentElement.AppendChild(GetItemElement(result, item, context, null, deviceId, filter, streamInfo)); + result.DocumentElement.AppendChild(GetItemElement(options, result, item, context, null, deviceId, filter, streamInfo)); return result.DocumentElement.OuterXml; } - public XmlElement GetItemElement(XmlDocument doc, BaseItem item, BaseItem context, StubType? contextStubType, string deviceId, Filter filter, StreamInfo streamInfo = null) + public XmlElement GetItemElement(DlnaOptions options, XmlDocument doc, BaseItem item, BaseItem context, StubType? contextStubType, string deviceId, Filter filter, StreamInfo streamInfo = null) { var clientId = GetClientId(item, null); @@ -112,11 +113,11 @@ namespace MediaBrowser.Dlna.Didl { if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) { - AddAudioResource(element, hasMediaSources, deviceId, filter, streamInfo); + AddAudioResource(options, element, hasMediaSources, deviceId, filter, streamInfo); } else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) { - AddVideoResource(element, hasMediaSources, deviceId, filter, streamInfo); + AddVideoResource(options, element, hasMediaSources, deviceId, filter, streamInfo); } } @@ -125,13 +126,23 @@ namespace MediaBrowser.Dlna.Didl return element; } - private void AddVideoResource(XmlElement container, IHasMediaSources video, string deviceId, Filter filter, StreamInfo streamInfo = null) + private ILogger GetStreamBuilderLogger(DlnaOptions options) + { + if (options.EnableDebugLog) + { + return _logger; + } + + return new NullLogger(); + } + + private void AddVideoResource(DlnaOptions options, XmlElement container, IHasMediaSources video, string deviceId, Filter filter, StreamInfo streamInfo = null) { if (streamInfo == null) { var sources = _mediaSourceManager.GetStaticMediaSources(video, true, _user).ToList(); - streamInfo = new StreamBuilder(_logger).BuildVideoItem(new VideoOptions + streamInfo = new StreamBuilder(GetStreamBuilderLogger(options)).BuildVideoItem(new VideoOptions { ItemId = GetClientId(video), MediaSources = sources, @@ -368,7 +379,7 @@ namespace MediaBrowser.Dlna.Didl return item.Name; } - private void AddAudioResource(XmlElement container, IHasMediaSources audio, string deviceId, Filter filter, StreamInfo streamInfo = null) + private void AddAudioResource(DlnaOptions options, XmlElement container, IHasMediaSources audio, string deviceId, Filter filter, StreamInfo streamInfo = null) { var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL); @@ -376,7 +387,7 @@ namespace MediaBrowser.Dlna.Didl { var sources = _mediaSourceManager.GetStaticMediaSources(audio, true, _user).ToList(); - streamInfo = new StreamBuilder(new NullLogger()).BuildAudioItem(new AudioOptions + streamInfo = new StreamBuilder(GetStreamBuilderLogger(options)).BuildAudioItem(new AudioOptions { ItemId = GetClientId(audio), MediaSources = sources, diff --git a/MediaBrowser.Dlna/PlayTo/PlayToController.cs b/MediaBrowser.Dlna/PlayTo/PlayToController.cs index 7e021b877..314756cdf 100644 --- a/MediaBrowser.Dlna/PlayTo/PlayToController.cs +++ b/MediaBrowser.Dlna/PlayTo/PlayToController.cs @@ -17,6 +17,7 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Common.Configuration; namespace MediaBrowser.Dlna.PlayTo { @@ -33,6 +34,7 @@ namespace MediaBrowser.Dlna.PlayTo private readonly IUserDataManager _userDataManager; private readonly ILocalizationManager _localization; private readonly IMediaSourceManager _mediaSourceManager; + private readonly IConfigurationManager _config; private readonly IDeviceDiscovery _deviceDiscovery; private readonly string _serverAddress; @@ -58,7 +60,7 @@ namespace MediaBrowser.Dlna.PlayTo } return false; } - + return _device != null; } } @@ -72,7 +74,7 @@ namespace MediaBrowser.Dlna.PlayTo get { return IsSessionActive; } } - public PlayToController(SessionInfo session, ISessionManager sessionManager, ILibraryManager libraryManager, ILogger logger, IDlnaManager dlnaManager, IUserManager userManager, IImageProcessor imageProcessor, string serverAddress, string accessToken, IDeviceDiscovery deviceDiscovery, IUserDataManager userDataManager, ILocalizationManager localization, IMediaSourceManager mediaSourceManager) + public PlayToController(SessionInfo session, ISessionManager sessionManager, ILibraryManager libraryManager, ILogger logger, IDlnaManager dlnaManager, IUserManager userManager, IImageProcessor imageProcessor, string serverAddress, string accessToken, IDeviceDiscovery deviceDiscovery, IUserDataManager userDataManager, ILocalizationManager localization, IMediaSourceManager mediaSourceManager, IConfigurationManager config) { _session = session; _sessionManager = sessionManager; @@ -85,6 +87,7 @@ namespace MediaBrowser.Dlna.PlayTo _userDataManager = userDataManager; _localization = localization; _mediaSourceManager = mediaSourceManager; + _config = config; _accessToken = accessToken; _logger = logger; _creationTime = DateTime.UtcNow; @@ -476,7 +479,7 @@ namespace MediaBrowser.Dlna.PlayTo playlistItem.StreamUrl = playlistItem.StreamInfo.ToDlnaUrl(_serverAddress, _accessToken); var itemXml = new DidlBuilder(profile, user, _imageProcessor, _serverAddress, _accessToken, _userDataManager, _localization, _mediaSourceManager, _logger, _libraryManager) - .GetItemDidl(item, null, _session.DeviceId, new Filter(), playlistItem.StreamInfo); + .GetItemDidl(_config.GetDlnaConfiguration(), item, null, _session.DeviceId, new Filter(), playlistItem.StreamInfo); playlistItem.Didl = itemXml; @@ -532,13 +535,23 @@ namespace MediaBrowser.Dlna.PlayTo return null; } + private ILogger GetStreamBuilderLogger() + { + if (_config.GetDlnaConfiguration().EnableDebugLog) + { + return _logger; + } + + return new NullLogger(); + } + private PlaylistItem GetPlaylistItem(BaseItem item, List mediaSources, DeviceProfile profile, string deviceId, string mediaSourceId, int? audioStreamIndex, int? subtitleStreamIndex) { if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) { return new PlaylistItem { - StreamInfo = new StreamBuilder(_logger).BuildVideoItem(new VideoOptions + StreamInfo = new StreamBuilder(GetStreamBuilderLogger()).BuildVideoItem(new VideoOptions { ItemId = item.Id.ToString("N"), MediaSources = mediaSources, @@ -558,7 +571,7 @@ namespace MediaBrowser.Dlna.PlayTo { return new PlaylistItem { - StreamInfo = new StreamBuilder(_logger).BuildAudioItem(new AudioOptions + StreamInfo = new StreamBuilder(GetStreamBuilderLogger()).BuildAudioItem(new AudioOptions { ItemId = item.Id.ToString("N"), MediaSources = mediaSources, diff --git a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs index 94f8104be..06697dee6 100644 --- a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs +++ b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs @@ -134,7 +134,8 @@ namespace MediaBrowser.Dlna.PlayTo _deviceDiscovery, _userDataManager, _localization, - _mediaSourceManager); + _mediaSourceManager, + _config); controller.Init(device); diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 346dcf359..9d6343568 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -1966,13 +1966,13 @@ namespace MediaBrowser.Server.Implementations.Persistence whereClauses.Add(string.Format("(InheritedParentalRatingValue > 0 or UnratedType not in ({0}))", inClause)); } - //var excludeTagIndex = 0; - //foreach (var excludeTag in query.ExcludeTags) - //{ - // whereClauses.Add("Tags not like @excludeTag" + excludeTagIndex); - // cmd.Parameters.Add(cmd, "@excludeTag" + excludeTagIndex, DbType.String).Value = "%" + excludeTag + "%"; - // excludeTagIndex++; - //} + var excludeTagIndex = 0; + foreach (var excludeTag in query.ExcludeTags) + { + whereClauses.Add("Tags not like @excludeTag" + excludeTagIndex); + cmd.Parameters.Add(cmd, "@excludeTag" + excludeTagIndex, DbType.String).Value = "%" + excludeTag + "%"; + excludeTagIndex++; + } if (addPaging) { @@ -2070,8 +2070,6 @@ namespace MediaBrowser.Server.Implementations.Persistence _updateInheritedRatingCommand.Transaction = transaction; _updateInheritedRatingCommand.ExecuteNonQuery(); - - _updateInheritedRatingCommand.ExecuteNonQuery(); } transaction.Commit(); diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 95a17808d..38e8e28ba 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -104,9 +104,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest