From 86ad04b6571a9e44744f135caac768e8f1acdcde Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Wed, 16 Sep 2020 12:02:00 +0100 Subject: [PATCH 1/4] Update DescriptionXmlBuilder.cs --- Emby.Dlna/Server/DescriptionXmlBuilder.cs | 59 +++++++++++++---------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/Emby.Dlna/Server/DescriptionXmlBuilder.cs b/Emby.Dlna/Server/DescriptionXmlBuilder.cs index bca9e81cd0..44b5e070fb 100644 --- a/Emby.Dlna/Server/DescriptionXmlBuilder.cs +++ b/Emby.Dlna/Server/DescriptionXmlBuilder.cs @@ -6,7 +6,6 @@ using System.Globalization; using System.Linq; using System.Security; using System.Text; -using Emby.Dlna.Common; using MediaBrowser.Model.Dlna; namespace Emby.Dlna.Server @@ -20,8 +19,9 @@ namespace Emby.Dlna.Server private readonly string _serverAddress; private readonly string _serverName; private readonly string _serverId; + private readonly string _customName; - public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string serverAddress, string serverName, string serverId) + public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string serverAddress, string serverName, string serverId, string customName) { if (string.IsNullOrEmpty(serverUdn)) { @@ -38,6 +38,7 @@ namespace Emby.Dlna.Server _serverAddress = serverAddress; _serverName = serverName; _serverId = serverId; + _customName = customName; } private static bool EnableAbsoluteUrls => false; @@ -168,7 +169,12 @@ namespace Emby.Dlna.Server { if (string.IsNullOrEmpty(_profile.FriendlyName)) { - return "Jellyfin - " + _serverName; + if (string.IsNullOrEmpty(_customName)) + { + return "Jellyfin - " + _serverName; + } + + return _customName; } var characterList = new List(); @@ -235,13 +241,13 @@ namespace Emby.Dlna.Server .Append(SecurityElement.Escape(service.ServiceId ?? string.Empty)) .Append(""); builder.Append("") - .Append(BuildUrl(service.ScpdUrl)) + .Append(BuildUrl(service.ScpdUrl, true)) .Append(""); builder.Append("") - .Append(BuildUrl(service.ControlUrl)) + .Append(BuildUrl(service.ControlUrl, true)) .Append(""); builder.Append("") - .Append(BuildUrl(service.EventSubUrl)) + .Append(BuildUrl(service.EventSubUrl, true)) .Append(""); builder.Append(""); @@ -250,7 +256,7 @@ namespace Emby.Dlna.Server builder.Append(""); } - private string BuildUrl(string url) + private string BuildUrl(string url, bool absoluteUrl = false) { if (string.IsNullOrEmpty(url)) { @@ -261,7 +267,7 @@ namespace Emby.Dlna.Server url = "/dlna/" + _serverUdn + "/" + url; - if (EnableAbsoluteUrls) + if (EnableAbsoluteUrls || absoluteUrl) { url = _serverAddress.TrimEnd('/') + url; } @@ -269,7 +275,7 @@ namespace Emby.Dlna.Server return SecurityElement.Escape(url); } - private IEnumerable GetIcons() + private static IEnumerable GetIcons() => new[] { new DeviceIcon @@ -329,25 +335,26 @@ namespace Emby.Dlna.Server private IEnumerable GetServices() { - var list = new List(); - - list.Add(new DeviceService + var list = new List { - ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1", - ServiceId = "urn:upnp-org:serviceId:ContentDirectory", - ScpdUrl = "contentdirectory/contentdirectory.xml", - ControlUrl = "contentdirectory/control", - EventSubUrl = "contentdirectory/events" - }); + new DeviceService + { + ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1", + ServiceId = "urn:upnp-org:serviceId:ContentDirectory", + ScpdUrl = "contentdirectory/contentdirectory.xml", + ControlUrl = "contentdirectory/control", + EventSubUrl = "contentdirectory/events" + }, - list.Add(new DeviceService - { - ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1", - ServiceId = "urn:upnp-org:serviceId:ConnectionManager", - ScpdUrl = "connectionmanager/connectionmanager.xml", - ControlUrl = "connectionmanager/control", - EventSubUrl = "connectionmanager/events" - }); + new DeviceService + { + ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1", + ServiceId = "urn:upnp-org:serviceId:ConnectionManager", + ScpdUrl = "connectionmanager/connectionmanager.xml", + ControlUrl = "connectionmanager/control", + EventSubUrl = "connectionmanager/events" + } + }; if (_profile.EnableMSMediaReceiverRegistrar) { From c2e2e5ac0ce298e550a02eeb2e853497d7f9e647 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Wed, 16 Sep 2020 12:03:17 +0100 Subject: [PATCH 2/4] Update DescriptionXmlBuilder.cs --- Emby.Dlna/Server/DescriptionXmlBuilder.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Emby.Dlna/Server/DescriptionXmlBuilder.cs b/Emby.Dlna/Server/DescriptionXmlBuilder.cs index 44b5e070fb..14f47e0417 100644 --- a/Emby.Dlna/Server/DescriptionXmlBuilder.cs +++ b/Emby.Dlna/Server/DescriptionXmlBuilder.cs @@ -256,6 +256,12 @@ namespace Emby.Dlna.Server builder.Append(""); } + /// + /// Builds a valid url for inclusion in the xml. + /// + /// Url to include. + /// Optional. When set to true, the absolute url is always used. + /// The url to use for the element. private string BuildUrl(string url, bool absoluteUrl = false) { if (string.IsNullOrEmpty(url)) From a6400d12c9bd8e32497f6510fe7491fd0325650a Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Wed, 16 Sep 2020 12:08:23 +0100 Subject: [PATCH 3/4] Update DescriptionXmlBuilder.cs --- Emby.Dlna/Server/DescriptionXmlBuilder.cs | 53 ++++++++++------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/Emby.Dlna/Server/DescriptionXmlBuilder.cs b/Emby.Dlna/Server/DescriptionXmlBuilder.cs index 14f47e0417..d449d5fe82 100644 --- a/Emby.Dlna/Server/DescriptionXmlBuilder.cs +++ b/Emby.Dlna/Server/DescriptionXmlBuilder.cs @@ -4,8 +4,9 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Security; +using System.Security;a using System.Text; +using Emby.Dlna.Common; using MediaBrowser.Model.Dlna; namespace Emby.Dlna.Server @@ -19,9 +20,8 @@ namespace Emby.Dlna.Server private readonly string _serverAddress; private readonly string _serverName; private readonly string _serverId; - private readonly string _customName; - public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string serverAddress, string serverName, string serverId, string customName) + public DescriptionXmlBuilder(DeviceProfile profile, string serverUdn, string serverAddress, string serverName, string serverId) { if (string.IsNullOrEmpty(serverUdn)) { @@ -38,7 +38,6 @@ namespace Emby.Dlna.Server _serverAddress = serverAddress; _serverName = serverName; _serverId = serverId; - _customName = customName; } private static bool EnableAbsoluteUrls => false; @@ -169,12 +168,7 @@ namespace Emby.Dlna.Server { if (string.IsNullOrEmpty(_profile.FriendlyName)) { - if (string.IsNullOrEmpty(_customName)) - { - return "Jellyfin - " + _serverName; - } - - return _customName; + return "Jellyfin - " + _serverName; } var characterList = new List(); @@ -281,7 +275,7 @@ namespace Emby.Dlna.Server return SecurityElement.Escape(url); } - private static IEnumerable GetIcons() + private IEnumerable GetIcons() => new[] { new DeviceIcon @@ -341,26 +335,25 @@ namespace Emby.Dlna.Server private IEnumerable GetServices() { - var list = new List - { - new DeviceService - { - ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1", - ServiceId = "urn:upnp-org:serviceId:ContentDirectory", - ScpdUrl = "contentdirectory/contentdirectory.xml", - ControlUrl = "contentdirectory/control", - EventSubUrl = "contentdirectory/events" - }, + var list = new List(); - new DeviceService - { - ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1", - ServiceId = "urn:upnp-org:serviceId:ConnectionManager", - ScpdUrl = "connectionmanager/connectionmanager.xml", - ControlUrl = "connectionmanager/control", - EventSubUrl = "connectionmanager/events" - } - }; + list.Add(new DeviceService + { + ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1", + ServiceId = "urn:upnp-org:serviceId:ContentDirectory", + ScpdUrl = "contentdirectory/contentdirectory.xml", + ControlUrl = "contentdirectory/control", + EventSubUrl = "contentdirectory/events" + }); + + list.Add(new DeviceService + { + ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1", + ServiceId = "urn:upnp-org:serviceId:ConnectionManager", + ScpdUrl = "connectionmanager/connectionmanager.xml", + ControlUrl = "connectionmanager/control", + EventSubUrl = "connectionmanager/events" + }); if (_profile.EnableMSMediaReceiverRegistrar) { From d99db543daf770a059830627dbdc255ae6abe42e Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Wed, 16 Sep 2020 12:08:37 +0100 Subject: [PATCH 4/4] Update DescriptionXmlBuilder.cs --- Emby.Dlna/Server/DescriptionXmlBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Dlna/Server/DescriptionXmlBuilder.cs b/Emby.Dlna/Server/DescriptionXmlBuilder.cs index d449d5fe82..1f429d0de3 100644 --- a/Emby.Dlna/Server/DescriptionXmlBuilder.cs +++ b/Emby.Dlna/Server/DescriptionXmlBuilder.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Security;a +using System.Security; using System.Text; using Emby.Dlna.Common; using MediaBrowser.Model.Dlna;