The Free Software Media System - Server Backend & API
Added SupportsAutoRunAtStartup
Luke Pulverentib4ac51aa1052
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex 6cec2118bc..e985fb615a 100644--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs@@ -1,4 +1,5 @@-using MediaBrowser.Controller.Library;+using System.Globalization;+using MediaBrowser.Controller.Library;using MediaBrowser.Controller.LiveTv;using MediaBrowser.Model.LiveTv;using MediaBrowser.Model.Querying;@@ -118,6 +119,18 @@ namespace MediaBrowser.Api.LiveTv[ApiMember(Name = "UserId", Description = "Optional filter by user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]public string UserId { get; set; }++ [ApiMember(Name = "MinStartDate", Description = "Optional. The minimum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]+ public string MinStartDate { get; set; }++ [ApiMember(Name = "MaxStartDate", Description = "Optional. The maximum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]+ public string MaxStartDate { get; set; }++ [ApiMember(Name = "MinEndDate", Description = "Optional. The minimum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]+ public string MinEndDate { get; set; }++ [ApiMember(Name = "MaxEndDate", Description = "Optional. The maximum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]+ public string MaxEndDate { get; set; }}[Route("/LiveTv/Programs/{Id}", "GET")]@@ -253,12 +266,33 @@ namespace MediaBrowser.Api.LiveTvpublic object Get(GetPrograms request){- var result = _liveTvManager.GetPrograms(new ProgramQuery+ var query = new ProgramQuery{- ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray(),+ ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToArray(),UserId = request.UserId+ };- }, CancellationToken.None).Result;+ if (!string.IsNullOrEmpty(request.MinStartDate))+ {+ query.MinStartDate = DateTime.ParseExact(request.MinStartDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);+ }++ if (!string.IsNullOrEmpty(request.MinEndDate))+ {+ query.MinEndDate = DateTime.ParseExact(request.MinEndDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);+ }++ if (!string.IsNullOrEmpty(request.MaxStartDate))+ {+ query.MaxStartDate = DateTime.ParseExact(request.MaxStartDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);+ }++ if (!string.IsNullOrEmpty(request.MaxEndDate))+ {+ query.MaxEndDate = DateTime.ParseExact(request.MaxEndDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);+ }++ var result = _liveTvManager.GetPrograms(query, CancellationToken.None).Result;return ToOptimizedResult(result);}diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.csindex f96c2536e6..f3312d2cb8 100644--- a/MediaBrowser.Controller/IServerApplicationHost.cs+++ b/MediaBrowser.Controller/IServerApplicationHost.cs@@ -25,5 +25,11 @@ namespace MediaBrowser.Controller/// </summary>/// <value>The HTTP server URL prefix.</value>string HttpServerUrlPrefix { get; }++ /// <summary>+ /// Gets a value indicating whether [supports automatic run at startup].+ /// </summary>+ /// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>+ bool SupportsAutoRunAtStartup { get; }}}diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.csindex 8676540fd0..93de9d5c34 100644--- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs+++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs@@ -11,7 +11,14 @@ namespace MediaBrowser.Controller.LiveTv/// <returns>System.String.</returns>public override string GetUserDataKey(){- return GetClientTypeName() + "-" + Name;+ var name = GetClientTypeName();++ if (!string.IsNullOrEmpty(RecordingInfo.ProgramId))+ {+ return name + "-" + RecordingInfo.ProgramId;+ }++ return name + "-" + RecordingInfo.Name + (RecordingInfo.EpisodeTitle ?? string.Empty);}public RecordingInfo RecordingInfo { get; set; }diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.csindex 9dfc7f828d..bc4ed54934 100644--- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs+++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs@@ -11,7 +11,14 @@ namespace MediaBrowser.Controller.LiveTv/// <returns>System.String.</returns>public override string GetUserDataKey(){- return GetClientTypeName() + "-" + Name;+ var name = GetClientTypeName();++ if (!string.IsNullOrEmpty(RecordingInfo.ProgramId))+ {+ return name + "-" + RecordingInfo.ProgramId;+ }++ return name + "-" + RecordingInfo.Name + (RecordingInfo.EpisodeTitle ?? string.Empty);}public RecordingInfo RecordingInfo { get; set; }diff --git a/MediaBrowser.Model/LiveTv/ProgramQuery.cs b/MediaBrowser.Model/LiveTv/ProgramQuery.csindex c2a913bc85..36c06d4c08 100644--- a/MediaBrowser.Model/LiveTv/ProgramQuery.cs+++ b/MediaBrowser.Model/LiveTv/ProgramQuery.cs@@ -1,4 +1,6 @@-namespace MediaBrowser.Model.LiveTv+using System;++namespace MediaBrowser.Model.LiveTv{/// <summary>/// Class ProgramQuery.@@ -17,6 +19,14 @@/// <value>The user identifier.</value>public string UserId { get; set; }+ public DateTime? MinStartDate { get; set; }++ public DateTime? MaxStartDate { get; set; }++ public DateTime? MinEndDate { get; set; }++ public DateTime? MaxEndDate { get; set; }+public ProgramQuery(){ChannelIdList = new string[] { };diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.csindex 733c9b6e5c..5fc5f363b6 100644--- a/MediaBrowser.Model/System/SystemInfo.cs+++ b/MediaBrowser.Model/System/SystemInfo.cs@@ -128,6 +128,12 @@ namespace MediaBrowser.Model.System/// <value><c>true</c> if this instance has update available; otherwise, <c>false</c>.</value>public bool HasUpdateAvailable { get; set; }+ /// <summary>+ /// Gets or sets a value indicating whether [supports automatic run at startup].+ /// </summary>+ /// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>+ public bool SupportsAutoRunAtStartup { get; set; }+/// <summary>/// Initializes a new instance of the <see cref="SystemInfo" /> class./// </summary>diff --git a/MediaBrowser.Mono.userprefs b/MediaBrowser.Mono.userprefsindex 6269e1b78c..c6c7831e60 100644--- a/MediaBrowser.Mono.userprefs+++ b/MediaBrowser.Mono.userprefs@@ -1,8 +1,10 @@<Properties><MonoDevelop.Ide.Workspace ActiveConfiguration="Release Mono" />- <MonoDevelop.Ide.Workbench ActiveDocument="MediaBrowser.Server.Mono\app.config">+ <MonoDevelop.Ide.Workbench ActiveDocument="MediaBrowser.Server.Mono\Native\NativeApp.cs"><Files>- <File FileName="MediaBrowser.Server.Mono\app.config" Line="1" Column="1" />+ <File FileName="MediaBrowser.Server.Mono\app.config" Line="14" Column="3" />+ <File FileName="MediaBrowser.ServerApplication\ApplicationHost.cs" Line="189" Column="1" />+ <File FileName="MediaBrowser.Server.Mono\Native\NativeApp.cs" Line="40" Column="17" /></Files></MonoDevelop.Ide.Workbench><MonoDevelop.Ide.DebuggingService.Breakpoints>diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 131c5c0fbe..332cbf0167 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -336,6 +336,34 @@ namespace MediaBrowser.Server.Implementations.LiveTv{IEnumerable<LiveTvProgram> programs = _programs.Values;+ if (query.MinEndDate.HasValue)+ {+ var val = query.MinEndDate.Value;++ programs = programs.Where(i => i.ProgramInfo.EndDate >= val);+ }++ if (query.MinStartDate.HasValue)+ {+ var val = query.MinStartDate.Value;++ programs = programs.Where(i => i.ProgramInfo.StartDate >= val);+ }++ if (query.MaxEndDate.HasValue)+ {+ var val = query.MaxEndDate.Value;++ programs = programs.Where(i => i.ProgramInfo.EndDate <= val);+ }++ if (query.MaxStartDate.HasValue)+ {+ var val = query.MaxStartDate.Value;++ programs = programs.Where(i => i.ProgramInfo.StartDate <= val);+ }+if (query.ChannelIdList.Length > 0){var guids = query.ChannelIdList.Select(i => new Guid(i)).ToList();@@ -355,7 +383,9 @@ namespace MediaBrowser.Server.Implementations.LiveTvif (user != null){- programs = programs.Where(i => i.IsParentalAllowed(user));+ // Avoid implicitly captured closure+ var currentUser = user;+ programs = programs.Where(i => i.IsParentalAllowed(currentUser));}var returnArray = programsdiff --git a/MediaBrowser.Server.Mono/Native/NativeApp.cs b/MediaBrowser.Server.Mono/Native/NativeApp.csindex b8c4447e5f..deff79b4ba 100644--- a/MediaBrowser.Server.Mono/Native/NativeApp.cs+++ b/MediaBrowser.Server.Mono/Native/NativeApp.cs@@ -46,5 +46,10 @@ namespace MediaBrowser.ServerApplication.Nativereturn MainClass.CanSelfUpdate;}}++ public static bool SupportsAutoRunAtStartup+ {+ get { return false; }+ }}}diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.csindex 0e66f2caf9..e027728831 100644--- a/MediaBrowser.ServerApplication/ApplicationHost.cs+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs@@ -1,5 +1,4 @@-using System.Globalization;-using MediaBrowser.Api;+using MediaBrowser.Api;using MediaBrowser.Common;using MediaBrowser.Common.Configuration;using MediaBrowser.Common.Constants;@@ -58,6 +57,7 @@ using MediaBrowser.ServerApplication.Networking;using MediaBrowser.WebDashboard.Api;using System;using System.Collections.Generic;+using System.Globalization;using System.IO;using System.Linq;using System.Reflection;@@ -186,6 +186,11 @@ namespace MediaBrowser.ServerApplicationget { return NativeApp.CanSelfRestart; }}+ public bool SupportsAutoRunAtStartup+ {+ get { return NativeApp.SupportsAutoRunAtStartup; }+ }+/// <summary>/// Runs the startup tasks./// </summary>@@ -629,7 +634,8 @@ namespace MediaBrowser.ServerApplicationCanSelfRestart = CanSelfRestart,CanSelfUpdate = CanSelfUpdate,WanAddress = GetWanAddress(),- HasUpdateAvailable = _hasUpdateAvailable+ HasUpdateAvailable = _hasUpdateAvailable,+ SupportsAutoRunAtStartup = SupportsAutoRunAtStartup};}@@ -736,9 +742,16 @@ namespace MediaBrowser.ServerApplicationOnApplicationUpdated(package.version);}+ /// <summary>+ /// Configures the automatic run at startup.+ /// </summary>+ /// <param name="autorun">if set to <c>true</c> [autorun].</param>protected override void ConfigureAutoRunAtStartup(bool autorun){- Autorun.Configure(autorun);+ if (SupportsAutoRunAtStartup)+ {+ Autorun.Configure(autorun);+ }}}}diff --git a/MediaBrowser.ServerApplication/Native/NativeApp.cs b/MediaBrowser.ServerApplication/Native/NativeApp.csindex c0d3e876a5..646a7bc98b 100644--- a/MediaBrowser.ServerApplication/Native/NativeApp.cs+++ b/MediaBrowser.ServerApplication/Native/NativeApp.cs@@ -34,6 +34,18 @@ namespace MediaBrowser.ServerApplication.Native}}+ /// <summary>+ /// Gets a value indicating whether [supports automatic run at startup].+ /// </summary>+ /// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>+ public static bool SupportsAutoRunAtStartup+ {+ get+ {+ return true;+ }+ }+/// <summary>/// Gets a value indicating whether this instance can self update./// </summary>