updated nuget

This commit is contained in:
Luke Pulverenti
2014-07-27 18:01:29 -04:00
parent 37c27a26e9
commit 063675bb07
58 changed files with 404 additions and 142 deletions

View File

@@ -1,5 +1,4 @@
using System.Linq;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Implementations.Configuration;
using MediaBrowser.Controller;
@@ -14,6 +13,7 @@ using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using System;
using System.IO;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Configuration
{

View File

@@ -66,22 +66,35 @@ namespace MediaBrowser.Server.Implementations.Dto
/// <exception cref="System.ArgumentNullException">item</exception>
public BaseItemDto GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null)
{
var dto = GetBaseItemDtoInternal(item, fields, user, owner);
var byName = item as IItemByName;
if (byName != null)
if (byName != null && !(item is LiveTvChannel))
{
var libraryItems = user != null ?
user.RootFolder.GetRecursiveChildren(user) :
_libraryManager.RootFolder.RecursiveChildren;
IEnumerable<BaseItem> libraryItems;
var dto = GetBaseItemDtoInternal(item, fields, user);
var artist = item as MusicArtist;
if (artist == null || artist.IsAccessedByName)
{
libraryItems = user != null ?
user.RootFolder.GetRecursiveChildren(user) :
_libraryManager.RootFolder.RecursiveChildren;
}
else
{
libraryItems = user != null ?
artist.GetRecursiveChildren(user) :
artist.RecursiveChildren;
}
SetItemByNameInfo(item, dto, byName.GetTaggedItems(libraryItems).ToList(), user);
return dto;
}
return GetBaseItemDtoInternal(item, fields, user, owner);
return dto;
}
private BaseItemDto GetBaseItemDtoInternal(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null)

View File

