From 78acab691693d6adfac67bcf3f0617e336f801a6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 17 Mar 2014 10:48:16 -0400 Subject: [PATCH] expand device identification --- .../Dlna/DeviceIdentification.cs | 56 ++++++ MediaBrowser.Controller/Dlna/DeviceProfile.cs | 32 +--- MediaBrowser.Controller/Dlna/IDlnaManager.cs | 9 +- .../MediaBrowser.Controller.csproj | 1 + MediaBrowser.Dlna/DlnaManager.cs | 163 +++++++++++++----- MediaBrowser.Dlna/PlayTo/DeviceInfo.cs | 13 ++ MediaBrowser.Dlna/PlayTo/DlnaController.cs | 2 +- MediaBrowser.Dlna/PlayTo/PlayToManager.cs | 2 +- .../Api/DashboardService.cs | 1 + .../MediaBrowser.WebDashboard.csproj | 3 + 10 files changed, 201 insertions(+), 81 deletions(-) create mode 100644 MediaBrowser.Controller/Dlna/DeviceIdentification.cs diff --git a/MediaBrowser.Controller/Dlna/DeviceIdentification.cs b/MediaBrowser.Controller/Dlna/DeviceIdentification.cs new file mode 100644 index 0000000000..a3a6155160 --- /dev/null +++ b/MediaBrowser.Controller/Dlna/DeviceIdentification.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Dlna +{ + public class DeviceIdentification + { + /// + /// Gets or sets the name of the friendly. + /// + /// The name of the friendly. + public string FriendlyName { get; set; } + /// + /// Gets or sets the model number. + /// + /// The model number. + public string ModelNumber { get; set; } + /// + /// Gets or sets the serial number. + /// + /// The serial number. + public string SerialNumber { get; set; } + /// + /// Gets or sets the name of the model. + /// + /// The name of the model. + public string ModelName { get; set; } + /// + /// Gets or sets the manufacturer. + /// + /// + /// The manufacturer. + /// + public string Manufacturer { get; set; } + /// + /// Gets or sets the manufacturer URL. + /// + /// The manufacturer URL. + public string ManufacturerUrl { get; set; } + /// + /// Gets or sets the headers. + /// + /// The headers. + public List Headers { get; set; } + + public DeviceIdentification() + { + Headers = new List(); + } + } + + public class HttpHeaderInfo + { + public string Name { get; set; } + public string Value { get; set; } + } +} diff --git a/MediaBrowser.Controller/Dlna/DeviceProfile.cs b/MediaBrowser.Controller/Dlna/DeviceProfile.cs index f3a3bc1713..119cfffd74 100644 --- a/MediaBrowser.Controller/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Controller/Dlna/DeviceProfile.cs @@ -15,32 +15,6 @@ namespace MediaBrowser.Controller.Dlna /// The type of the client. public string ClientType { get; set; } - /// - /// Gets or sets the name of the friendly. - /// - /// The name of the friendly. - public string FriendlyName { get; set; } - - /// - /// Gets or sets the model number. - /// - /// The model number. - public string ModelNumber { get; set; } - - /// - /// Gets or sets the name of the model. - /// - /// The name of the model. - public string ModelName { get; set; } - - /// - /// Gets or sets the manufacturer. - /// - /// - /// The manufacturer. - /// - public string Manufacturer { get; set; } - /// /// Gets or sets the transcoding profiles. /// @@ -53,6 +27,12 @@ namespace MediaBrowser.Controller.Dlna /// The direct play profiles. public DirectPlayProfile[] DirectPlayProfiles { get; set; } + /// + /// Gets or sets the identification. + /// + /// The identification. + public DeviceIdentification Identification { get; set; } + public DeviceProfile() { DirectPlayProfiles = new DirectPlayProfile[] { }; diff --git a/MediaBrowser.Controller/Dlna/IDlnaManager.cs b/MediaBrowser.Controller/Dlna/IDlnaManager.cs index 599b42dd54..6de17e5511 100644 --- a/MediaBrowser.Controller/Dlna/IDlnaManager.cs +++ b/MediaBrowser.Controller/Dlna/IDlnaManager.cs @@ -19,11 +19,8 @@ namespace MediaBrowser.Controller.Dlna /// /// Gets the profile. /// - /// Name of the friendly. - /// Name of the model. - /// The model number. - /// The manufacturer. - /// DlnaProfile. - DeviceProfile GetProfile(string friendlyName, string modelName, string modelNumber, string manufacturer); + /// The device information. + /// DeviceProfile. + DeviceProfile GetProfile(DeviceIdentification deviceInfo); } } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 7e5e6d9b0c..2dc444ea93 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -73,6 +73,7 @@ + diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index 6766400d9e..b0c1e17498 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -3,6 +3,7 @@ using MediaBrowser.Common.IO; using MediaBrowser.Controller.Dlna; using MediaBrowser.Model.Serialization; using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; namespace MediaBrowser.Dlna @@ -31,9 +32,13 @@ namespace MediaBrowser.Dlna { Name = "Samsung TV (B Series)", ClientType = "DLNA", - FriendlyName = "^TV$", - ModelNumber = @"1\.0", - ModelName = "Samsung DTV DMR", + + Identification = new DeviceIdentification + { + FriendlyName = "^TV$", + ModelNumber = @"1\.0", + ModelName = "Samsung DTV DMR" + }, TranscodingProfiles = new[] { @@ -82,8 +87,12 @@ namespace MediaBrowser.Dlna { Name = "Samsung TV (E/F-series)", ClientType = "DLNA", - FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung|(^\[TV\]Samsung [A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)", - ModelNumber = @"(1\.0)|(AllShare1\.0)", + + Identification = new DeviceIdentification + { + FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung|(^\[TV\]Samsung [A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)", + ModelNumber = @"(1\.0)|(AllShare1\.0)" + }, TranscodingProfiles = new[] { @@ -130,8 +139,13 @@ namespace MediaBrowser.Dlna { Name = "Samsung TV (C/D-series)", ClientType = "DLNA", - FriendlyName = @"(^TV-\d{2}C\d{3}.*)|(^\[TV\][A-Z]{2}\d{2}(D)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung", - ModelNumber = @"(1\.0)|(AllShare1\.0)", + + Identification = new DeviceIdentification + { + FriendlyName = @"(^TV-\d{2}C\d{3}.*)|(^\[TV\][A-Z]{2}\d{2}(D)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung", + ModelNumber = @"(1\.0)|(AllShare1\.0)" + }, + TranscodingProfiles = new[] { new TranscodingProfile @@ -181,7 +195,12 @@ namespace MediaBrowser.Dlna { Name = "Xbox 360", ClientType = "DLNA", - ModelName = "Xbox 360", + + Identification = new DeviceIdentification + { + ModelName = "Xbox 360" + }, + TranscodingProfiles = new[] { new TranscodingProfile @@ -215,9 +234,14 @@ namespace MediaBrowser.Dlna list.Add(new DeviceProfile { Name = "Xbox One", - ModelName = "Xbox One", ClientType = "DLNA", - FriendlyName = "Xbox-SystemOS", + + Identification = new DeviceIdentification + { + ModelName = "Xbox One", + FriendlyName = "Xbox-SystemOS" + }, + TranscodingProfiles = new[] { new TranscodingProfile @@ -256,7 +280,11 @@ namespace MediaBrowser.Dlna { Name = "Sony Bravia (2012)", ClientType = "DLNA", - FriendlyName = @"BRAVIA KDL-\d{2}[A-Z]X\d5(\d|G).*", + + Identification = new DeviceIdentification + { + FriendlyName = @"BRAVIA KDL-\d{2}[A-Z]X\d5(\d|G).*" + }, TranscodingProfiles = new[] { @@ -292,7 +320,11 @@ namespace MediaBrowser.Dlna { Name = "Sony Bravia (2013)", ClientType = "DLNA", - FriendlyName = @"BRAVIA (KDL-\d{2}W[689]\d{2}A.*)|(KD-\d{2}X9\d{3}A.*)", + + Identification = new DeviceIdentification + { + FriendlyName = @"BRAVIA (KDL-\d{2}W[689]\d{2}A.*)|(KD-\d{2}X9\d{3}A.*)" + }, TranscodingProfiles = new[] { @@ -346,8 +378,12 @@ namespace MediaBrowser.Dlna //Panasonic Viera (2011|2012) Without AVI Support Name = "Panasonic Viera E/S/ST/VT (2011)", ClientType = "DLNA", - FriendlyName = @"(VIERA (E|S)T?(3|5)0?.*)|(VIERA VT30.*)", - Manufacturer = "Panasonic", + + Identification = new DeviceIdentification + { + FriendlyName = @"(VIERA (E|S)T?(3|5)0?.*)|(VIERA VT30.*)", + Manufacturer = "Panasonic" + }, TranscodingProfiles = new[] { @@ -383,8 +419,12 @@ namespace MediaBrowser.Dlna //Panasonic Viera (2011|2012) With AVI Support Name = "Panasonic Viera G/GT/DT/UT/VT (2011/2012)", ClientType = "DLNA", - FriendlyName = @"(VIERA (G|D|U)T?(3|5)0?.*)|(VIERA VT50.*)", - Manufacturer = "Panasonic", + + Identification = new DeviceIdentification + { + FriendlyName = @"(VIERA (G|D|U)T?(3|5)0?.*)|(VIERA VT50.*)", + Manufacturer = "Panasonic" + }, TranscodingProfiles = new[] { @@ -427,9 +467,13 @@ namespace MediaBrowser.Dlna list.Add(new DeviceProfile { Name = "Philips (2010-)", - FriendlyName = ".*PHILIPS.*", ClientType = "DLNA", - ModelName = "WD TV HD Live", + + Identification = new DeviceIdentification + { + FriendlyName = ".*PHILIPS.*", + ModelName = "WD TV HD Live" + }, DirectPlayProfiles = new[] { @@ -460,7 +504,11 @@ namespace MediaBrowser.Dlna { Name = "WDTV Live", ClientType = "DLNA", - ModelName = "WD TV HD Live", + + Identification = new DeviceIdentification + { + ModelName = "WD TV HD Live" + }, DirectPlayProfiles = new[] { @@ -483,7 +531,11 @@ namespace MediaBrowser.Dlna //Linksys DMA2100us does not need any transcoding of the formats we support statically Name = "Linksys DMA2100", ClientType = "DLNA", - ModelName = "DMA2100us", + + Identification = new DeviceIdentification + { + ModelName = "DMA2100us" + }, DirectPlayProfiles = new[] { @@ -504,9 +556,13 @@ namespace MediaBrowser.Dlna list.Add(new DeviceProfile { Name = "Denon AVR", - FriendlyName = @"Denon:\[AVR:.*", - Manufacturer = "Denon", - ClientType = "DLNA", + ClientType = "DLNA", + + Identification = new DeviceIdentification + { + FriendlyName = @"Denon:\[AVR:.*", + Manufacturer = "Denon" + }, DirectPlayProfiles = new[] { @@ -561,38 +617,51 @@ namespace MediaBrowser.Dlna }; } - public DeviceProfile GetProfile(string friendlyName, string modelName, string modelNumber, string manufacturer) + public DeviceProfile GetProfile(DeviceIdentification deviceInfo) + { + return GetProfiles().FirstOrDefault(i => IsMatch(deviceInfo, i.Identification)) ?? + GetDefaultProfile(); + } + + private bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo) { - foreach (var profile in GetProfiles()) + if (!string.IsNullOrEmpty(profileInfo.FriendlyName)) { - if (!string.IsNullOrEmpty(profile.FriendlyName)) - { - if (!Regex.IsMatch(friendlyName, profile.FriendlyName)) - continue; - } + if (!Regex.IsMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName)) + return false; + } - if (!string.IsNullOrEmpty(profile.ModelNumber)) - { - if (!Regex.IsMatch(modelNumber, profile.ModelNumber)) - continue; - } + if (!string.IsNullOrEmpty(profileInfo.ModelNumber)) + { + if (!Regex.IsMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber)) + return false; + } - if (!string.IsNullOrEmpty(profile.ModelName)) - { - if (!Regex.IsMatch(modelName, profile.ModelName)) - continue; - } + if (!string.IsNullOrEmpty(profileInfo.ModelName)) + { + if (!Regex.IsMatch(deviceInfo.ModelName, profileInfo.ModelName)) + return false; + } - if (!string.IsNullOrEmpty(profile.Manufacturer)) - { - if (!Regex.IsMatch(manufacturer, profile.Manufacturer)) - continue; - } + if (!string.IsNullOrEmpty(profileInfo.Manufacturer)) + { + if (!Regex.IsMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer)) + return false; + } - return profile; + if (!string.IsNullOrEmpty(profileInfo.ManufacturerUrl)) + { + if (!Regex.IsMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl)) + return false; + } + if (!string.IsNullOrEmpty(profileInfo.SerialNumber)) + { + if (!Regex.IsMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber)) + return false; } - return GetDefaultProfile(); + + return true; } } } \ No newline at end of file diff --git a/MediaBrowser.Dlna/PlayTo/DeviceInfo.cs b/MediaBrowser.Dlna/PlayTo/DeviceInfo.cs index f952b725e1..4b40daf704 100644 --- a/MediaBrowser.Dlna/PlayTo/DeviceInfo.cs +++ b/MediaBrowser.Dlna/PlayTo/DeviceInfo.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using MediaBrowser.Controller.Dlna; namespace MediaBrowser.Dlna.PlayTo { @@ -62,5 +63,17 @@ namespace MediaBrowser.Dlna.PlayTo return _services; } } + + public DeviceIdentification ToDeviceIdentification() + { + return new DeviceIdentification + { + Manufacturer = Manufacturer, + ModelName = ModelName, + ModelNumber = ModelNumber, + FriendlyName = Name, + ManufacturerUrl = ManufacturerUrl + }; + } } } diff --git a/MediaBrowser.Dlna/PlayTo/DlnaController.cs b/MediaBrowser.Dlna/PlayTo/DlnaController.cs index b3f1accc72..4180154a40 100644 --- a/MediaBrowser.Dlna/PlayTo/DlnaController.cs +++ b/MediaBrowser.Dlna/PlayTo/DlnaController.cs @@ -395,7 +395,7 @@ namespace MediaBrowser.Dlna.PlayTo var deviceInfo = _device.Properties; - var playlistItem = PlaylistItem.Create(item, _dlnaManager.GetProfile(deviceInfo.Name, deviceInfo.ModelName, deviceInfo.ModelNumber, deviceInfo.Manufacturer)); + var playlistItem = PlaylistItem.Create(item, _dlnaManager.GetProfile(deviceInfo.ToDeviceIdentification())); playlistItem.StartPositionTicks = startPostionTicks; if (playlistItem.IsAudio) diff --git a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs index 2fc03f2f95..d18ed595f8 100644 --- a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs +++ b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs @@ -246,7 +246,7 @@ namespace MediaBrowser.Dlna.PlayTo /// The TranscodeSettings for the device private void GetProfileSettings(DeviceInfo deviceProperties) { - var profile = _dlnaManager.GetProfile(deviceProperties.Name, deviceProperties.ModelName, deviceProperties.ModelNumber, deviceProperties.Manufacturer); + var profile = _dlnaManager.GetProfile(deviceProperties.ToDeviceIdentification()); if (!string.IsNullOrWhiteSpace(profile.Name)) { diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 8d54a64e91..2fc3caa2ad 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -461,6 +461,7 @@ namespace MediaBrowser.WebDashboard.Api "extensions.js", "site.js", "librarybrowser.js", + "librarylist.js", "editorsidebar.js", "librarymenu.js", //"chromecast.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 04ce347fb6..15f1609423 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -512,6 +512,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest