From 1539836ca1ca833715c9bc2b58cfc1efea47bb30 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 6 Nov 2016 12:30:44 -0500 Subject: [PATCH] update didl xml --- Emby.Dlna/ContentDirectory/ControlHandler.cs | 14 ++--- Emby.Dlna/Didl/DidlBuilder.cs | 55 ++++++++++++------- Emby.Dlna/Service/BaseControlHandler.cs | 8 +-- Emby.Dlna/Service/ControlErrorHandler.cs | 8 +-- .../LiveTv/LiveStreamHelper.cs | 2 +- .../Sync/IServerSyncProvider.cs | 4 -- .../Encoder/EncoderValidator.cs | 16 +++++- ...MediaBrowser.Server.Implementations.csproj | 4 +- .../packages.config | 2 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 11 files changed, 68 insertions(+), 51 deletions(-) diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index dc599b993..8cb59b056 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -232,10 +232,7 @@ namespace Emby.Dlna.ContentDirectory writer.WriteAttributeString("xmlns", "upnp", null, NS_UPNP); //didl.SetAttribute("xmlns:sec", NS_SEC); - foreach (var att in _profile.XmlRootAttributes) - { - writer.WriteAttributeString(att.Name, att.Value); - } + DidlBuilder.WriteXmlRootAttributes(_profile, writer); var serverItem = GetItemFromObjectId(id, user); var item = serverItem.Item; @@ -282,7 +279,7 @@ namespace Emby.Dlna.ContentDirectory } } } - writer.WriteEndElement(); + writer.WriteFullEndElement(); //writer.WriteEndDocument(); } @@ -345,10 +342,7 @@ namespace Emby.Dlna.ContentDirectory writer.WriteAttributeString("xmlns", "upnp", null, NS_UPNP); //didl.SetAttribute("xmlns:sec", NS_SEC); - foreach (var att in _profile.XmlRootAttributes) - { - writer.WriteAttributeString(att.Name, att.Value); - } + DidlBuilder.WriteXmlRootAttributes(_profile, writer); var serverItem = GetItemFromObjectId(sparams["ContainerID"], user); @@ -375,7 +369,7 @@ namespace Emby.Dlna.ContentDirectory } } - writer.WriteEndElement(); + writer.WriteFullEndElement(); //writer.WriteEndDocument(); } diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index ee5c8fecd..3ad33f0fe 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -84,28 +84,39 @@ namespace Emby.Dlna.Didl writer.WriteAttributeString("xmlns", "upnp", null, NS_UPNP); //didl.SetAttribute("xmlns:sec", NS_SEC); - foreach (var att in _profile.XmlRootAttributes) - { - writer.WriteAttributeString(att.Name, att.Value); - } + WriteXmlRootAttributes(_profile, writer); WriteItemElement(options, writer, item, context, null, deviceId, filter, streamInfo); - writer.WriteEndElement(); + writer.WriteFullEndElement(); //writer.WriteEndDocument(); } return builder.ToString(); } + public static void WriteXmlRootAttributes(DeviceProfile profile, XmlWriter writer) + { + foreach (var att in profile.XmlRootAttributes) + { + var parts = att.Name.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 2) + { + writer.WriteAttributeString(parts[0], parts[1], null, att.Value); + } + else + { + writer.WriteAttributeString(att.Name, att.Value); + } + } + } + public void WriteItemElement(DlnaOptions options, XmlWriter writer, BaseItem item, BaseItem context, StubType? contextStubType, string deviceId, Filter filter, StreamInfo streamInfo = null) { var clientId = GetClientId(item, null); writer.WriteStartElement(string.Empty, "item", NS_DIDL); - AddGeneralProperties(item, null, context, writer, filter); - writer.WriteAttributeString("restricted", "1"); writer.WriteAttributeString("id", clientId); @@ -122,6 +133,8 @@ namespace Emby.Dlna.Didl } } + AddGeneralProperties(item, null, context, writer, filter); + //AddBookmarkInfo(item, user, element); // refID? @@ -142,7 +155,7 @@ namespace Emby.Dlna.Didl } AddCover(item, context, null, writer); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } private ILogger GetStreamBuilderLogger(DlnaOptions options) @@ -236,7 +249,7 @@ namespace Emby.Dlna.Didl writer.WriteAttributeString("sec", "type", null, info.Format.ToLower()); writer.WriteString(info.Url); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } else if (string.Equals(subtitleMode, "smi", StringComparison.OrdinalIgnoreCase)) { @@ -245,7 +258,7 @@ namespace Emby.Dlna.Didl writer.WriteAttributeString("protocolInfo", "http-get:*:smi/caption:*"); writer.WriteString(info.Url); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } else { @@ -254,7 +267,7 @@ namespace Emby.Dlna.Didl writer.WriteAttributeString("protocolInfo", protocolInfo); writer.WriteString(info.Url); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } return true; @@ -349,7 +362,7 @@ namespace Emby.Dlna.Didl writer.WriteString(url); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } private string GetDisplayName(BaseItem item, StubType? itemStubType, BaseItem context) @@ -479,7 +492,7 @@ namespace Emby.Dlna.Didl writer.WriteString(url); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } public static bool IsIdRoot(string id) @@ -501,8 +514,6 @@ namespace Emby.Dlna.Didl { writer.WriteStartElement(string.Empty, "container", NS_DIDL); - AddGeneralProperties(folder, stubType, context, writer, filter); - writer.WriteAttributeString("restricted", "0"); writer.WriteAttributeString("searchable", "1"); writer.WriteAttributeString("childCount", childCount.ToString(_usCulture)); @@ -536,9 +547,11 @@ namespace Emby.Dlna.Didl } } + AddGeneralProperties(folder, stubType, context, writer, filter); + AddCover(folder, context, stubType, writer); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } //private void AddBookmarkInfo(BaseItem item, User user, XmlElement element) @@ -698,7 +711,7 @@ namespace Emby.Dlna.Didl writer.WriteString("object.item"); } - writer.WriteEndElement(); + writer.WriteFullEndElement(); } private void AddPeople(BaseItem item, XmlWriter writer) @@ -811,7 +824,7 @@ namespace Emby.Dlna.Didl writer.WriteString(name); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } catch (XmlException) { @@ -897,7 +910,7 @@ namespace Emby.Dlna.Didl writer.WriteStartElement("upnp", "albumArtURI", NS_UPNP); writer.WriteAttributeString("dlna", "profileID", NS_DLNA, _profile.AlbumArtPn); writer.WriteString(albumartUrlInfo.Url); - writer.WriteEndElement(); + writer.WriteFullEndElement(); // TOOD: Remove these default values var iconUrlInfo = GetImageUrl(imageInfo, _profile.MaxIconWidth ?? 48, _profile.MaxIconHeight ?? 48, playbackPercentage, unplayedCount, "jpg"); @@ -932,7 +945,7 @@ namespace Emby.Dlna.Didl writer.WriteStartElement("upnp", "albumArtURI", NS_UPNP); writer.WriteAttributeString("dlna", "profileID", NS_DLNA, _profile.AlbumArtPn); writer.WriteString(_serverAddress + "/Dlna/icons/people480.jpg"); - writer.WriteEndElement(); + writer.WriteFullEndElement(); writer.WriteElementString("upnp", "icon", NS_UPNP, _serverAddress + "/Dlna/icons/people48.jpg"); } @@ -976,7 +989,7 @@ namespace Emby.Dlna.Didl writer.WriteString(albumartUrlInfo.Url); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } private ImageDownloadInfo GetImageInfo(BaseItem item) diff --git a/Emby.Dlna/Service/BaseControlHandler.cs b/Emby.Dlna/Service/BaseControlHandler.cs index afc66b1d7..35203edae 100644 --- a/Emby.Dlna/Service/BaseControlHandler.cs +++ b/Emby.Dlna/Service/BaseControlHandler.cs @@ -99,12 +99,12 @@ namespace Emby.Dlna.Service { writer.WriteStartElement(i.Key); writer.WriteString(i.Value); - writer.WriteEndElement(); + writer.WriteFullEndElement(); } - writer.WriteEndElement(); - writer.WriteEndElement(); + writer.WriteFullEndElement(); + writer.WriteFullEndElement(); - writer.WriteEndElement(); + writer.WriteFullEndElement(); writer.WriteEndDocument(); } diff --git a/Emby.Dlna/Service/ControlErrorHandler.cs b/Emby.Dlna/Service/ControlErrorHandler.cs index 07b4dad60..a3cd77f0f 100644 --- a/Emby.Dlna/Service/ControlErrorHandler.cs +++ b/Emby.Dlna/Service/ControlErrorHandler.cs @@ -36,12 +36,12 @@ namespace Emby.Dlna.Service writer.WriteStartElement("detail"); writer.WriteRaw("401Invalid Action"); - writer.WriteEndElement(); + writer.WriteFullEndElement(); - writer.WriteEndElement(); - writer.WriteEndElement(); + writer.WriteFullEndElement(); + writer.WriteFullEndElement(); - writer.WriteEndElement(); + writer.WriteFullEndElement(); writer.WriteEndDocument(); } diff --git a/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs b/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs index 99996c252..a338ae23a 100644 --- a/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs +++ b/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs @@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.LiveTv Protocol = mediaSource.Protocol, MediaType = isAudio ? DlnaProfileType.Audio : DlnaProfileType.Video, ExtractChapters = false, - AnalyzeDurationSections = 3 + AnalyzeDurationSections = 2 }, cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Controller/Sync/IServerSyncProvider.cs b/MediaBrowser.Controller/Sync/IServerSyncProvider.cs index 1869d6126..3913e86f0 100644 --- a/MediaBrowser.Controller/Sync/IServerSyncProvider.cs +++ b/MediaBrowser.Controller/Sync/IServerSyncProvider.cs @@ -40,10 +40,6 @@ namespace MediaBrowser.Controller.Sync /// Task<Stream>. Task GetFile(string id, SyncTarget target, IProgress progress, CancellationToken cancellationToken); - /// - /// Gets the files. - /// - Task> GetFiles(string id, SyncTarget target, CancellationToken cancellationToken); Task> GetFiles(string[] pathParts, SyncTarget target, CancellationToken cancellationToken); Task> GetFiles(SyncTarget target, CancellationToken cancellationToken); } diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 20b5eb05d..6acdccf3d 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.Logging; @@ -40,9 +41,11 @@ namespace MediaBrowser.MediaEncoding.Encoder { } + output = output ?? string.Empty; + if (logOutput) { - _logger.Info("ffmpeg info: {0}", output ?? string.Empty); + _logger.Info("ffmpeg info: {0}", output); } if (string.IsNullOrWhiteSpace(output)) @@ -55,6 +58,17 @@ namespace MediaBrowser.MediaEncoding.Encoder return false; } + output = " " + output + " "; + + for (var i = 2013; i <= 2015; i++) + { + var yearString = i.ToString(CultureInfo.InvariantCulture); + if (output.IndexOf(" " + yearString + " ", StringComparison.OrdinalIgnoreCase) != -1) + { + return false; + } + } + return true; } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 10ebe4ea6..780dcb676 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -76,8 +76,8 @@ False ..\ThirdParty\SharpCompress\SharpCompress.dll - - ..\packages\SocketHttpListener.1.0.0.40\lib\net45\SocketHttpListener.dll + + ..\packages\SocketHttpListener.1.0.0.43\lib\net45\SocketHttpListener.dll True diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index 5ba04f7a8..415ba1652 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -5,6 +5,6 @@ - + \ No newline at end of file diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index b94b54736..e813c0a0a 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.683 + 3.0.684 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index c0d5d2705..9b0c10cbb 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.683 + 3.0.684 Emby.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - +