diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 48f7cd62e..074dba7c5 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -200,6 +200,8 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "SeriesTimerId", Description = "Optional filter by timers belonging to a series timer", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string SeriesTimerId { get; set; } + + public bool? IsActive { get; set; } } [Route("/LiveTv/Programs", "GET,POST", Summary = "Gets available live tv epgs..")] @@ -927,7 +929,8 @@ namespace MediaBrowser.Api.LiveTv var result = await _liveTvManager.GetTimers(new TimerQuery { ChannelId = request.ChannelId, - SeriesTimerId = request.SeriesTimerId + SeriesTimerId = request.SeriesTimerId, + IsActive = request.IsActive }, CancellationToken.None).ConfigureAwait(false); diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index e4949b4d8..93c9f8b9f 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -69,9 +69,9 @@ namespace MediaBrowser.Api _config.SaveConfiguration(); } - public object Get(GetStartupInfo request) + public async Task Get(GetStartupInfo request) { - var info = _appHost.GetSystemInfo(); + var info = await _appHost.GetSystemInfo().ConfigureAwait(false); return new StartupInfo { diff --git a/MediaBrowser.Api/System/SystemInfoWebSocketListener.cs b/MediaBrowser.Api/System/SystemInfoWebSocketListener.cs index 9ab7770ed..a53bfac27 100644 --- a/MediaBrowser.Api/System/SystemInfoWebSocketListener.cs +++ b/MediaBrowser.Api/System/SystemInfoWebSocketListener.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Api.System /// Task{SystemInfo}. protected override Task GetDataToSend(WebSocketListenerState state) { - return Task.FromResult(_appHost.GetSystemInfo()); + return _appHost.GetSystemInfo(); } } } diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index 1610be85d..346f6b32a 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -157,16 +157,16 @@ namespace MediaBrowser.Api.System /// /// The request. /// System.Object. - public object Get(GetSystemInfo request) + public async Task Get(GetSystemInfo request) { - var result = _appHost.GetSystemInfo(); + var result = await _appHost.GetSystemInfo().ConfigureAwait(false); return ToOptimizedResult(result); } - public object Get(GetPublicSystemInfo request) + public async Task Get(GetPublicSystemInfo request) { - var result = _appHost.GetSystemInfo(); + var result = await _appHost.GetSystemInfo().ConfigureAwait(false); var publicInfo = new PublicSystemInfo { diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 78b7d2ccd..f4c0e7658 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Controller /// Gets the system info. /// /// SystemInfo. - SystemInfo GetSystemInfo(); + Task GetSystemInfo(); /// /// Gets a value indicating whether [supports automatic run at startup]. diff --git a/MediaBrowser.Model/LiveTv/TimerQuery.cs b/MediaBrowser.Model/LiveTv/TimerQuery.cs index e6ceff530..87b6b89ac 100644 --- a/MediaBrowser.Model/LiveTv/TimerQuery.cs +++ b/MediaBrowser.Model/LiveTv/TimerQuery.cs @@ -13,5 +13,7 @@ /// /// The series timer identifier. public string SeriesTimerId { get; set; } + + public bool? IsActive { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs index 020856886..fb4397462 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -39,6 +39,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); + public Func ResultScope { get; set; } + public List Cookies { get; private set; } + /// /// Additional HTTP Headers /// @@ -81,6 +84,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer Options["Accept-Ranges"] = "bytes"; StatusCode = HttpStatusCode.PartialContent; + Cookies = new List(); SetRangeValues(); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs index ed9e17b6b..efa850922 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Text; using System.Web; +using ServiceStack; using ServiceStack.Web; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp @@ -116,6 +117,21 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp } } + public string Accept + { + get + { + return string.IsNullOrEmpty(request.Headers[HttpHeaders.Accept]) ? null : request.Headers[HttpHeaders.Accept]; + } + } + + public string Authorization + { + get + { + return string.IsNullOrEmpty(request.Headers[HttpHeaders.Authorization]) ? null : request.Headers[HttpHeaders.Authorization]; + } + } protected bool validate_cookies, validate_query_string, validate_form; protected bool checked_cookies, checked_query_string, checked_form; diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs index 30849d441..c7d889505 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp this.OperationName = operationName; this.RequestAttributes = requestAttributes; this.request = httpContext.Request; - this.response = new WebSocketSharpResponse(logger, httpContext.Response); + this.response = new WebSocketSharpResponse(logger, httpContext.Response, this); this.RequestPreferences = new RequestPreferences(this); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs index 171dacb22..e08be8bd1 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Net; using MediaBrowser.Model.Logging; @@ -14,14 +15,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp private readonly ILogger _logger; private readonly HttpListenerResponse response; - public WebSocketSharpResponse(ILogger logger, HttpListenerResponse response) + public WebSocketSharpResponse(ILogger logger, HttpListenerResponse response, IRequest request) { _logger = logger; this.response = response; + Items = new Dictionary(); + Request = request; } + public IRequest Request { get; private set; } public bool UseBufferedStream { get; set; } - + public Dictionary Items { get; private set; } public object OriginalResponse { get { return response; } @@ -58,6 +62,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp response.AddHeader(name, value); } + public string GetHeader(string name) + { + return response.Headers[name]; + } + public void Redirect(string url) { response.Redirect(url); @@ -142,5 +151,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp } public bool KeepAlive { get; set; } + + public void ClearCookies() + { + } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index d38e9ad32..1b43ff7c1 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1010,6 +1010,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV Action onStarted = () => { + timer.Status = RecordingStatus.InProgress; + _timerProvider.AddOrUpdate(timer); + result.Item3.Release(); isResourceOpen = false; }; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 552139b4a..9f80877f6 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1665,6 +1665,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv var results = await Task.WhenAll(tasks).ConfigureAwait(false); var timers = results.SelectMany(i => i.ToList()); + if (query.IsActive.HasValue) + { + if (query.IsActive.Value) + { + timers = timers.Where(i => i.Item1.Status == RecordingStatus.InProgress); + } + else + { + timers = timers.Where(i => i.Item1.Status != RecordingStatus.InProgress); + } + } + if (!string.IsNullOrEmpty(query.ChannelId)) { var guid = new Guid(query.ChannelId); diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index c69c788c8..cfe0564fb 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -392,7 +392,103 @@ + + swagger-ui\lib\backbone-min.js + PreserveNewest + + + swagger-ui\lib\handlebars-2.0.0.js + PreserveNewest + + + swagger-ui\lib\highlight.7.3.pack.js + PreserveNewest + + + swagger-ui\lib\jquery-1.8.0.min.js + PreserveNewest + + + swagger-ui\lib\jquery.ba-bbq.min.js + PreserveNewest + + + swagger-ui\lib\jquery.slideto.min.js + PreserveNewest + + + swagger-ui\lib\jquery.wiggle.min.js + PreserveNewest + + + swagger-ui\lib\marked.js + PreserveNewest + + + swagger-ui\lib\shred.bundle.js + PreserveNewest + + + swagger-ui\lib\swagger-client.js + PreserveNewest + + + swagger-ui\lib\swagger-oauth.js + PreserveNewest + + + swagger-ui\lib\underscore-min.js + PreserveNewest + + + swagger-ui\o2c.html + PreserveNewest + + + swagger-ui\patch.js + PreserveNewest + + + swagger-ui\swagger-ui.js + PreserveNewest + + + swagger-ui\swagger-ui.min.js + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.eot + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.ttf + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.woff + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.woff2 + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.eot + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.ttf + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.woff + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.woff2 + PreserveNewest + @@ -609,10 +705,30 @@ + + swagger-ui\css\reset.css + PreserveNewest + swagger-ui\css\screen.css PreserveNewest + + swagger-ui\css\typography.css + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-700.svg + PreserveNewest + + + swagger-ui\fonts\droid-sans-v6-latin-regular.svg + PreserveNewest + + + swagger-ui\images\explorer_icons.png + PreserveNewest + swagger-ui\images\logo_small.png PreserveNewest @@ -633,58 +749,10 @@ swagger-ui\index.html PreserveNewest - - swagger-ui\lib\backbone-min.js - PreserveNewest - - - swagger-ui\lib\handlebars-1.0.0.js - PreserveNewest - - - swagger-ui\lib\highlight.7.3.pack.js - PreserveNewest - - - swagger-ui\lib\jquery-1.8.0.min.js - PreserveNewest - - - swagger-ui\lib\jquery.ba-bbq.min.js - PreserveNewest - - - swagger-ui\lib\jquery.slideto.min.js - PreserveNewest - - - swagger-ui\lib\jquery.wiggle.min.js - PreserveNewest - - - swagger-ui\lib\shred.bundle.js - PreserveNewest - swagger-ui\lib\shred\content.js PreserveNewest - - swagger-ui\lib\swagger.js - PreserveNewest - - - swagger-ui\lib\underscore-min.js - PreserveNewest - - - swagger-ui\swagger-ui.js - PreserveNewest - - - swagger-ui\swagger-ui.min.js - PreserveNewest - diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index a54fa0a29..84aab5e1f 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1134,11 +1134,11 @@ namespace MediaBrowser.Server.Implementations.Session /// /// The cancellation token. /// Task. - public Task SendRestartRequiredNotification(CancellationToken cancellationToken) + public async Task SendRestartRequiredNotification(CancellationToken cancellationToken) { var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null).ToList(); - var info = _appHost.GetSystemInfo(); + var info = await _appHost.GetSystemInfo().ConfigureAwait(false); var tasks = sessions.Select(session => Task.Run(async () => { @@ -1153,7 +1153,7 @@ namespace MediaBrowser.Server.Implementations.Session }, cancellationToken)); - return Task.WhenAll(tasks); + await Task.WhenAll(tasks).ConfigureAwait(false); } /// diff --git a/MediaBrowser.Server.Implementations/Social/SharingManager.cs b/MediaBrowser.Server.Implementations/Social/SharingManager.cs index 2ffd33ca4..95f0ece0c 100644 --- a/MediaBrowser.Server.Implementations/Social/SharingManager.cs +++ b/MediaBrowser.Server.Implementations/Social/SharingManager.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Server.Implementations.Social throw new ResourceNotFoundException(); } - var externalUrl = _appHost.GetSystemInfo().WanAddress; + var externalUrl = (await _appHost.GetSystemInfo().ConfigureAwait(false)).WanAddress; if (string.IsNullOrWhiteSpace(externalUrl)) { @@ -58,7 +58,7 @@ namespace MediaBrowser.Server.Implementations.Social UserId = userId }; - AddShareInfo(info); + AddShareInfo(info, externalUrl); await _repository.CreateShare(info).ConfigureAwait(false); @@ -74,15 +74,13 @@ namespace MediaBrowser.Server.Implementations.Social { var info = _repository.GetShareInfo(id); - AddShareInfo(info); + AddShareInfo(info, _appHost.GetSystemInfo().Result.WanAddress); return info; } - private void AddShareInfo(SocialShareInfo info) + private void AddShareInfo(SocialShareInfo info, string externalUrl) { - var externalUrl = _appHost.GetSystemInfo().WanAddress; - info.ImageUrl = externalUrl + "/Social/Shares/Public/" + info.Id + "/Image"; info.Url = externalUrl + "/emby/web/shared.html?id=" + info.Id; diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 642ae1bf0..7341f56cb 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -1098,8 +1098,10 @@ namespace MediaBrowser.Server.Startup.Common /// Gets the system status. /// /// SystemInfo. - public SystemInfo GetSystemInfo() + public async Task GetSystemInfo() { + var localAddress = await GetLocalApiUrl().ConfigureAwait(false); + return new SystemInfo { HasPendingRestart = HasPendingRestart, @@ -1130,7 +1132,7 @@ namespace MediaBrowser.Server.Startup.Common IsRunningAsService = IsRunningAsService, SupportsRunningAsService = SupportsRunningAsService, ServerName = FriendlyName, - LocalAddress = GetLocalApiUrl().Result, + LocalAddress = localAddress, SupportsLibraryMonitor = SupportsLibraryMonitor }; }