@@ -1,4 +1,5 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Plugins;
@@ -35,6 +36,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
/// The _HTTP server
/// </summary>
private readonly IHttpServer _httpServer;
private readonly IServerApplicationHost _appHost;
public const int PortNumber = 7359;
@@ -45,12 +47,13 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
/// <param name="networkManager">The network manager.</param>
/// <param name="serverConfigurationManager">The server configuration manager.</param>
/// <param name="httpServer">The HTTP server.</param>
public UdpServerEntryPoint(ILogger logger, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager, IHttpServer httpServer)
public UdpServerEntryPoint(ILogger logger, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager, IHttpServer httpServer, IServerApplicationHost appHost)
{
_logger = logger;
_networkManager = networkManager;
_serverConfigurationManager = serverConfigurationManager;
_httpServer = httpServer;
_appHost = appHost;
}
/// <summary>
@@ -58,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
/// </summary>
public void Run()
{
var udpServer = new UdpServer(_logger, _networkManager, _serverConfigurationManager, _httpServer);
var udpServer = new UdpServer(_logger, _networkManager, _serverConfigurationManager, _httpServer, _appHost);
try
{

View File

@@ -0,0 +1,21 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Configuration;
using System.Collections.Generic;
namespace MediaBrowser.Server.Implementations.LiveTv
{
public class LiveTvConfigurationFactory : IConfigurationFactory
{
public IEnumerable<ConfigurationStore> GetConfigurations()
{
return new List<ConfigurationStore>
{
new ConfigurationStore
{
ConfigurationType = typeof(LiveTvOptions),
Key = "livetv"
}
};
}
}
}

View File

@@ -1,4 +1,5 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Configuration;
@@ -11,6 +12,7 @@ using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.LiveTv;
@@ -83,6 +85,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
public ILiveTvService ActiveService { get; private set; }
private LiveTvOptions GetConfiguration()
{
return _config.GetConfiguration<LiveTvOptions>("livetv");
}
/// <summary>
/// Adds the parts.
/// </summary>
@@ -91,7 +98,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{
_services.AddRange(services);
SetActiveService(_config.Configuration.LiveTvOptions.ActiveService);
SetActiveService(GetConfiguration().ActiveService);
}
private void SetActiveService(string name)
@@ -303,22 +310,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
try
{
// Avoid implicitly captured closure
var itemId = id;
var stream = _openStreams
.Where(i => string.Equals(i.Value.ItemId, itemId) && isChannel == i.Value.IsChannel)
.Take(1)
.Select(i => i.Value)
.FirstOrDefault();
if (stream != null)
{
stream.ConsumerCount++;
_logger.Debug("Returning existing live tv stream");
return stream.Info;
}
var service = ActiveService;
LiveStreamInfo info;
@@ -1010,9 +1001,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private double GetGuideDays(int channelCount)
{
if (_config.Configuration.LiveTvOptions.GuideDays.HasValue)
var config = GetConfiguration();
if (config.GuideDays.HasValue)
{
return _config.Configuration.LiveTvOptions.GuideDays.Value;
return config.GuideDays.Value;
}
var programsPerDay = channelCount * 48;

View File

@@ -699,6 +699,10 @@
"HeaderProfileServerSettingsHelp": "These values control how Media Browser will present itself to the device.",
"LabelMaxBitrate": "Max bitrate:",
"LabelMaxBitrateHelp": "Specify a max bitrate in bandwidth constrained environments, or if the device imposes it's own limit.",
"LabelMaxStreamingBitrate": "Max streaming bitrate:",
"LabelMaxStreamingBitrateHelp": "Specify a max bitrate when streaming.",
"LabelMaxStaticBitrate": "Max sync bitrate:",
"LabelMaxStaticBitrateHelp": "Specify a max bitrate when syncing content at high quality.",
"OptionIgnoreTranscodeByteRangeRequests": "Ignore transcode byte range requests",
"OptionIgnoreTranscodeByteRangeRequestsHelp": "If enabled, these requests will be honored but will ignore the byte range header.",
"LabelFriendlyName": "Friendly name",
@@ -905,5 +909,11 @@
"HeaderChapters": "Chapters",
"HeaderResumeSettings": "Resume Settings",
"TabSync": "Sync",
"TitleUsers": "Users"
"TitleUsers": "Users",
"LabelProtocol": "Protocol:",
"OptionProtocolHttp": "Http",
"OptionProtocolHls": "Http Live Streaming",
"LabelContext": "Context:",
"OptionContextStreaming": "Streaming",
"OptionContextStatic": "Sync"
}

View File

@@ -198,6 +198,7 @@
<Compile Include="Library\Validators\YearsPostScanTask.cs" />
<Compile Include="LiveTv\ChannelImageProvider.cs" />
<Compile Include="LiveTv\CleanDatabaseScheduledTask.cs" />
<Compile Include="LiveTv\LiveTvConfigurationFactory.cs" />
<Compile Include="LiveTv\LiveTvDtoService.cs" />
<Compile Include="LiveTv\LiveTvManager.cs" />
<Compile Include="LiveTv\ProgramImageProvider.cs" />

View File

@@ -17,6 +17,10 @@ namespace MediaBrowser.Server.Implementations.Security
{
if (value == null) throw new ArgumentNullException("value");
#if __MonoCS__
return EncryptStringUniversal(value);
#endif
return Encoding.Default.GetString(ProtectedData.Protect(Encoding.Default.GetBytes(value), null, DataProtectionScope.LocalMachine));
}
@@ -30,7 +34,27 @@ namespace MediaBrowser.Server.Implementations.Security
{
if (value == null) throw new ArgumentNullException("value");
#if __MonoCS__
return DecryptStringUniversal(value);
#endif
return Encoding.Default.GetString(ProtectedData.Unprotect(Encoding.Default.GetBytes(value), null, DataProtectionScope.LocalMachine));
}
private string EncryptStringUniversal(string value)
{
// Yes, this isn't good, but ProtectedData in mono is throwing exceptions, so use this for now
var bytes = Encoding.UTF8.GetBytes(value);
return Convert.ToBase64String(bytes);
}
private string DecryptStringUniversal(string value)
{
// Yes, this isn't good, but ProtectedData in mono is throwing exceptions, so use this for now
var bytes = Convert.FromBase64String(value);
return Encoding.UTF8.GetString(bytes);
}
}
}

View File

@@ -1236,7 +1236,8 @@ namespace MediaBrowser.Server.Implementations.Session
{
User = _dtoService.GetUserDto(user),
SessionInfo = GetSessionInfoDto(session),
AccessToken = token
AccessToken = token,
ServerId = _appHost.ServerId
};
}

View File

