Added SupportsAutoRunAtStartup

pull/702/head
Luke Pulverenti 11 years ago
parent 6ed380ed1b
commit b4ac51aa10

@ -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.LiveTv
public 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);
}

@ -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; }
}
}

@ -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; }

@ -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; }

@ -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[] { };

@ -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>

@ -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>

@ -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.LiveTv
if (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 = programs

@ -46,5 +46,10 @@ namespace MediaBrowser.ServerApplication.Native
return MainClass.CanSelfUpdate;
}
}
public static bool SupportsAutoRunAtStartup
{
get { return false; }
}
}
}

@ -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.ServerApplication
get { return NativeApp.CanSelfRestart; }
}
public bool SupportsAutoRunAtStartup
{
get { return NativeApp.SupportsAutoRunAtStartup; }
}
/// <summary>
/// Runs the startup tasks.
/// </summary>
@ -629,7 +634,8 @@ namespace MediaBrowser.ServerApplication
CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate,
WanAddress = GetWanAddress(),
HasUpdateAvailable = _hasUpdateAvailable
HasUpdateAvailable = _hasUpdateAvailable,
SupportsAutoRunAtStartup = SupportsAutoRunAtStartup
};
}
@ -736,9 +742,16 @@ namespace MediaBrowser.ServerApplication
OnApplicationUpdated(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);
}
}
}
}

@ -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>

Loading…
Cancel
Save