rework collection editor
This commit is contained in:
parent
a0fa1b5f8f
commit
a2c371ec60
|
@ -108,7 +108,6 @@ namespace MediaBrowser.Api.Dlna
|
||||||
private readonly IConnectionManager _connectionManager;
|
private readonly IConnectionManager _connectionManager;
|
||||||
private readonly IMediaReceiverRegistrar _mediaReceiverRegistrar;
|
private readonly IMediaReceiverRegistrar _mediaReceiverRegistrar;
|
||||||
|
|
||||||
// TODO: Add utf-8
|
|
||||||
private const string XMLContentType = "text/xml; charset=UTF-8";
|
private const string XMLContentType = "text/xml; charset=UTF-8";
|
||||||
|
|
||||||
public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IConnectionManager connectionManager, IMediaReceiverRegistrar mediaReceiverRegistrar)
|
public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IConnectionManager connectionManager, IMediaReceiverRegistrar mediaReceiverRegistrar)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Common.IO;
|
||||||
|
using MediaBrowser.Model.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Implementations.Serialization
|
namespace MediaBrowser.Common.Implementations.Serialization
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Channels
|
|
||||||
{
|
|
||||||
public interface IChannelFactory
|
|
||||||
{
|
|
||||||
IEnumerable<IChannel> GetChannels();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IFactoryChannel
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Channels
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="channels">The channels.</param>
|
/// <param name="channels">The channels.</param>
|
||||||
/// <param name="factories">The factories.</param>
|
/// <param name="factories">The factories.</param>
|
||||||
void AddParts(IEnumerable<IChannel> channels, IEnumerable<IChannelFactory> factories);
|
void AddParts(IEnumerable<IChannel> channels);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the channel download path.
|
/// Gets the channel download path.
|
||||||
|
|
|
@ -77,7 +77,6 @@
|
||||||
<Compile Include="Channels\ChannelParentalRating.cs" />
|
<Compile Include="Channels\ChannelParentalRating.cs" />
|
||||||
<Compile Include="Channels\ChannelSearchInfo.cs" />
|
<Compile Include="Channels\ChannelSearchInfo.cs" />
|
||||||
<Compile Include="Channels\IChannel.cs" />
|
<Compile Include="Channels\IChannel.cs" />
|
||||||
<Compile Include="Channels\IChannelFactory.cs" />
|
|
||||||
<Compile Include="Channels\IChannelManager.cs" />
|
<Compile Include="Channels\IChannelManager.cs" />
|
||||||
<Compile Include="Channels\IChannelItem.cs" />
|
<Compile Include="Channels\IChannelItem.cs" />
|
||||||
<Compile Include="Channels\ChannelAudioItem.cs" />
|
<Compile Include="Channels\ChannelAudioItem.cs" />
|
||||||
|
|
|
@ -18,325 +18,325 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Dlna.Channels
|
namespace MediaBrowser.Dlna.Channels
|
||||||
{
|
{
|
||||||
public class DlnaChannelFactory : IChannelFactory, IDisposable
|
//public class DlnaChannelFactory : IChannelFactory, IDisposable
|
||||||
{
|
|
||||||
private readonly IServerConfigurationManager _config;
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IHttpClient _httpClient;
|
|
||||||
|
|
||||||
private readonly IDeviceDiscovery _deviceDiscovery;
|
|
||||||
|
|
||||||
private readonly SemaphoreSlim _syncLock = new SemaphoreSlim(1, 1);
|
|
||||||
private List<Device> _servers = new List<Device>();
|
|
||||||
|
|
||||||
public static DlnaChannelFactory Instance;
|
|
||||||
|
|
||||||
private Func<List<string>> _localServersLookup;
|
|
||||||
|
|
||||||
public DlnaChannelFactory(IServerConfigurationManager config, IHttpClient httpClient, ILogger logger, IDeviceDiscovery deviceDiscovery)
|
|
||||||
{
|
|
||||||
_config = config;
|
|
||||||
_httpClient = httpClient;
|
|
||||||
_logger = logger;
|
|
||||||
_deviceDiscovery = deviceDiscovery;
|
|
||||||
Instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Start(Func<List<string>> localServersLookup)
|
|
||||||
{
|
|
||||||
_localServersLookup = localServersLookup;
|
|
||||||
|
|
||||||
//deviceDiscovery.DeviceDiscovered += deviceDiscovery_DeviceDiscovered;
|
|
||||||
_deviceDiscovery.DeviceLeft += deviceDiscovery_DeviceLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
async void deviceDiscovery_DeviceDiscovered(object sender, SsdpMessageEventArgs e)
|
|
||||||
{
|
|
||||||
string usn;
|
|
||||||
if (!e.Headers.TryGetValue("USN", out usn)) usn = string.Empty;
|
|
||||||
|
|
||||||
string nt;
|
|
||||||
if (!e.Headers.TryGetValue("NT", out nt)) nt = string.Empty;
|
|
||||||
|
|
||||||
string location;
|
|
||||||
if (!e.Headers.TryGetValue("Location", out location)) location = string.Empty;
|
|
||||||
|
|
||||||
if (!IsValid(nt, usn))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_localServersLookup != null)
|
|
||||||
{
|
|
||||||
if (_localServersLookup().Any(i => usn.IndexOf(i, StringComparison.OrdinalIgnoreCase) != -1))
|
|
||||||
{
|
|
||||||
// Don't add the local Dlna server to this
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetExistingServers(usn).Any())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await _syncLock.WaitAsync().ConfigureAwait(false);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (GetExistingServers(usn).Any())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var device = await Device.CreateuPnpDeviceAsync(new Uri(location), _httpClient, _config, _logger)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (!_servers.Any(i => string.Equals(i.Properties.UUID, device.Properties.UUID, StringComparison.OrdinalIgnoreCase)))
|
|
||||||
{
|
|
||||||
_servers.Add(device);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_syncLock.Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async void deviceDiscovery_DeviceLeft(object sender, SsdpMessageEventArgs e)
|
|
||||||
{
|
|
||||||
string usn;
|
|
||||||
if (!e.Headers.TryGetValue("USN", out usn)) usn = String.Empty;
|
|
||||||
|
|
||||||
string nt;
|
|
||||||
if (!e.Headers.TryGetValue("NT", out nt)) nt = String.Empty;
|
|
||||||
|
|
||||||
if (!IsValid(nt, usn))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GetExistingServers(usn).Any())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await _syncLock.WaitAsync().ConfigureAwait(false);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _servers.ToList();
|
|
||||||
|
|
||||||
foreach (var device in GetExistingServers(usn).ToList())
|
|
||||||
{
|
|
||||||
list.Remove(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
_servers = list;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_syncLock.Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsValid(string nt, string usn)
|
|
||||||
{
|
|
||||||
// It has to report that it's a media renderer
|
|
||||||
if (usn.IndexOf("ContentDirectory:", StringComparison.OrdinalIgnoreCase) == -1 &&
|
|
||||||
nt.IndexOf("ContentDirectory:", StringComparison.OrdinalIgnoreCase) == -1 &&
|
|
||||||
usn.IndexOf("MediaServer:", StringComparison.OrdinalIgnoreCase) == -1 &&
|
|
||||||
nt.IndexOf("MediaServer:", StringComparison.OrdinalIgnoreCase) == -1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<Device> GetExistingServers(string usn)
|
|
||||||
{
|
|
||||||
return _servers
|
|
||||||
.Where(i => usn.IndexOf(i.Properties.UUID, StringComparison.OrdinalIgnoreCase) != -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<IChannel> GetChannels()
|
|
||||||
{
|
|
||||||
//if (_servers.Count > 0)
|
|
||||||
//{
|
//{
|
||||||
// var service = _servers[0].Properties.Services
|
// private readonly IServerConfigurationManager _config;
|
||||||
// .FirstOrDefault(i => string.Equals(i.ServiceType, "urn:schemas-upnp-org:service:ContentDirectory:1", StringComparison.OrdinalIgnoreCase));
|
// private readonly ILogger _logger;
|
||||||
|
// private readonly IHttpClient _httpClient;
|
||||||
|
|
||||||
// var controlUrl = service == null ? null : (_servers[0].Properties.BaseUrl.TrimEnd('/') + "/" + service.ControlUrl.TrimStart('/'));
|
// private readonly IDeviceDiscovery _deviceDiscovery;
|
||||||
|
|
||||||
// if (!string.IsNullOrEmpty(controlUrl))
|
// private readonly SemaphoreSlim _syncLock = new SemaphoreSlim(1, 1);
|
||||||
|
// private List<Device> _servers = new List<Device>();
|
||||||
|
|
||||||
|
// public static DlnaChannelFactory Instance;
|
||||||
|
|
||||||
|
// private Func<List<string>> _localServersLookup;
|
||||||
|
|
||||||
|
// public DlnaChannelFactory(IServerConfigurationManager config, IHttpClient httpClient, ILogger logger, IDeviceDiscovery deviceDiscovery)
|
||||||
// {
|
// {
|
||||||
// return new List<IChannel>
|
// _config = config;
|
||||||
|
// _httpClient = httpClient;
|
||||||
|
// _logger = logger;
|
||||||
|
// _deviceDiscovery = deviceDiscovery;
|
||||||
|
// Instance = this;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// internal void Start(Func<List<string>> localServersLookup)
|
||||||
// {
|
// {
|
||||||
// new ServerChannel(_servers.ToList(), _httpClient, _logger, controlUrl)
|
// _localServersLookup = localServersLookup;
|
||||||
// };
|
|
||||||
|
// //deviceDiscovery.DeviceDiscovered += deviceDiscovery_DeviceDiscovered;
|
||||||
|
// _deviceDiscovery.DeviceLeft += deviceDiscovery_DeviceLeft;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// async void deviceDiscovery_DeviceDiscovered(object sender, SsdpMessageEventArgs e)
|
||||||
|
// {
|
||||||
|
// string usn;
|
||||||
|
// if (!e.Headers.TryGetValue("USN", out usn)) usn = string.Empty;
|
||||||
|
|
||||||
|
// string nt;
|
||||||
|
// if (!e.Headers.TryGetValue("NT", out nt)) nt = string.Empty;
|
||||||
|
|
||||||
|
// string location;
|
||||||
|
// if (!e.Headers.TryGetValue("Location", out location)) location = string.Empty;
|
||||||
|
|
||||||
|
// if (!IsValid(nt, usn))
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (_localServersLookup != null)
|
||||||
|
// {
|
||||||
|
// if (_localServersLookup().Any(i => usn.IndexOf(i, StringComparison.OrdinalIgnoreCase) != -1))
|
||||||
|
// {
|
||||||
|
// // Don't add the local Dlna server to this
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (GetExistingServers(usn).Any())
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// await _syncLock.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// if (GetExistingServers(usn).Any())
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var device = await Device.CreateuPnpDeviceAsync(new Uri(location), _httpClient, _config, _logger)
|
||||||
|
// .ConfigureAwait(false);
|
||||||
|
|
||||||
|
// if (!_servers.Any(i => string.Equals(i.Properties.UUID, device.Properties.UUID, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
// {
|
||||||
|
// _servers.Add(device);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
// finally
|
||||||
|
// {
|
||||||
|
// _syncLock.Release();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// async void deviceDiscovery_DeviceLeft(object sender, SsdpMessageEventArgs e)
|
||||||
|
// {
|
||||||
|
// string usn;
|
||||||
|
// if (!e.Headers.TryGetValue("USN", out usn)) usn = String.Empty;
|
||||||
|
|
||||||
|
// string nt;
|
||||||
|
// if (!e.Headers.TryGetValue("NT", out nt)) nt = String.Empty;
|
||||||
|
|
||||||
|
// if (!IsValid(nt, usn))
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (!GetExistingServers(usn).Any())
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// await _syncLock.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var list = _servers.ToList();
|
||||||
|
|
||||||
|
// foreach (var device in GetExistingServers(usn).ToList())
|
||||||
|
// {
|
||||||
|
// list.Remove(device);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _servers = list;
|
||||||
|
// }
|
||||||
|
// finally
|
||||||
|
// {
|
||||||
|
// _syncLock.Release();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// private bool IsValid(string nt, string usn)
|
||||||
|
// {
|
||||||
|
// // It has to report that it's a media renderer
|
||||||
|
// if (usn.IndexOf("ContentDirectory:", StringComparison.OrdinalIgnoreCase) == -1 &&
|
||||||
|
// nt.IndexOf("ContentDirectory:", StringComparison.OrdinalIgnoreCase) == -1 &&
|
||||||
|
// usn.IndexOf("MediaServer:", StringComparison.OrdinalIgnoreCase) == -1 &&
|
||||||
|
// nt.IndexOf("MediaServer:", StringComparison.OrdinalIgnoreCase) == -1)
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// private IEnumerable<Device> GetExistingServers(string usn)
|
||||||
|
// {
|
||||||
|
// return _servers
|
||||||
|
// .Where(i => usn.IndexOf(i.Properties.UUID, StringComparison.OrdinalIgnoreCase) != -1);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public IEnumerable<IChannel> GetChannels()
|
||||||
|
// {
|
||||||
|
// //if (_servers.Count > 0)
|
||||||
|
// //{
|
||||||
|
// // var service = _servers[0].Properties.Services
|
||||||
|
// // .FirstOrDefault(i => string.Equals(i.ServiceType, "urn:schemas-upnp-org:service:ContentDirectory:1", StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
// // var controlUrl = service == null ? null : (_servers[0].Properties.BaseUrl.TrimEnd('/') + "/" + service.ControlUrl.TrimStart('/'));
|
||||||
|
|
||||||
|
// // if (!string.IsNullOrEmpty(controlUrl))
|
||||||
|
// // {
|
||||||
|
// // return new List<IChannel>
|
||||||
|
// // {
|
||||||
|
// // new ServerChannel(_servers.ToList(), _httpClient, _logger, controlUrl)
|
||||||
|
// // };
|
||||||
|
// // }
|
||||||
|
// //}
|
||||||
|
|
||||||
|
// return new List<IChannel>();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public void Dispose()
|
||||||
|
// {
|
||||||
|
// if (_deviceDiscovery != null)
|
||||||
|
// {
|
||||||
|
// _deviceDiscovery.DeviceDiscovered -= deviceDiscovery_DeviceDiscovered;
|
||||||
|
// _deviceDiscovery.DeviceLeft -= deviceDiscovery_DeviceLeft;
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return new List<IChannel>();
|
//public class ServerChannel : IChannel, IFactoryChannel
|
||||||
}
|
//{
|
||||||
|
// private readonly IHttpClient _httpClient;
|
||||||
|
// private readonly ILogger _logger;
|
||||||
|
// public string ControlUrl { get; set; }
|
||||||
|
// public List<Device> Servers { get; set; }
|
||||||
|
|
||||||
public void Dispose()
|
// public ServerChannel(IHttpClient httpClient, ILogger logger)
|
||||||
{
|
// {
|
||||||
if (_deviceDiscovery != null)
|
// _httpClient = httpClient;
|
||||||
{
|
// _logger = logger;
|
||||||
_deviceDiscovery.DeviceDiscovered -= deviceDiscovery_DeviceDiscovered;
|
// Servers = new List<Device>();
|
||||||
_deviceDiscovery.DeviceLeft -= deviceDiscovery_DeviceLeft;
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ServerChannel : IChannel, IFactoryChannel
|
// public string Name
|
||||||
{
|
// {
|
||||||
private readonly IHttpClient _httpClient;
|
// get { return "Devices"; }
|
||||||
private readonly ILogger _logger;
|
// }
|
||||||
public string ControlUrl { get; set; }
|
|
||||||
public List<Device> Servers { get; set; }
|
|
||||||
|
|
||||||
public ServerChannel(IHttpClient httpClient, ILogger logger)
|
// public string Description
|
||||||
{
|
// {
|
||||||
_httpClient = httpClient;
|
// get { return string.Empty; }
|
||||||
_logger = logger;
|
// }
|
||||||
Servers = new List<Device>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name
|
// public string DataVersion
|
||||||
{
|
// {
|
||||||
get { return "Devices"; }
|
// get { return DateTime.UtcNow.Ticks.ToString(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public string Description
|
// public string HomePageUrl
|
||||||
{
|
// {
|
||||||
get { return string.Empty; }
|
// get { return string.Empty; }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public string DataVersion
|
// public ChannelParentalRating ParentalRating
|
||||||
{
|
// {
|
||||||
get { return DateTime.UtcNow.Ticks.ToString(); }
|
// get { return ChannelParentalRating.GeneralAudience; }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public string HomePageUrl
|
// public InternalChannelFeatures GetChannelFeatures()
|
||||||
{
|
// {
|
||||||
get { return string.Empty; }
|
// return new InternalChannelFeatures
|
||||||
}
|
// {
|
||||||
|
// ContentTypes = new List<ChannelMediaContentType>
|
||||||
|
// {
|
||||||
|
// ChannelMediaContentType.Song,
|
||||||
|
// ChannelMediaContentType.Clip
|
||||||
|
// },
|
||||||
|
|
||||||
public ChannelParentalRating ParentalRating
|
// MediaTypes = new List<ChannelMediaType>
|
||||||
{
|
// {
|
||||||
get { return ChannelParentalRating.GeneralAudience; }
|
// ChannelMediaType.Audio,
|
||||||
}
|
// ChannelMediaType.Video,
|
||||||
|
// ChannelMediaType.Photo
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
public InternalChannelFeatures GetChannelFeatures()
|
// public bool IsEnabledFor(string userId)
|
||||||
{
|
// {
|
||||||
return new InternalChannelFeatures
|
// return true;
|
||||||
{
|
// }
|
||||||
ContentTypes = new List<ChannelMediaContentType>
|
|
||||||
{
|
|
||||||
ChannelMediaContentType.Song,
|
|
||||||
ChannelMediaContentType.Clip
|
|
||||||
},
|
|
||||||
|
|
||||||
MediaTypes = new List<ChannelMediaType>
|
// public async Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken)
|
||||||
{
|
// {
|
||||||
ChannelMediaType.Audio,
|
// IEnumerable<ChannelItemInfo> items;
|
||||||
ChannelMediaType.Video,
|
|
||||||
ChannelMediaType.Photo
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsEnabledFor(string userId)
|
// if (string.IsNullOrWhiteSpace(query.FolderId))
|
||||||
{
|
// {
|
||||||
return true;
|
// items = Servers.Select(i => new ChannelItemInfo
|
||||||
}
|
// {
|
||||||
|
// FolderType = ChannelFolderType.Container,
|
||||||
|
// Id = GetServerId(i),
|
||||||
|
// Name = i.Properties.Name,
|
||||||
|
// Overview = i.Properties.ModelDescription,
|
||||||
|
// Type = ChannelItemType.Folder
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// var idParts = query.FolderId.Split('|');
|
||||||
|
// var folderId = idParts.Length == 2 ? idParts[1] : null;
|
||||||
|
|
||||||
public async Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken)
|
// var result = await new ContentDirectoryBrowser(_httpClient, _logger).Browse(new ContentDirectoryBrowseRequest
|
||||||
{
|
// {
|
||||||
IEnumerable<ChannelItemInfo> items;
|
// Limit = query.Limit,
|
||||||
|
// StartIndex = query.StartIndex,
|
||||||
|
// ParentId = folderId,
|
||||||
|
// ContentDirectoryUrl = ControlUrl
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(query.FolderId))
|
// }, cancellationToken).ConfigureAwait(false);
|
||||||
{
|
|
||||||
items = Servers.Select(i => new ChannelItemInfo
|
|
||||||
{
|
|
||||||
FolderType = ChannelFolderType.Container,
|
|
||||||
Id = GetServerId(i),
|
|
||||||
Name = i.Properties.Name,
|
|
||||||
Overview = i.Properties.ModelDescription,
|
|
||||||
Type = ChannelItemType.Folder
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var idParts = query.FolderId.Split('|');
|
|
||||||
var folderId = idParts.Length == 2 ? idParts[1] : null;
|
|
||||||
|
|
||||||
var result = await new ContentDirectoryBrowser(_httpClient, _logger).Browse(new ContentDirectoryBrowseRequest
|
// items = result.Items.ToList();
|
||||||
{
|
// }
|
||||||
Limit = query.Limit,
|
|
||||||
StartIndex = query.StartIndex,
|
|
||||||
ParentId = folderId,
|
|
||||||
ContentDirectoryUrl = ControlUrl
|
|
||||||
|
|
||||||
}, cancellationToken).ConfigureAwait(false);
|
// var list = items.ToList();
|
||||||
|
// var count = list.Count;
|
||||||
|
|
||||||
items = result.Items.ToList();
|
// list = ApplyPaging(list, query).ToList();
|
||||||
}
|
|
||||||
|
|
||||||
var list = items.ToList();
|
// return new ChannelItemResult
|
||||||
var count = list.Count;
|
// {
|
||||||
|
// Items = list,
|
||||||
|
// TotalRecordCount = count
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
list = ApplyPaging(list, query).ToList();
|
// private string GetServerId(Device device)
|
||||||
|
// {
|
||||||
|
// return device.Properties.UUID.GetMD5().ToString("N");
|
||||||
|
// }
|
||||||
|
|
||||||
return new ChannelItemResult
|
// private IEnumerable<T> ApplyPaging<T>(IEnumerable<T> items, InternalChannelItemQuery query)
|
||||||
{
|
// {
|
||||||
Items = list,
|
// if (query.StartIndex.HasValue)
|
||||||
TotalRecordCount = count
|
// {
|
||||||
};
|
// items = items.Skip(query.StartIndex.Value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
private string GetServerId(Device device)
|
// if (query.Limit.HasValue)
|
||||||
{
|
// {
|
||||||
return device.Properties.UUID.GetMD5().ToString("N");
|
// items = items.Take(query.Limit.Value);
|
||||||
}
|
// }
|
||||||
|
|
||||||
private IEnumerable<T> ApplyPaging<T>(IEnumerable<T> items, InternalChannelItemQuery query)
|
// return items;
|
||||||
{
|
// }
|
||||||
if (query.StartIndex.HasValue)
|
|
||||||
{
|
|
||||||
items = items.Skip(query.StartIndex.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query.Limit.HasValue)
|
// public Task<DynamicImageResponse> GetChannelImage(ImageType type, CancellationToken cancellationToken)
|
||||||
{
|
// {
|
||||||
items = items.Take(query.Limit.Value);
|
// // TODO: Implement
|
||||||
}
|
// return Task.FromResult(new DynamicImageResponse
|
||||||
|
// {
|
||||||
|
// HasImage = false
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
return items;
|
// public IEnumerable<ImageType> GetSupportedChannelImages()
|
||||||
}
|
// {
|
||||||
|
// return new List<ImageType>
|
||||||
public Task<DynamicImageResponse> GetChannelImage(ImageType type, CancellationToken cancellationToken)
|
// {
|
||||||
{
|
// ImageType.Primary
|
||||||
// TODO: Implement
|
// };
|
||||||
return Task.FromResult(new DynamicImageResponse
|
// }
|
||||||
{
|
//}
|
||||||
HasImage = false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<ImageType> GetSupportedChannelImages()
|
|
||||||
{
|
|
||||||
return new List<ImageType>
|
|
||||||
{
|
|
||||||
ImageType.Primary
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,6 @@ namespace MediaBrowser.Dlna.Main
|
||||||
ReloadComponents();
|
ReloadComponents();
|
||||||
|
|
||||||
_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;
|
_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;
|
||||||
|
|
||||||
DlnaChannelFactory.Instance.Start(() => _registeredServerIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _config_NamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)
|
void _config_NamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)
|
||||||
|
|
|
@ -483,9 +483,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Output in webp for smaller sizes
|
|
||||||
// -f image2 -f webp
|
|
||||||
|
|
||||||
// Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case.
|
// Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case.
|
||||||
var args = useIFrame ? string.Format("-i {0} -threads 1 -v quiet -vframes 1 -vf \"{2},thumbnail=30\" -f image2 \"{1}\"", inputPath, "-", vf) :
|
var args = useIFrame ? string.Format("-i {0} -threads 1 -v quiet -vframes 1 -vf \"{2},thumbnail=30\" -f image2 \"{1}\"", inputPath, "-", vf) :
|
||||||
string.Format("-i {0} -threads 1 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, "-", vf);
|
string.Format("-i {0} -threads 1 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, "-", vf);
|
||||||
|
|
|
@ -276,11 +276,7 @@ namespace MediaBrowser.Model.Configuration
|
||||||
|
|
||||||
InsecureApps9 = new[]
|
InsecureApps9 = new[]
|
||||||
{
|
{
|
||||||
"Chromecast",
|
|
||||||
"iOS",
|
|
||||||
"Unknown app",
|
"Unknown app",
|
||||||
"iPad",
|
|
||||||
"iPhone",
|
|
||||||
"Windows Phone"
|
"Windows Phone"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ namespace MediaBrowser.Model.Dlna
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
return true;
|
return true;
|
||||||
case ProfileConditionValue.Has64BitOffsets:
|
case ProfileConditionValue.Has64BitOffsets:
|
||||||
// TODO: Implement
|
|
||||||
return true;
|
return true;
|
||||||
case ProfileConditionValue.IsAnamorphic:
|
case ProfileConditionValue.IsAnamorphic:
|
||||||
return IsConditionSatisfied(condition, isAnamorphic);
|
return IsConditionSatisfied(condition, isAnamorphic);
|
||||||
|
|
|
@ -79,8 +79,7 @@ namespace MediaBrowser.Providers.Omdb
|
||||||
|
|
||||||
public bool Supports(IHasImages item)
|
public bool Supports(IHasImages item)
|
||||||
{
|
{
|
||||||
// Save the http requests since we know it's not currently supported
|
// We'll hammer Omdb if we enable this
|
||||||
// TODO: Check again periodically
|
|
||||||
if (item is Person)
|
if (item is Person)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -31,7 +31,6 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||||
public class ChannelManager : IChannelManager, IDisposable
|
public class ChannelManager : IChannelManager, IDisposable
|
||||||
{
|
{
|
||||||
private IChannel[] _channels;
|
private IChannel[] _channels;
|
||||||
private IChannelFactory[] _factories;
|
|
||||||
|
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
private readonly IUserDataManager _userDataManager;
|
private readonly IUserDataManager _userDataManager;
|
||||||
|
@ -76,10 +75,9 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddParts(IEnumerable<IChannel> channels, IEnumerable<IChannelFactory> factories)
|
public void AddParts(IEnumerable<IChannel> channels)
|
||||||
{
|
{
|
||||||
_channels = channels.Where(i => !(i is IFactoryChannel)).ToArray();
|
_channels = channels.ToArray();
|
||||||
_factories = factories.ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ChannelDownloadPath
|
public string ChannelDownloadPath
|
||||||
|
@ -99,20 +97,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||||
|
|
||||||
private IEnumerable<IChannel> GetAllChannels()
|
private IEnumerable<IChannel> GetAllChannels()
|
||||||
{
|
{
|
||||||
return _factories
|
return _channels
|
||||||
.SelectMany(i =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return i.GetChannels().ToList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting channel list", ex);
|
|
||||||
return new List<IChannel>();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.Concat(_channels)
|
|
||||||
.OrderBy(i => i.Name);
|
.OrderBy(i => i.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,47 +69,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||||
token = httpReq.QueryString["api_key"];
|
token = httpReq.QueryString["api_key"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack until iOS is updated
|
|
||||||
// TODO: Remove
|
|
||||||
if (string.IsNullOrWhiteSpace(client))
|
|
||||||
{
|
|
||||||
var userAgent = httpReq.Headers["User-Agent"] ?? string.Empty;
|
|
||||||
|
|
||||||
if (userAgent.IndexOf("mediabrowserios", StringComparison.OrdinalIgnoreCase) != -1 ||
|
|
||||||
userAgent.IndexOf("iphone", StringComparison.OrdinalIgnoreCase) != -1 ||
|
|
||||||
userAgent.IndexOf("ipad", StringComparison.OrdinalIgnoreCase) != -1)
|
|
||||||
{
|
|
||||||
client = "iOS";
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (userAgent.IndexOf("crKey", StringComparison.OrdinalIgnoreCase) != -1)
|
|
||||||
{
|
|
||||||
client = "Chromecast";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hack until iOS is updated
|
|
||||||
// TODO: Remove
|
|
||||||
if (string.IsNullOrWhiteSpace(device))
|
|
||||||
{
|
|
||||||
var userAgent = httpReq.Headers["User-Agent"] ?? string.Empty;
|
|
||||||
|
|
||||||
if (userAgent.IndexOf("iPhone", StringComparison.OrdinalIgnoreCase) != -1)
|
|
||||||
{
|
|
||||||
device = "iPhone";
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (userAgent.IndexOf("iPad", StringComparison.OrdinalIgnoreCase) != -1)
|
|
||||||
{
|
|
||||||
device = "iPad";
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (userAgent.IndexOf("crKey", StringComparison.OrdinalIgnoreCase) != -1)
|
|
||||||
{
|
|
||||||
device = "Chromecast";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var info = new AuthorizationInfo
|
var info = new AuthorizationInfo
|
||||||
{
|
{
|
||||||
Client = client,
|
Client = client,
|
||||||
|
|
|
@ -962,8 +962,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make sure it hasn't been deleted
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -790,7 +790,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
|
|
||||||
SessionManager.AddParts(GetExports<ISessionControllerFactory>());
|
SessionManager.AddParts(GetExports<ISessionControllerFactory>());
|
||||||
|
|
||||||
ChannelManager.AddParts(GetExports<IChannel>(), GetExports<IChannelFactory>());
|
ChannelManager.AddParts(GetExports<IChannel>());
|
||||||
|
|
||||||
MediaSourceManager.AddParts(GetExports<IMediaSourceProvider>());
|
MediaSourceManager.AddParts(GetExports<IMediaSourceProvider>());
|
||||||
|
|
||||||
|
|
|
@ -1005,9 +1005,6 @@
|
||||||
<Content Include="dashboard-ui\scripts\dlnasettings.js">
|
<Content Include="dashboard-ui\scripts\dlnasettings.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="dashboard-ui\scripts\editcollectionitems.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="dashboard-ui\scripts\edititemsubtitles.js">
|
<Content Include="dashboard-ui\scripts\edititemsubtitles.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user