@@ -68,7 +68,8 @@ namespace MediaBrowser.Server.Implementations.Sync
LimitType = request.LimitType,
RequestedItemIds = request.ItemIds,
DateCreated = DateTime.UtcNow,
DateLastModified = DateTime.UtcNow
DateLastModified = DateTime.UtcNow,
ItemCount = 1
};
await _repo.Create(job).ConfigureAwait(false);

View File

@@ -1,8 +1,12 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.ApiClient;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
@@ -37,6 +41,11 @@ namespace MediaBrowser.Server.Implementations.Udp
private bool _isDisposed;
private readonly List<Tuple<byte[], Action<string>>> _responders = new List<Tuple<byte[], Action<string>>>();
private readonly IServerApplicationHost _appHost;
private readonly IJsonSerializer _json;
/// <summary>
/// Initializes a new instance of the <see cref="UdpServer" /> class.
/// </summary>
@@ -44,12 +53,24 @@ namespace MediaBrowser.Server.Implementations.Udp
/// <param name="networkManager">The network manager.</param>
/// <param name="serverConfigurationManager">The server configuration manager.</param>
/// <param name="httpServer">The HTTP server.</param>
public UdpServer(ILogger logger, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager, IHttpServer httpServer)
/// <param name="appHost">The application host.</param>
public UdpServer(ILogger logger, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager, IHttpServer httpServer, IServerApplicationHost appHost)
{
_logger = logger;
_networkManager = networkManager;
_serverConfigurationManager = serverConfigurationManager;
_httpServer = httpServer;
_appHost = appHost;
AddMessageResponder("who is MediaBrowserServer?", RespondToV1Message);
AddMessageResponder("who is MediaBrowserServer_v2?", RespondToV2Message);
}
private void AddMessageResponder(string message, Action<string> responder)
{
var expectedMessageBytes = Encoding.UTF8.GetBytes(message);
_responders.Add(new Tuple<byte[], Action<string>>(expectedMessageBytes, responder));
}
/// <summary>
@@ -58,28 +79,51 @@ namespace MediaBrowser.Server.Implementations.Udp
/// <param name="e">The <see cref="UdpMessageReceivedEventArgs"/> instance containing the event data.</param>
private async void OnMessageReceived(UdpMessageReceivedEventArgs e)
{
const string context = "Server";
var responder = _responders.FirstOrDefault(i => i.Item1.SequenceEqual(e.Bytes));
var expectedMessage = String.Format("who is MediaBrowser{0}?", context);
var expectedMessageBytes = Encoding.UTF8.GetBytes(expectedMessage);
if (expectedMessageBytes.SequenceEqual(e.Bytes))
if (responder != null)
{
_logger.Info("Received UDP server request from " + e.RemoteEndPoint);
responder.Item2(e.RemoteEndPoint);
}
}
var localAddress = GetLocalIpAddress();
private async void RespondToV1Message(string endpoint)
{
var localAddress = GetLocalIpAddress();
if (!string.IsNullOrEmpty(localAddress))
if (!string.IsNullOrEmpty(localAddress))
{
// Send a response back with our ip address and port
var response = String.Format("MediaBrowserServer|{0}:{1}", localAddress, _serverConfigurationManager.Configuration.HttpServerPortNumber);
await SendAsync(Encoding.UTF8.GetBytes(response), endpoint);
}
else
{
_logger.Warn("Unable to respond to udp request because the local ip address could not be determined.");
}
}
private async void RespondToV2Message(string endpoint)
{
var localAddress = GetLocalIpAddress();
if (!string.IsNullOrEmpty(localAddress))
{
var serverAddress = string.Format("http://{0}:{1}", localAddress, _serverConfigurationManager.Configuration.HttpServerPortNumber);
var response = new ServerDiscoveryInfo
{
// Send a response back with our ip address and port
var response = String.Format("MediaBrowser{0}|{1}:{2}", context, GetLocalIpAddress(), _serverConfigurationManager.Configuration.HttpServerPortNumber);
Address = serverAddress,
Id = _appHost.ServerId,
Name = _appHost.Name
};
await SendAsync(Encoding.UTF8.GetBytes(response), e.RemoteEndPoint);
}
else
{
_logger.Warn("Unable to respond to udp request because the local ip address could not be determined.");
}
await SendAsync(Encoding.UTF8.GetBytes(_json.SerializeToString(response)), endpoint);
}
else
{
_logger.Warn("Unable to respond to udp request because the local ip address could not be determined.");
}
}