aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs25
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs8
-rw-r--r--MediaBrowser.Api/WebSocket/LogFileWebSocketListener.cs6
-rw-r--r--MediaBrowser.Common.Implementations/Logging/NlogManager.cs2
-rw-r--r--MediaBrowser.Model/Configuration/UserConfiguration.cs3
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs17
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs25
-rw-r--r--MediaBrowser.Server.Implementations/Session/SessionManager.cs10
-rw-r--r--MediaBrowser.WebDashboard/Api/DashboardService.cs5
-rw-r--r--MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj14
10 files changed, 76 insertions, 39 deletions
diff --git a/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs b/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs
index 6cecbd0b6..6c56083cb 100644
--- a/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs
+++ b/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs
@@ -98,17 +98,20 @@ namespace MediaBrowser.Api
{
var auth = GetAuthorizationDictionary(httpReq);
- string userId;
- string deviceId;
- string device;
- string client;
- string version;
-
- auth.TryGetValue("UserId", out userId);
- auth.TryGetValue("DeviceId", out deviceId);
- auth.TryGetValue("Device", out device);
- auth.TryGetValue("Client", out client);
- auth.TryGetValue("Version", out version);
+ string userId = null;
+ string deviceId = null;
+ string device = null;
+ string client = null;
+ string version = null;
+
+ if (auth != null)
+ {
+ auth.TryGetValue("UserId", out userId);
+ auth.TryGetValue("DeviceId", out deviceId);
+ auth.TryGetValue("Device", out device);
+ auth.TryGetValue("Client", out client);
+ auth.TryGetValue("Version", out version);
+ }
return new AuthorizationInfo
{
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index f872b7274..394ca69d5 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -1007,6 +1007,13 @@ namespace MediaBrowser.Api.Playback
throw new InvalidOperationException("You asked for a debug error, you got one.");
}
+ var user = AuthorizationRequestFilterAttribute.GetCurrentUser(Request, UserManager);
+
+ if (user != null && !user.Configuration.EnableMediaPlayback)
+ {
+ throw new ArgumentException(string.Format("{0} is not allowed to play media.", user.Name));
+ }
+
var url = Request.PathInfo;
if (!request.AudioCodec.HasValue)
@@ -1060,6 +1067,7 @@ namespace MediaBrowser.Api.Playback
//state.RunTimeTicks = recording.RunTimeTicks;
state.ReadInputAtNativeFramerate = recording.RecordingInfo.Status == RecordingStatus.InProgress;
+ state.SendInputOverStandardInput = recording.RecordingInfo.Status == RecordingStatus.InProgress;
state.AudioSync = 1000;
state.DeInterlace = true;
}
diff --git a/MediaBrowser.Api/WebSocket/LogFileWebSocketListener.cs b/MediaBrowser.Api/WebSocket/LogFileWebSocketListener.cs
index eae232f11..4193cc797 100644
--- a/MediaBrowser.Api/WebSocket/LogFileWebSocketListener.cs
+++ b/MediaBrowser.Api/WebSocket/LogFileWebSocketListener.cs
@@ -111,9 +111,9 @@ namespace MediaBrowser.Api.WebSocket
{
var line = await reader.ReadLineAsync().ConfigureAwait(false);
- if (line.IndexOf(", Info,", StringComparison.OrdinalIgnoreCase) != -1 ||
- line.IndexOf(", Warn,", StringComparison.OrdinalIgnoreCase) != -1 ||
- line.IndexOf(", Error,", StringComparison.OrdinalIgnoreCase) != -1)
+ if (line.IndexOf("Info", StringComparison.OrdinalIgnoreCase) != -1 ||
+ line.IndexOf("Warn", StringComparison.OrdinalIgnoreCase) != -1 ||
+ line.IndexOf("Error", StringComparison.OrdinalIgnoreCase) != -1)
{
lines.Add(line);
}
diff --git a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
index 40dc380ea..fe530f917 100644
--- a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
+++ b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
@@ -89,7 +89,7 @@ namespace MediaBrowser.Common.Implementations.Logging
var logFile = new FileTarget
{
FileName = path,
- Layout = "${longdate}, ${level}, ${logger}, ${message}"
+ Layout = "${longdate} ${level} - ${logger}: ${message}"
};
RemoveTarget("ApplicationLogFile");
diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs
index 7cc61e7fd..ba4726956 100644
--- a/MediaBrowser.Model/Configuration/UserConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs
@@ -68,6 +68,8 @@ namespace MediaBrowser.Model.Configuration
public bool BlockUnratedBooks { get; set; }
public bool EnableLiveTvManagement { get; set; }
+
+ public bool EnableMediaPlayback { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="UserConfiguration" /> class.
@@ -79,6 +81,7 @@ namespace MediaBrowser.Model.Configuration
BlockNotRated = false;
EnableLiveTvManagement = true;
+ EnableMediaPlayback = true;
}
}
}
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
index 54fb345eb..b4c442ec8 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -253,13 +253,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
try
{
- LogHttpRequest(context, index);
-
var request = context.Request;
+ LogHttpRequest(request, index);
+
if (request.IsWebSocketRequest)
{
- ProcessWebSocketRequest(context);
+ await ProcessWebSocketRequest(context).ConfigureAwait(false);
return;
}
@@ -299,7 +299,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
if (EnableHttpRequestLogging)
{
- LoggerUtils.LogResponse(_logger, context, url, endPoint, duration);
+ LoggerUtils.LogResponse(_logger, context.Response, url, endPoint, duration);
}
}
catch (Exception ex)
@@ -315,10 +315,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <summary>
/// Logs the HTTP request.
/// </summary>
- /// <param name="ctx">The CTX.</param>
- private void LogHttpRequest(HttpListenerContext ctx, int index)
+ /// <param name="request">The request.</param>
+ /// <param name="index">The index.</param>
+ private void LogHttpRequest(HttpListenerRequest request, int index)
{
- var endpoint = ctx.Request.LocalEndPoint;
+ var endpoint = request.LocalEndPoint;
if (endpoint != null)
{
@@ -329,7 +330,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
if (EnableHttpRequestLogging)
{
- LoggerUtils.LogRequest(_logger, ctx, index);
+ LoggerUtils.LogRequest(_logger, request, index);
}
}
diff --git a/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs b/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs
index 8fe1297c7..cbb2c5642 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs
@@ -8,39 +8,44 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
public static class LoggerUtils
{
- public static void LogRequest(ILogger logger, HttpListenerContext ctx, int workerIndex)
+ /// <summary>
+ /// Logs the request.
+ /// </summary>
+ /// <param name="logger">The logger.</param>
+ /// <param name="request">The request.</param>
+ /// <param name="workerIndex">Index of the worker.</param>
+ public static void LogRequest(ILogger logger, HttpListenerRequest request, int workerIndex)
{
var log = new StringBuilder();
- log.AppendLine("Url: " + ctx.Request.Url);
- log.AppendLine("Headers: " + string.Join(",", ctx.Request.Headers.AllKeys.Select(k => k + "=" + ctx.Request.Headers[k])));
+ log.AppendLine("Ip: " + request.RemoteEndPoint + ". Headers: " + string.Join(",", request.Headers.AllKeys.Select(k => k + "=" + request.Headers[k])));
- var type = ctx.Request.IsWebSocketRequest ? "Web Socket" : "HTTP " + ctx.Request.HttpMethod;
+ var type = request.IsWebSocketRequest ? "Web Socket" : "HTTP " + request.HttpMethod;
- logger.LogMultiline(type + " request received on worker " + workerIndex + " from " + ctx.Request.RemoteEndPoint, LogSeverity.Debug, log);
+ logger.LogMultiline(type + " " + request.Url, LogSeverity.Debug, log);
}
/// <summary>
/// Logs the response.
/// </summary>
/// <param name="logger">The logger.</param>
- /// <param name="ctx">The CTX.</param>
+ /// <param name="response">The response.</param>
/// <param name="url">The URL.</param>
/// <param name="endPoint">The end point.</param>
/// <param name="duration">The duration.</param>
- public static void LogResponse(ILogger logger, HttpListenerContext ctx, string url, IPEndPoint endPoint, TimeSpan duration)
+ public static void LogResponse(ILogger logger, HttpListenerResponse response, string url, IPEndPoint endPoint, TimeSpan duration)
{
- var statusCode = ctx.Response.StatusCode;
+ var statusCode = response.StatusCode;
var log = new StringBuilder();
log.AppendLine(string.Format("Url: {0}", url));
- log.AppendLine("Headers: " + string.Join(",", ctx.Response.Headers.AllKeys.Select(k => k + "=" + ctx.Response.Headers[k])));
+ log.AppendLine("Headers: " + string.Join(",", response.Headers.AllKeys.Select(k => k + "=" + response.Headers[k])));
var responseTime = string.Format(". Response time: {0} ms", duration.TotalMilliseconds);
- var msg = "Response code " + statusCode + " sent to " + endPoint + responseTime;
+ var msg = "HTTP Response " + statusCode + " to " + endPoint + responseTime;
logger.LogMultiline(msg, LogSeverity.Debug, log);
}
diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
index d24de75cb..fd78d1aaa 100644
--- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs
+++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
@@ -604,6 +604,16 @@ namespace MediaBrowser.Server.Implementations.Session
{
var session = GetSessionForRemoteControl(sessionId);
+ if (session.UserId.HasValue)
+ {
+ var user = _userManager.GetUserById(session.UserId.Value);
+
+ if (!user.Configuration.EnableMediaPlayback)
+ {
+ throw new ArgumentException(string.Format("{0} is not allowed to play media.", user.Name));
+ }
+ }
+
var items = command.ItemIds.Select(i => _libraryManager.GetItemById(new Guid(i)))
.ToList();
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs
index 28b3970d3..ef1504ed5 100644
--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs
+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs
@@ -476,6 +476,8 @@ namespace MediaBrowser.WebDashboard.Api
"metadataadvanced.js",
"appsplayback.js",
"appsweather.js",
+ "autoorganizetv.js",
+ "autoorganizelog.js",
"dashboardinfo.js",
"dashboardpage.js",
"directorybrowser.js",
@@ -494,8 +496,6 @@ namespace MediaBrowser.WebDashboard.Api
"itemgallery.js",
"itemlistpage.js",
"librarysettings.js",
- "libraryfileorganizer.js",
- "libraryfileorganizerlog.js",
"livetvchannel.js",
"livetvchannels.js",
"livetvguide.js",
@@ -509,6 +509,7 @@ namespace MediaBrowser.WebDashboard.Api
"livetvseriestimers.js",
"livetvsettings.js",
"livetvsuggested.js",
+ "livetvstatus.js",
"livetvtimers.js",
"loginpage.js",
"logpage.js",
diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
index b60c533b3..f1cc75864 100644
--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
@@ -169,10 +169,10 @@
<Content Include="dashboard-ui\encodingsettings.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="dashboard-ui\libraryfileorganizer.html">
+ <Content Include="dashboard-ui\autoorganizetv.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="dashboard-ui\libraryfileorganizerlog.html">
+ <Content Include="dashboard-ui\autoorganizelog.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\livetvchannel.html">
@@ -196,6 +196,9 @@
<Content Include="dashboard-ui\livetvsettings.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="dashboard-ui\livetvstatus.html">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="dashboard-ui\livetvtimers.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -424,10 +427,10 @@
<Content Include="dashboard-ui\scripts\encodingsettings.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="dashboard-ui\scripts\libraryfileorganizer.js">
+ <Content Include="dashboard-ui\scripts\autoorganizetv.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="dashboard-ui\scripts\libraryfileorganizerlog.js">
+ <Content Include="dashboard-ui\scripts\autoorganizelog.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\scripts\librarymenu.js">
@@ -457,6 +460,9 @@
<Content Include="dashboard-ui\scripts\livetvsettings.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="dashboard-ui\scripts\livetvstatus.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="dashboard-ui\scripts\livetvtimer.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>